Bazaar developer reference

CvCity::findPopulationRank()

Defined in
CvCity.cpp, line 2409
Class
CvCity
Hook name
CivHooks::CvCity_findPopulationRank

Hooks

static bool BeforeCvCity_findPopulationRank(CvCity* self, int& result);static void AfterCvCity_findPopulationRank(CvCity* self, int& result);static int ReplaceCvCity_findPopulationRank(int (*original)(CvCity*), CvCity* self);CivRegisterBefore<CivHooks::CvCity_findPopulationRank>(host, &BeforeCvCity_findPopulationRank);CivRegisterAfter<CivHooks::CvCity_findPopulationRank>(host, &AfterCvCity_findPopulationRank);CivRegisterReplace<CivHooks::CvCity_findPopulationRank>(host, &ReplaceCvCity_findPopulationRank);

Code

2409int CvCity::findPopulationRank()2410{2411	VALIDATE_OBJECT2412	if(!m_bPopulationRankValid)2413	{2414		int iRank = 1;24152416		int iLoop;2417		CvCity* pLoopCity;2418		for(pLoopCity = GET_PLAYER(getOwner()).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(getOwner()).nextCity(&iLoop))2419		{2420			if((pLoopCity->getPopulation() > getPopulation()) ||2421			        ((pLoopCity->getPopulation() == getPopulation()) && (pLoopCity->GetID() < GetID())))2422			{2423				iRank++;2424			}2425		}24262427		// shenanigans are to get around the const check2428		m_bPopulationRankValid = true;2429		m_iPopulationRank = iRank;2430	}24312432	return m_iPopulationRank;2433}

Calls

Called by