CvPlayer::GetGreatPersonSpawnCity(UnitTypes)
- Defined in
- CvPlayer.cpp, line 15017
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetGreatPersonSpawnCity
Hooks
static bool BeforeCvPlayer_GetGreatPersonSpawnCity(CvPlayer* self, UnitTypes eUnit, CvCity*& result);static void AfterCvPlayer_GetGreatPersonSpawnCity(CvPlayer* self, UnitTypes eUnit, CvCity*& result);static CvCity* ReplaceCvPlayer_GetGreatPersonSpawnCity(CvCity* (*original)(CvPlayer*, UnitTypes), CvPlayer* self, UnitTypes eUnit);CivRegisterBefore<CivHooks::CvPlayer_GetGreatPersonSpawnCity>(host, &BeforeCvPlayer_GetGreatPersonSpawnCity);CivRegisterAfter<CivHooks::CvPlayer_GetGreatPersonSpawnCity>(host, &AfterCvPlayer_GetGreatPersonSpawnCity);CivRegisterReplace<CivHooks::CvPlayer_GetGreatPersonSpawnCity>(host, &ReplaceCvPlayer_GetGreatPersonSpawnCity);
Code
15017CvCity* CvPlayer::GetGreatPersonSpawnCity(UnitTypes eUnit)15018{15019 CvCity* pBestCity = getCapitalCity();15020 CvUnitEntry* pkUnitEntry = GC.getUnitInfo(eUnit);1502115022 if(pkUnitEntry && pkUnitEntry->GetDomainType() == DOMAIN_SEA)15023 {15024 int iBestValue = INT_MAX;15025 int iLoop;15026 for(CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))15027 {15028 if(!pLoopCity->isCoastal())15029 {15030 continue;15031 }1503215033 int iValue = 4 * GC.getGame().getJonRandNum(getNumCities(), "Great Admiral City Selection");1503415035 for(int i = 0; i < NUM_YIELD_TYPES; i++)15036 {15037 iValue += pLoopCity->findYieldRateRank((YieldTypes)i);15038 }15039 iValue += pLoopCity->findPopulationRank();1504015041 if(iValue < iBestValue)15042 {15043 pBestCity = pLoopCity;15044 iBestValue = iValue;15045 }15046 }15047 }1504815049 return pBestCity;15050}
Calls
- CvCity::findPopulationRank()
- CvCity::findYieldRateRank(YieldTypes)
- CvCity::isCoastal(int) const
- CvGame::getJonRandNum(int, const char *)
- CvGlobals::getGame()
- CvGlobals::getUnitInfo(UnitTypes)
- CvPlayer::firstCity(int *, bool)
- CvPlayer::getCapitalCity()
- CvPlayer::getNumCities() const
- CvPlayer::nextCity(int *, bool)
- CvUnitEntry::GetDomainType() const