CvPlayer::GetMaxEffectiveCities(bool)
- Defined in
- CvPlayer.cpp, line 26795
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetMaxEffectiveCities
Hooks
static bool BeforeCvPlayer_GetMaxEffectiveCities(CvPlayer* self, bool bIncludePuppets, int& result);static void AfterCvPlayer_GetMaxEffectiveCities(CvPlayer* self, bool bIncludePuppets, int& result);static int ReplaceCvPlayer_GetMaxEffectiveCities(int (*original)(CvPlayer*, bool), CvPlayer* self, bool bIncludePuppets);CivRegisterBefore<CivHooks::CvPlayer_GetMaxEffectiveCities>(host, &BeforeCvPlayer_GetMaxEffectiveCities);CivRegisterAfter<CivHooks::CvPlayer_GetMaxEffectiveCities>(host, &AfterCvPlayer_GetMaxEffectiveCities);CivRegisterReplace<CivHooks::CvPlayer_GetMaxEffectiveCities>(host, &ReplaceCvPlayer_GetMaxEffectiveCities);
Code
26794// How many Cities does this player have for policy/tech cost purposes?26795int CvPlayer::GetMaxEffectiveCities(bool bIncludePuppets)26796{26797 int iNumCities = getNumCities();2679826799 // Don't count puppet Cities26800 int iNumPuppetCities = GetNumPuppetCities();26801 iNumCities -= iNumPuppetCities;2680226803 // Don't count cities where the player hasn't decided yet what to do with them or ones that are currently being razed26804 int iNumLimboCities = 0;26805 const CvCity* pLoopCity;26806 int iLoop;26807 for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))26808 {26809 if(pLoopCity->IsIgnoreCityForHappiness() || pLoopCity->IsRazing())26810 {26811 iNumLimboCities++;26812 }26813 }26814 iNumCities -= iNumLimboCities;2681526816 if(iNumCities == 0) // If we don't pretend the player has at least one city it screws up the math26817 iNumCities = 1;2681826819 // Update member variable26820 m_iMaxEffectiveCities = (m_iMaxEffectiveCities > iNumCities) ? m_iMaxEffectiveCities : iNumCities;2682126822 if (bIncludePuppets)26823 {26824 return m_iMaxEffectiveCities + iNumPuppetCities;26825 }2682626827 return m_iMaxEffectiveCities;26828}