Bazaar developer reference

CvCity::CountFeature(FeatureTypes) const

Defined in
CvCity.cpp, line 17758
Class
CvCity
Hook name
CivHooks::CvCity_CountFeature

Hooks

static bool BeforeCvCity_CountFeature(const CvCity* self, FeatureTypes iFeatureType, int& result);static void AfterCvCity_CountFeature(const CvCity* self, FeatureTypes iFeatureType, int& result);static int ReplaceCvCity_CountFeature(int (*original)(const CvCity*, FeatureTypes), const CvCity* self, FeatureTypes iFeatureType);CivRegisterBefore<CivHooks::CvCity_CountFeature>(host, &BeforeCvCity_CountFeature);CivRegisterAfter<CivHooks::CvCity_CountFeature>(host, &AfterCvCity_CountFeature);CivRegisterReplace<CivHooks::CvCity_CountFeature>(host, &ReplaceCvCity_CountFeature);

Code

17758int CvCity::CountFeature(FeatureTypes iFeatureType) const17759{17760	int iCount = 0;17761	int iX = getX(); int iY = getY(); int iOwner = getOwner();1776217763#if defined(MOD_GLOBAL_CITY_WORKING)17764	for (int iCityPlotLoop = 0; iCityPlotLoop < GetNumWorkablePlots(); iCityPlotLoop++)17765#else17766	for (int iCityPlotLoop = 0; iCityPlotLoop < NUM_CITY_PLOTS; iCityPlotLoop++)17767#endif17768	{17769		CvPlot* pLoopPlot = plotCity(iX, iY, iCityPlotLoop);1777017771		// Invalid plot or not owned by this player17772		if (pLoopPlot == NULL || pLoopPlot->getOwner() != iOwner) {17773			continue;17774		}1777517776		// Not owned by this city17777		if (pLoopPlot->getWorkingCity() != this) {17778			continue;17779		}1778017781		if (pLoopPlot->HasFeature(iFeatureType)) {17782			++iCount;17783		}17784	}17785	17786	return iCount;17787}

Calls

Called by