CvCitySpecializationAI::FindBestWonderCity() const
- Defined in
- CvCitySpecializationAI.cpp, line 1104
- Class
- CvCitySpecializationAI
- Hook name
CivHooks::CvCitySpecializationAI_FindBestWonderCity
Hooks
static bool BeforeCvCitySpecializationAI_FindBestWonderCity(const CvCitySpecializationAI* self, CvCity*& result);static void AfterCvCitySpecializationAI_FindBestWonderCity(const CvCitySpecializationAI* self, CvCity*& result);static CvCity* ReplaceCvCitySpecializationAI_FindBestWonderCity(CvCity* (*original)(const CvCitySpecializationAI*), const CvCitySpecializationAI* self);CivRegisterBefore<CivHooks::CvCitySpecializationAI_FindBestWonderCity>(host, &BeforeCvCitySpecializationAI_FindBestWonderCity);CivRegisterAfter<CivHooks::CvCitySpecializationAI_FindBestWonderCity>(host, &AfterCvCitySpecializationAI_FindBestWonderCity);CivRegisterReplace<CivHooks::CvCitySpecializationAI_FindBestWonderCity>(host, &ReplaceCvCitySpecializationAI_FindBestWonderCity);
Code
1103/// Choose a city to build the next wonder1104CvCity* CvCitySpecializationAI::FindBestWonderCity() const1105{1106 CvCity* pBestCity = NULL;1107 CvCity* pLoopCity;1108 int iLoop;1109 int iBestProduction = 0;1110 int iProduction;11111112 // First, see if we already have a wonder underway somewhere. If so that's our wonder city1113 pLoopCity = NULL;//GetWonderBuildCity();11141115 CvBuildingEntry* pkProductionBuildingInfo = NULL;1116 if(pLoopCity != NULL && pLoopCity->getProductionBuilding() != NO_BUILDING)1117 {1118 pkProductionBuildingInfo = GC.getBuildingInfo(pLoopCity->getProductionBuilding());1119 }11201121 if(pkProductionBuildingInfo && m_pPlayer->GetWonderProductionAI()->IsWonder(*pkProductionBuildingInfo))1122 {1123 if(!pLoopCity->IsPuppet())1124 {1125 return pLoopCity;1126 }1127 }1128 else if(m_eNextWonderDesired != NO_BUILDING)1129 {1130 for(pLoopCity = m_pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoop))1131 {1132 if(!pLoopCity->IsPuppet())1133 {1134 if(pLoopCity->canConstruct(m_eNextWonderDesired))1135 {1136 iProduction = pLoopCity->getCurrentProductionDifference(true, false);1137 if(pLoopCity->GetCityStrategyAI()->GetDefaultSpecialization() == GetWonderSpecialization())1138 {1139 iProduction = (iProduction * 3) / 2;1140 }11411142 // factor in Marble, etc.1143 iProduction = (iProduction * (100 + pLoopCity->GetWonderProductionModifier())) / 100;11441145 if(iProduction > iBestProduction)1146 {1147 pBestCity = pLoopCity;1148 iBestProduction = iProduction;1149 }1150 }1151 }1152 }1153 }11541155 return pBestCity;1156}
Calls
- CvCity::canConstruct(BuildingTypes, bool, bool, bool, bool, CvString *) const
- CvCity::GetCityStrategyAI() const
- CvCity::getCurrentProductionDifference(bool, bool) const
- CvCity::getProductionBuilding() const
- CvCity::GetWonderProductionModifier() const
- CvCity::IsPuppet() const
- CvCitySpecializationAI::GetWonderSpecialization() const
- CvCityStrategyAI::GetDefaultSpecialization() const
- CvGlobals::getBuildingInfo(BuildingTypes)
- CvPlayer::firstCity(int *, bool)
- CvPlayer::GetWonderProductionAI() const
- CvPlayer::nextCity(int *, bool)
- CvWonderProductionAI::IsWonder(const CvBuildingEntry &) const