EconomicAIHelpers::IsTestStrategy_MostlyOnTheCoast(CvPlayer *)
- Defined in
- CvEconomicAI.cpp, line 4147
- Hook name
CivHooks::EconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast
Hooks
static bool BeforeEconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast(CvPlayer* pPlayer, bool& result);static void AfterEconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast(CvPlayer* pPlayer, bool& result);static bool ReplaceEconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast(bool (*original)(CvPlayer*), CvPlayer* pPlayer);CivRegisterBefore<CivHooks::EconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast>(host, &BeforeEconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast);CivRegisterAfter<CivHooks::EconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast>(host, &AfterEconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast);CivRegisterReplace<CivHooks::EconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast>(host, &ReplaceEconomicAIHelpers_IsTestStrategy_MostlyOnTheCoast);
Code
4146/// Are we mostly on the coast?4147bool EconomicAIHelpers::IsTestStrategy_MostlyOnTheCoast(CvPlayer* pPlayer)4148{4149 // total pop4150 int iInlandPop = 0;4151 int iCoastalPop = 0;4152 int iLoopCity = 0;4153 CvCity* pLoopCity = NULL;4154 for(pLoopCity = pPlayer->firstCity(&iLoopCity); pLoopCity != NULL; pLoopCity = pPlayer->nextCity(&iLoopCity))4155 {4156 if(pLoopCity->isCoastal(100)) // don't run this for lakes or even small inland seas4157 {4158 iCoastalPop += pLoopCity->getPopulation();4159 }4160 else4161 {4162 iInlandPop += pLoopCity->getPopulation();4163 }4164 }4165 return (iCoastalPop > 0 && iCoastalPop >= iInlandPop);4166}