CvCity::CountImprovement(ImprovementTypes) const
- Defined in
- CvCity.cpp, line 17820
- Class
- CvCity
- Hook name
CivHooks::CvCity_CountImprovement
Hooks
static bool BeforeCvCity_CountImprovement(const CvCity* self, ImprovementTypes iImprovementType, int& result);static void AfterCvCity_CountImprovement(const CvCity* self, ImprovementTypes iImprovementType, int& result);static int ReplaceCvCity_CountImprovement(int (*original)(const CvCity*, ImprovementTypes), const CvCity* self, ImprovementTypes iImprovementType);CivRegisterBefore<CivHooks::CvCity_CountImprovement>(host, &BeforeCvCity_CountImprovement);CivRegisterAfter<CivHooks::CvCity_CountImprovement>(host, &AfterCvCity_CountImprovement);CivRegisterReplace<CivHooks::CvCity_CountImprovement>(host, &ReplaceCvCity_CountImprovement);
Code
17820int CvCity::CountImprovement(ImprovementTypes iImprovementType) const17821{17822 int iCount = 0;17823 int iX = getX(); int iY = getY(); int iOwner = getOwner();1782417825#if defined(MOD_GLOBAL_CITY_WORKING)17826 for (int iCityPlotLoop = 0; iCityPlotLoop < GetNumWorkablePlots(); iCityPlotLoop++)17827#else17828 for (int iCityPlotLoop = 0; iCityPlotLoop < NUM_CITY_PLOTS; iCityPlotLoop++)17829#endif17830 {17831 CvPlot* pLoopPlot = plotCity(iX, iY, iCityPlotLoop);1783217833 // Invalid plot or not owned by this player17834 if (pLoopPlot == NULL || pLoopPlot->getOwner() != iOwner) {17835 continue;17836 }1783717838 // Not owned by this city17839 if (pLoopPlot->getWorkingCity() != this) {17840 continue;17841 }1784217843 if (pLoopPlot->HasImprovement(iImprovementType)) {17844 ++iCount;17845 }17846 }17847 17848 return iCount;17849}