Bazaar developer reference

CvCity::CountWorkedTerrain(TerrainTypes) const

Defined in
CvCity.cpp, line 18037
Class
CvCity
Hook name
CivHooks::CvCity_CountWorkedTerrain

Hooks

static bool BeforeCvCity_CountWorkedTerrain(const CvCity* self, TerrainTypes iTerrainType, int& result);static void AfterCvCity_CountWorkedTerrain(const CvCity* self, TerrainTypes iTerrainType, int& result);static int ReplaceCvCity_CountWorkedTerrain(int (*original)(const CvCity*, TerrainTypes), const CvCity* self, TerrainTypes iTerrainType);CivRegisterBefore<CivHooks::CvCity_CountWorkedTerrain>(host, &BeforeCvCity_CountWorkedTerrain);CivRegisterAfter<CivHooks::CvCity_CountWorkedTerrain>(host, &AfterCvCity_CountWorkedTerrain);CivRegisterReplace<CivHooks::CvCity_CountWorkedTerrain>(host, &ReplaceCvCity_CountWorkedTerrain);

Code

18037int CvCity::CountWorkedTerrain(TerrainTypes iTerrainType) const18038{18039	int iCount = 0;18040	int iX = getX(); int iY = getY(); int iOwner = getOwner();1804118042#if defined(MOD_GLOBAL_CITY_WORKING)18043	for (int iCityPlotLoop = 0; iCityPlotLoop < GetNumWorkablePlots(); iCityPlotLoop++)18044#else18045	for (int iCityPlotLoop = 0; iCityPlotLoop < NUM_CITY_PLOTS; iCityPlotLoop++)18046#endif18047	{18048		CvPlot* pLoopPlot = plotCity(iX, iY, iCityPlotLoop);1804918050		// Invalid plot or not owned by this player18051		if (pLoopPlot == NULL || pLoopPlot->getOwner() != iOwner) {18052			continue;18053		}1805418055		// Not being worked by this city18056		if (pLoopPlot->getWorkingCity() != this || !pLoopPlot->isBeingWorked()) {18057			continue;18058		}1805918060		if (pLoopPlot->HasTerrain(iTerrainType)) {18061			++iCount;18062		}18063	}1806418065	return iCount;18066}

Calls

Called by