Bazaar developer reference

CvCity::CountTerrain(TerrainTypes) const

Defined in
CvCity.cpp, line 18006
Class
CvCity
Hook name
CivHooks::CvCity_CountTerrain

Hooks

static bool BeforeCvCity_CountTerrain(const CvCity* self, TerrainTypes iTerrainType, int& result);static void AfterCvCity_CountTerrain(const CvCity* self, TerrainTypes iTerrainType, int& result);static int ReplaceCvCity_CountTerrain(int (*original)(const CvCity*, TerrainTypes), const CvCity* self, TerrainTypes iTerrainType);CivRegisterBefore<CivHooks::CvCity_CountTerrain>(host, &BeforeCvCity_CountTerrain);CivRegisterAfter<CivHooks::CvCity_CountTerrain>(host, &AfterCvCity_CountTerrain);CivRegisterReplace<CivHooks::CvCity_CountTerrain>(host, &ReplaceCvCity_CountTerrain);

Code

18006int CvCity::CountTerrain(TerrainTypes iTerrainType) const18007{18008	int iCount = 0;18009	int iX = getX(); int iY = getY(); int iOwner = getOwner();1801018011#if defined(MOD_GLOBAL_CITY_WORKING)18012	for (int iCityPlotLoop = 0; iCityPlotLoop < GetNumWorkablePlots(); iCityPlotLoop++)18013#else18014	for (int iCityPlotLoop = 0; iCityPlotLoop < NUM_CITY_PLOTS; iCityPlotLoop++)18015#endif18016	{18017		CvPlot* pLoopPlot = plotCity(iX, iY, iCityPlotLoop);1801818019		// Invalid plot or not owned by this player18020		if (pLoopPlot == NULL || pLoopPlot->getOwner() != iOwner) {18021			continue;18022		}1802318024		// Not owned by this city18025		if (pLoopPlot->getWorkingCity() != this) {18026			continue;18027		}1802818029		if (pLoopPlot->HasTerrain(iTerrainType)) {18030			++iCount;18031		}18032	}18033	18034	return iCount;18035}

Calls

Called by