Bazaar developer reference

plotCityXY(const CvCity *, const CvPlot *)

Defined in
CvGameCoreUtils.cpp, line 104
Hook name
CivHooks::plotCityXY

Hooks

static bool BeforeplotCityXY(const CvCity* pCity, const CvPlot* pPlot, int& result);static void AfterplotCityXY(const CvCity* pCity, const CvPlot* pPlot, int& result);static int ReplaceplotCityXY(int (*original)(const CvCity*, const CvPlot*), const CvCity* pCity, const CvPlot* pPlot);CivRegisterBefore<CivHooks::plotCityXY>(host, &BeforeplotCityXY);CivRegisterAfter<CivHooks::plotCityXY>(host, &AfterplotCityXY);CivRegisterReplace<CivHooks::plotCityXY>(host, &ReplaceplotCityXY);

Code

104int plotCityXY(const CvCity* pCity, const CvPlot* pPlot)105{106107	int iDX;108	int iWrappedDX = dxWrap(pPlot->getX() - pCity->getX());109	int iWrappedDY = dyWrap(pPlot->getY() - pCity->getY());110	int iDY = iWrappedDY;111112	// convert to hex-space coordinates - the coordinate system axes are E and NE (not orthogonal)113	int iCityHexX = xToHexspaceX(pCity->getX(), pCity->getY());114	int iPlotHexX = xToHexspaceX(pCity->getX() + iWrappedDX, pCity->getY() + iWrappedDY);115116	iDX = dxWrap(iPlotHexX - iCityHexX);117118#if defined(MOD_GLOBAL_CITY_WORKING)119	if(hexDistance(iDX, iDY) > pCity->getWorkPlotDistance())120#else121	if(hexDistance(iDX, iDY) > CITY_PLOTS_RADIUS)122#endif123	{124		return -1;125	}126	else127	{128#if defined(MOD_GLOBAL_CITY_WORKING)129		// Regardless of the working radius, we need to offset into the array by the maximum radius130		return GC.getXYCityPlot((iDX + MAX_CITY_RADIUS), (iDY + MAX_CITY_RADIUS));131#else132		return GC.getXYCityPlot((iDX + CITY_PLOTS_RADIUS), (iDY + CITY_PLOTS_RADIUS));133#endif134	}135}

Calls

Called by