CvCity::CountWorkedImprovement(ImprovementTypes) const
- Defined in
- CvCity.cpp, line 17851
- Class
- CvCity
- Hook name
CivHooks::CvCity_CountWorkedImprovement
Hooks
static bool BeforeCvCity_CountWorkedImprovement(const CvCity* self, ImprovementTypes iImprovementType, int& result);static void AfterCvCity_CountWorkedImprovement(const CvCity* self, ImprovementTypes iImprovementType, int& result);static int ReplaceCvCity_CountWorkedImprovement(int (*original)(const CvCity*, ImprovementTypes), const CvCity* self, ImprovementTypes iImprovementType);CivRegisterBefore<CivHooks::CvCity_CountWorkedImprovement>(host, &BeforeCvCity_CountWorkedImprovement);CivRegisterAfter<CivHooks::CvCity_CountWorkedImprovement>(host, &AfterCvCity_CountWorkedImprovement);CivRegisterReplace<CivHooks::CvCity_CountWorkedImprovement>(host, &ReplaceCvCity_CountWorkedImprovement);
Code
17851int CvCity::CountWorkedImprovement(ImprovementTypes iImprovementType) const17852{17853 int iCount = 0;17854 int iX = getX(); int iY = getY(); int iOwner = getOwner();1785517856#if defined(MOD_GLOBAL_CITY_WORKING)17857 for (int iCityPlotLoop = 0; iCityPlotLoop < GetNumWorkablePlots(); iCityPlotLoop++)17858#else17859 for (int iCityPlotLoop = 0; iCityPlotLoop < NUM_CITY_PLOTS; iCityPlotLoop++)17860#endif17861 {17862 CvPlot* pLoopPlot = plotCity(iX, iY, iCityPlotLoop);1786317864 // Invalid plot or not owned by this player17865 if (pLoopPlot == NULL || pLoopPlot->getOwner() != iOwner) {17866 continue;17867 }1786817869 // Not being worked by this city17870 if (pLoopPlot->getWorkingCity() != this || !pLoopPlot->isBeingWorked()) {17871 continue;17872 }1787317874 if (pLoopPlot->HasImprovement(iImprovementType)) {17875 ++iCount;17876 }17877 }17878 17879 return iCount;17880}