Bazaar developer reference

CvGame::getAdjustedPopulationPercent(VictoryTypes) const

Defined in
CvGame.cpp, line 3719
Class
CvGame
Hook name
CivHooks::CvGame_getAdjustedPopulationPercent

Hooks

static bool BeforeCvGame_getAdjustedPopulationPercent(const CvGame* self, VictoryTypes eVictory, int& result);static void AfterCvGame_getAdjustedPopulationPercent(const CvGame* self, VictoryTypes eVictory, int& result);static int ReplaceCvGame_getAdjustedPopulationPercent(int (*original)(const CvGame*, VictoryTypes), const CvGame* self, VictoryTypes eVictory);CivRegisterBefore<CivHooks::CvGame_getAdjustedPopulationPercent>(host, &BeforeCvGame_getAdjustedPopulationPercent);CivRegisterAfter<CivHooks::CvGame_getAdjustedPopulationPercent>(host, &AfterCvGame_getAdjustedPopulationPercent);CivRegisterReplace<CivHooks::CvGame_getAdjustedPopulationPercent>(host, &ReplaceCvGame_getAdjustedPopulationPercent);

Code

3719int CvGame::getAdjustedPopulationPercent(VictoryTypes eVictory) const3720{3721	int iPopulation;3722	int iBestPopulation;3723	int iNextBestPopulation;3724	int iI;37253726	CvVictoryInfo* pkVictoryInfo = GC.getVictoryInfo(eVictory);3727	if(pkVictoryInfo == NULL)3728	{3729		return 0;3730	}37313732	if(pkVictoryInfo->getPopulationPercentLead() == 0)3733	{3734		return 0;3735	}37363737	if(getTotalPopulation() == 0)3738	{3739		return 100;3740	}37413742	iBestPopulation = 0;3743	iNextBestPopulation = 0;37443745	for(iI = 0; iI < MAX_CIV_TEAMS; iI++)3746	{3747		if(GET_TEAM((TeamTypes)iI).isAlive())3748		{3749			iPopulation = GET_TEAM((TeamTypes)iI).getTotalPopulation();37503751			if(iPopulation > iBestPopulation)3752			{3753				iNextBestPopulation = iBestPopulation;3754				iBestPopulation = iPopulation;3755			}3756			else if(iPopulation > iNextBestPopulation)3757			{3758				iNextBestPopulation = iPopulation;3759			}3760		}3761	}37623763	return std::min(100, (((iNextBestPopulation * 100) / getTotalPopulation()) + pkVictoryInfo->getPopulationPercentLead()));3764}

Calls

Called by