Bazaar developer reference

CvDangerPlots::GetCityDanger(CvCity *)

Defined in
CvDangerPlots.cpp, line 277
Class
CvDangerPlots
Hook name
CivHooks::CvDangerPlots_GetCityDanger

Hooks

static bool BeforeCvDangerPlots_GetCityDanger(CvDangerPlots* self, CvCity* pCity, int& result);static void AfterCvDangerPlots_GetCityDanger(CvDangerPlots* self, CvCity* pCity, int& result);static int ReplaceCvDangerPlots_GetCityDanger(int (*original)(CvDangerPlots*, CvCity*), CvDangerPlots* self, CvCity* pCity);CivRegisterBefore<CivHooks::CvDangerPlots_GetCityDanger>(host, &BeforeCvDangerPlots_GetCityDanger);CivRegisterAfter<CivHooks::CvDangerPlots_GetCityDanger>(host, &AfterCvDangerPlots_GetCityDanger);CivRegisterReplace<CivHooks::CvDangerPlots_GetCityDanger>(host, &ReplaceCvDangerPlots_GetCityDanger);

Code

276/// Sums the danger values of the plots around the city to determine the danger value of the city277int CvDangerPlots::GetCityDanger(CvCity* pCity)278{279	CvAssertMsg(pCity, "pCity is null");280	if(!pCity) return 0;281282	CvAssertMsg(pCity->getOwner() == m_ePlayer, "City does not belong to us");283284	CvPlot* pPlot = pCity->plot();285	int iEvalRange = GC.getAI_DIPLO_PLOT_RANGE_FROM_CITY_HOME_FRONT();286287	int iDangerValue = 0;288289	for(int iX = -iEvalRange; iX <= iEvalRange; iX++)290	{291		for(int iY = -iEvalRange; iY <= iEvalRange; iY++)292		{293			CvPlot* pEvalPlot = plotXYWithRangeCheck(pPlot->getX(), pPlot->getY(), iX, iY, iEvalRange);294			if(!pEvalPlot)295			{296				continue;297			}298299			iDangerValue += GetDanger(*pEvalPlot);300		}301	}302303	return iDangerValue;304}

Calls

Called by