本文整理汇总了C++中Town::initServer方法的典型用法代码示例。如果您正苦于以下问题:C++ Town::initServer方法的具体用法?C++ Town::initServer怎么用?C++ Town::initServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Town
的用法示例。
在下文中一共展示了Town::initServer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFromServer
// -----------------------------------------------------------------
// Name : createFromServer
// -----------------------------------------------------------------
void Map::createFromServer(MapReader * pMapReader, LocalClient * pLocalClient)
{
m_iWidth = pMapReader->getMapWidth();
m_iHeight = pMapReader->getMapHeight();
int * pTiles = pMapReader->getMap();
m_pTiles = new MapTile**[m_iWidth];
for (u16 x = 0; x < m_iWidth; x++)
{
m_pTiles[x] = new MapTile*[m_iHeight];
for (u16 y = 0; y < m_iHeight; y++)
{
if (IS_VALID_TERRAIN(pTiles[y * m_iWidth + x]))
m_pTiles[x][y] = new MapTile(pTiles[y * m_iWidth + x], pLocalClient->getServer()->getSolver()->getGlobalSpellsPtr());
else
{
m_pTiles[x][y] = new MapTile(TERRAIN_SEA, pLocalClient->getServer()->getSolver()->getGlobalSpellsPtr());
char sError[512];
snprintf(sError, 512, "Invalid terrain type at (%d,%d)", (int)x, (int)y);
pLocalClient->getDebug()->notifyErrorMessage(sError);
}
}
}
// Reset used town names and heroes
Edition * pEdition = pLocalClient->getDataFactory()->getFirstEdition();
while (pEdition != NULL)
{
Ethnicity * pEthn = (Ethnicity*) pEdition->getEthnicities()->getFirst(0);
while (pEthn != NULL)
{
pEthn->resetUsedTownNames();
pEthn->resetUsedHeroes();
pEthn = (Ethnicity*) pEdition->getEthnicities()->getNext(0);
}
pEdition = pLocalClient->getDataFactory()->getNextEdition();
}
// Create towns
std::vector<TownData> * towns = pMapReader->getTowns();
for (u16 i = 0; i < towns->size(); i++)
{
if (getTileAt((*towns)[i].position)->m_uTerrainType == TERRAIN_SEA)
continue;
Edition * pEdition = pLocalClient->getDataFactory()->findEdition((*towns)[i].sEthnEdition);
if (pEdition != NULL)
{
Ethnicity * pEthn = pEdition->findEthnicity((*towns)[i].sEthnId);
if (pEthn != NULL)
{
Town * pTown = new Town((*towns)[i].position, this, pLocalClient->getServer()->getSolver()->getGlobalSpellsPtr());
pTown->init(m_iNbTowns++, (*towns)[i].size, pEthn, pLocalClient);
pTown->initServer();
m_pTownsRef->addLast(pTown);
}
}
}
// Create temples
std::vector<TempleData> * temples = pMapReader->getTemples();
for (u16 i = 0; i < temples->size(); i++)
{
if (getTileAt((*temples)[i].position)->m_uTerrainType == TERRAIN_SEA)
continue;
Temple * pTemple = new Temple((*temples)[i].position, this, pLocalClient->getServer()->getSolver()->getGlobalSpellsPtr());
pTemple->init(m_iNbTemples++, (*temples)[i].mana, (*temples)[i].amount);
m_pTemplesRef->addLast(pTemple);
}
// Create special tiles
std::vector<CoordsMap> * spectiles = pMapReader->getSpecialTiles();
char pAllTerrains[7][64] = LTERRAIN_NAMES;
for (u16 i = 0; i < spectiles->size(); i++)
{
MapTile * pTile = getTileAt((*spectiles)[i]);
// First get total frequency
int totalFreq = 0;
Edition * pEd = pLocalClient->getDataFactory()->getFirstEdition();
while (pEd != NULL)
{
SpecialTile * pSpec = (SpecialTile*) pEd->getSpecialTiles()->getFirst(0);
while (pSpec != NULL)
{
pSpec->callLuaFunction("isAllowedOn", 1, "s", pAllTerrains[pTile->m_uTerrainType]);
if (pSpec->getLuaNumber() > 0)
totalFreq += pSpec->getFrequency();
pSpec = (SpecialTile*) pEd->getSpecialTiles()->getNext(0);
}
pEd = pLocalClient->getDataFactory()->getNextEdition();
}
if (totalFreq > 0)
{
bool bBreak = false;
int iRnd = getRandom(totalFreq);
pEd = pLocalClient->getDataFactory()->getFirstEdition();
while (pEd != NULL)
{
SpecialTile * pSpec = (SpecialTile*) pEd->getSpecialTiles()->getFirst(0);
while (pSpec != NULL)
{
pSpec->callLuaFunction("isAllowedOn", 1, "s", pAllTerrains[pTile->m_uTerrainType]);
if (pSpec->getLuaNumber() > 0)
//.........这里部分代码省略.........