Bazaar developer reference

CvCity::doGrowth()

Defined in
CvCity.cpp, line 14544
Class
CvCity
Hook name
CivHooks::CvCity_doGrowth

Hooks

static bool BeforeCvCity_doGrowth(CvCity* self);static void AfterCvCity_doGrowth(CvCity* self);static void ReplaceCvCity_doGrowth(void (*original)(CvCity*), CvCity* self);CivRegisterBefore<CivHooks::CvCity_doGrowth>(host, &BeforeCvCity_doGrowth);CivRegisterAfter<CivHooks::CvCity_doGrowth>(host, &AfterCvCity_doGrowth);CivRegisterReplace<CivHooks::CvCity_doGrowth>(host, &ReplaceCvCity_doGrowth);

Code

14544void CvCity::doGrowth()14545{14546	VALIDATE_OBJECT14547	AI_PERF_FORMAT("City-AI-perf.csv", ("CvCity::doGrowth, Turn %03d, %s, %s", GC.getGame().getElapsedGameTurns(), GetPlayer()->getCivilizationShortDescription(), getName().c_str()) );14548	// here would be a good place to override this in Lua1454914550	// No growth or starvation if being razed14551	if(IsRazing())14552	{14553		return;14554	}1455514556	int iDiff = foodDifferenceTimes100();1455714558	if(iDiff < 0)14559	{14560		CvNotifications* pNotifications = GET_PLAYER(getOwner()).GetNotifications();14561		if(pNotifications)14562		{14563			Localization::String text = Localization::Lookup("TXT_KEY_NTFN_CITY_STARVING");14564			text << getNameKey();14565			Localization::String summary = Localization::Lookup("TXT_KEY_NTFN_CITY_STARVING_S");14566			summary << getNameKey();1456714568			pNotifications->Add(NOTIFICATION_STARVING, text.toUTF8(), summary.toUTF8(), getX(), getY(), -1);14569		}14570	}1457114572	changeFoodTimes100(iDiff);14573	changeFoodKept(iDiff/100);1457414575	setFoodKept(range(getFoodKept(), 0, ((growthThreshold() * getMaxFoodKeptPercent()) / 100)));1457614577	if(getFood() >= growthThreshold())14578	{14579		if(GetCityCitizens()->IsForcedAvoidGrowth())  // don't grow a city if we are at avoid growth14580		{14581			setFood(growthThreshold());14582		}14583		else14584		{14585			changeFood(-(std::max(0, (growthThreshold() - getFoodKept()))));14586			changePopulation(1);1458714588			// Only show notification if the city is small14589			if(getPopulation() <= 5)14590			{14591				CvNotifications* pNotifications = GET_PLAYER(getOwner()).GetNotifications();14592				if(pNotifications)14593				{14594					Localization::String localizedText = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_GROWTH");14595					localizedText << getNameKey() << getPopulation();14596					Localization::String localizedSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_CITY_GROWTH");14597					localizedSummary << getNameKey();14598					pNotifications->Add(NOTIFICATION_CITY_GROWTH, localizedText.toUTF8(), localizedSummary.toUTF8(), getX(), getY(), GetID());14599				}14600			}14601		}14602	}14603	else if(getFood() < 0)14604	{14605		changeFood(-(getFood()));1460614607		if(getPopulation() > 1)14608		{14609			changePopulation(-1);14610		}14611	}14612}

Calls

Called by