Bazaar developer reference

CvPlayer::getAdvancedStartPopCost(bool, CvCity *)

Defined in
CvPlayer.cpp, line 23036
Class
CvPlayer
Hook name
CivHooks::CvPlayer_getAdvancedStartPopCost

Hooks

static bool BeforeCvPlayer_getAdvancedStartPopCost(CvPlayer* self, bool bAdd, CvCity* pCity, int& result);static void AfterCvPlayer_getAdvancedStartPopCost(CvPlayer* self, bool bAdd, CvCity* pCity, int& result);static int ReplaceCvPlayer_getAdvancedStartPopCost(int (*original)(CvPlayer*, bool, CvCity*), CvPlayer* self, bool bAdd, CvCity* pCity);CivRegisterBefore<CivHooks::CvPlayer_getAdvancedStartPopCost>(host, &BeforeCvPlayer_getAdvancedStartPopCost);CivRegisterAfter<CivHooks::CvPlayer_getAdvancedStartPopCost>(host, &AfterCvPlayer_getAdvancedStartPopCost);CivRegisterReplace<CivHooks::CvPlayer_getAdvancedStartPopCost>(host, &ReplaceCvPlayer_getAdvancedStartPopCost);

Code

23036int CvPlayer::getAdvancedStartPopCost(bool bAdd, CvCity* pCity)23037{23038	if(0 == getNumCities())23039	{23040		return -1;23041	}2304223043	int iCost = (getGrowthThreshold(1) * GC.getADVANCED_START_POPULATION_COST()) / 100;2304423045	if(NULL != pCity)23046	{23047		if(pCity->getOwner() != GetID())23048		{23049			return -1;23050		}2305123052		int iPopulation = pCity->getPopulation();2305323054		// Need to have Population to remove it23055		if(!bAdd)23056		{23057			--iPopulation;2305823059			if(iPopulation < GC.getINITIAL_CITY_POPULATION() + GC.getGame().getStartEraInfo().getFreePopulation())23060			{23061				return -1;23062			}23063		}2306423065		iCost = (getGrowthThreshold(iPopulation) * GC.getADVANCED_START_POPULATION_COST()) / 100;2306623067		// Increase cost if the XML defines that additional Pop will cost more23068		if(0 != GC.getADVANCED_START_POPULATION_COST_INCREASE())23069		{23070			--iPopulation;2307123072			if(iPopulation > 0)23073			{23074				iCost *= 100 + GC.getADVANCED_START_POPULATION_COST_INCREASE() * iPopulation;23075				iCost /= 100;23076			}23077		}23078	}2307923080	return iCost;23081}

Calls

Called by