CvCity::CountWorkedPlotType(PlotTypes) const
- Defined in
- CvCity.cpp, line 17913
- Class
- CvCity
- Hook name
CivHooks::CvCity_CountWorkedPlotType
Hooks
static bool BeforeCvCity_CountWorkedPlotType(const CvCity* self, PlotTypes iPlotType, int& result);static void AfterCvCity_CountWorkedPlotType(const CvCity* self, PlotTypes iPlotType, int& result);static int ReplaceCvCity_CountWorkedPlotType(int (*original)(const CvCity*, PlotTypes), const CvCity* self, PlotTypes iPlotType);CivRegisterBefore<CivHooks::CvCity_CountWorkedPlotType>(host, &BeforeCvCity_CountWorkedPlotType);CivRegisterAfter<CivHooks::CvCity_CountWorkedPlotType>(host, &AfterCvCity_CountWorkedPlotType);CivRegisterReplace<CivHooks::CvCity_CountWorkedPlotType>(host, &ReplaceCvCity_CountWorkedPlotType);
Code
17913int CvCity::CountWorkedPlotType(PlotTypes iPlotType) const17914{17915 int iCount = 0;17916 int iX = getX(); int iY = getY(); int iOwner = getOwner();1791717918#if defined(MOD_GLOBAL_CITY_WORKING)17919 for (int iCityPlotLoop = 0; iCityPlotLoop < GetNumWorkablePlots(); iCityPlotLoop++)17920#else17921 for (int iCityPlotLoop = 0; iCityPlotLoop < NUM_CITY_PLOTS; iCityPlotLoop++)17922#endif17923 {17924 CvPlot* pLoopPlot = plotCity(iX, iY, iCityPlotLoop);1792517926 // Invalid plot or not owned by this player17927 if (pLoopPlot == NULL || pLoopPlot->getOwner() != iOwner) {17928 continue;17929 }1793017931 // Not being worked by this city17932 if (pLoopPlot->getWorkingCity() != this || !pLoopPlot->isBeingWorked()) {17933 continue;17934 }1793517936 if (pLoopPlot->HasPlotType(iPlotType)) {17937 ++iCount;17938 }17939 }17940 17941 return iCount;17942}