Bazaar developer reference

CvCity::HasResource(ResourceTypes) const

Defined in
CvCity.cpp, line 17411
Class
CvCity
Hook name
CivHooks::CvCity_HasResource

Hooks

static bool BeforeCvCity_HasResource(const CvCity* self, ResourceTypes iResourceType, bool& result);static void AfterCvCity_HasResource(const CvCity* self, ResourceTypes iResourceType, bool& result);static bool ReplaceCvCity_HasResource(bool (*original)(const CvCity*, ResourceTypes), const CvCity* self, ResourceTypes iResourceType);CivRegisterBefore<CivHooks::CvCity_HasResource>(host, &BeforeCvCity_HasResource);CivRegisterAfter<CivHooks::CvCity_HasResource>(host, &AfterCvCity_HasResource);CivRegisterReplace<CivHooks::CvCity_HasResource>(host, &ReplaceCvCity_HasResource);

Code

17411bool CvCity::HasResource(ResourceTypes iResourceType) const17412{17413	int iX = getX(); int iY = getY(); int iOwner = getOwner();1741417415#if defined(MOD_GLOBAL_CITY_WORKING)17416	for (int iCityPlotLoop = 0; iCityPlotLoop < GetNumWorkablePlots(); iCityPlotLoop++)17417#else17418	for (int iCityPlotLoop = 0; iCityPlotLoop < NUM_CITY_PLOTS; iCityPlotLoop++)17419#endif17420	{17421		CvPlot* pLoopPlot = plotCity(iX, iY, iCityPlotLoop);1742217423		// Invalid plot or not owned by this player17424		if (pLoopPlot == NULL || pLoopPlot->getOwner() != iOwner) {17425			continue;17426		}1742717428		// Team can't see the resource here17429		if (pLoopPlot->getResourceType(getTeam()) != iResourceType) {17430			continue;17431		}1743217433		// Resource not linked to this city17434		// if (pLoopPlot->GetResourceLinkedCity() != this) {17435		// 	continue;17436		// }1743717438		if (pLoopPlot->HasResource(iResourceType)) {17439			return true;17440		}17441	}1744217443	return false;17444}

Calls

Called by