Bazaar developer reference

CvCityStrategyAI::ReweightByCost()

Defined in
CvCityStrategyAI.cpp, line 1828
Class
CvCityStrategyAI
Hook name
CivHooks::CvCityStrategyAI_ReweightByCost

Hooks

static bool BeforeCvCityStrategyAI_ReweightByCost(CvCityStrategyAI* self);static void AfterCvCityStrategyAI_ReweightByCost(CvCityStrategyAI* self);static void ReplaceCvCityStrategyAI_ReweightByCost(void (*original)(CvCityStrategyAI*), CvCityStrategyAI* self);CivRegisterBefore<CivHooks::CvCityStrategyAI_ReweightByCost>(host, &BeforeCvCityStrategyAI_ReweightByCost);CivRegisterAfter<CivHooks::CvCityStrategyAI_ReweightByCost>(host, &AfterCvCityStrategyAI_ReweightByCost);CivRegisterReplace<CivHooks::CvCityStrategyAI_ReweightByCost>(host, &ReplaceCvCityStrategyAI_ReweightByCost);

Code

1827/// Recompute weights taking into account Production cost1828void CvCityStrategyAI::ReweightByCost()1829{1830	CvCityBuildable buildable;18311832	for(int iI = 0; iI < m_Buildables.size(); iI++)1833	{1834		buildable = m_Buildables.GetElement(iI);18351836		// Compute the new weight and change it1837		int iNewWeight = CityStrategyAIHelpers::ReweightByTurnsLeft(m_Buildables.GetWeight(iI), buildable.m_iTurnsToConstruct);1838		m_Buildables.SetWeight(iI, iNewWeight);1839	}1840}

Calls

Called by