void CvGameObjectPlayer::foreach(GameObjectTypes eType, boost::function<void (CvGameObject*)> func) { int iLoop; switch(eType) { case GAMEOBJECT_GAME: func(GC.getGameINLINE().getGameObject()); break; case GAMEOBJECT_TEAM: func(GET_TEAM(m_pPlayer->getTeam()).getGameObject()); break; case GAMEOBJECT_CITY: for (CvCity* pCity = m_pPlayer->firstCity(&iLoop); pCity != NULL; pCity = m_pPlayer->nextCity(&iLoop)) { func(pCity->getGameObject()); } break; case GAMEOBJECT_UNIT: for (CvUnit* pUnit = m_pPlayer->firstUnit(&iLoop); pUnit != NULL; pUnit = m_pPlayer->nextUnit(&iLoop)) { func(pUnit->getGameObject()); } break; case GAMEOBJECT_PLOT: for (int iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++) { CvPlot* pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI); if (pLoopPlot->getOwnerINLINE() == m_pPlayer->getID()) { func(pLoopPlot->getGameObject()); } } break; case GAMEOBJECT_PLAYER: func(this); break; } }
///Tks Med CvPlot* CvMap::syncRandPlot(int iFlags, int iArea, int iMinUnitDistance, int iTimeout, bool bIgnoreNativeTeams) { ///TKe CvPlot* pPlot = NULL; int iCount = 0; while (iCount < iTimeout) { CvPlot* pTestPlot = plotSorenINLINE(GC.getGameINLINE().getSorenRandNum(getGridWidthINLINE(), "Rand Plot Width"), GC.getGameINLINE().getSorenRandNum(getGridHeightINLINE(), "Rand Plot Height")); FAssertMsg(pTestPlot != NULL, "TestPlot is not assigned a valid value"); if ((iArea == -1) || (pTestPlot->getArea() == iArea)) { bool bValid = true; if (bValid) { if (iMinUnitDistance != -1) { for (int iDX = -(iMinUnitDistance); iDX <= iMinUnitDistance; iDX++) { for (int iDY = -(iMinUnitDistance); iDY <= iMinUnitDistance; iDY++) { CvPlot* pLoopPlot = plotXY(pTestPlot->getX_INLINE(), pTestPlot->getY_INLINE(), iDX, iDY); if (pLoopPlot != NULL) { if (pLoopPlot->isUnit()) { bValid = false; } } } } } } if (bValid) { if (iFlags & RANDPLOT_LAND) { if (pTestPlot->isWater()) { bValid = false; } } } if (bValid) { if (iFlags & RANDPLOT_UNOWNED) { if (pTestPlot->isOwned()) { ///Tks Med if (bIgnoreNativeTeams) { if (!GET_PLAYER(pTestPlot->getOwnerINLINE()).isNative()) { bValid = false; } } else { bValid = false; } ///TKe } } } if (bValid) { if (iFlags & RANDPLOT_ADJACENT_UNOWNED) { if (pTestPlot->isAdjacentOwned()) { bValid = false; } } } if (bValid) { if (iFlags & RANDPLOT_ADJACENT_LAND) { if (!(pTestPlot->isAdjacentToLand())) { bValid = false; } } } if (bValid) { if (iFlags & RANDPLOT_PASSIBLE) { if (pTestPlot->isImpassable()) { bValid = false; } } } if (bValid) { if (iFlags & RANDPLOT_NOT_VISIBLE_TO_CIV) { ///TKs Med if (pTestPlot->isVisibleToCivTeam(bIgnoreNativeTeams)) { bValid = false; } ///TKe } } ///TKs Med if (bValid) { if (bIgnoreNativeTeams) { if (pTestPlot->isVisibleToWatchingHuman()) { bValid = false; } } } ///TKe if (bValid) { if (iFlags & RANDPLOT_NOT_CITY) { if (pTestPlot->isCity()) { bValid = false; } } } if (bValid) { pPlot = pTestPlot; break; } } iCount++; } return pPlot; }