EconomicAIHelpers::IsTestStrategy_ReallyNeedReconSea(CvPlayer *)
- Defined in
- CvEconomicAI.cpp, line 3089
- Hook name
CivHooks::EconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea
Hooks
static bool BeforeEconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea(CvPlayer* pPlayer, bool& result);static void AfterEconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea(CvPlayer* pPlayer, bool& result);static bool ReplaceEconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea(bool (*original)(CvPlayer*), CvPlayer* pPlayer);CivRegisterBefore<CivHooks::EconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea>(host, &BeforeEconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea);CivRegisterAfter<CivHooks::EconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea>(host, &AfterEconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea);CivRegisterReplace<CivHooks::EconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea>(host, &ReplaceEconomicAIHelpers_IsTestStrategy_ReallyNeedReconSea);
Code
3088/// "Really Need Recon Sea" Player Strategy: If we could theoretically start exploring other continents but we don't have any appropriate ship...3089bool EconomicAIHelpers::IsTestStrategy_ReallyNeedReconSea(CvPlayer* pPlayer)3090{3091 if(pPlayer->GetEconomicAI()->GetNavalReconState() == RECON_STATE_NEEDED)3092 {3093 if(GET_TEAM(pPlayer->getTeam()).canEmbarkAllWaterPassage()) // get a caravel out there NOW!3094 {3095 CvUnit* pLoopUnit;3096 CvCity* pLoopCity;3097 int iLoop;30983099 // Current Units3100 for(pLoopUnit = pPlayer->firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = pPlayer->nextUnit(&iLoop))3101 {3102 if(pLoopUnit->AI_getUnitAIType() == UNITAI_EXPLORE_SEA && !pLoopUnit->isTerrainImpassable(TERRAIN_OCEAN))3103 {3104 return false;3105 }3106 }31073108 // Figure out which Promotion is the one which makes a unit not cross oceans3109 PromotionTypes eOceanImpassablePromotion = NO_PROMOTION;3110 for(int iI = 0; iI < GC.getNumPromotionInfos(); iI++)3111 {3112 const PromotionTypes eLoopPromotion = static_cast<PromotionTypes>(iI);3113 CvPromotionEntry* pkPromotionInfo = GC.getPromotionInfo(eLoopPromotion);3114 if(pkPromotionInfo)3115 {3116 if(pkPromotionInfo->GetTerrainImpassable(TERRAIN_OCEAN) && pkPromotionInfo->GetTerrainPassableTech(TERRAIN_OCEAN) == -1)3117 {3118 eOceanImpassablePromotion = eLoopPromotion;3119 break;3120 }3121 }3122 }31233124 // Units being trained now3125 for(pLoopCity = pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = pPlayer->nextCity(&iLoop))3126 {3127 if(pLoopCity->isProductionUnit())3128 {3129 CvUnitEntry* pkUnitEntry = GC.getUnitInfo(pLoopCity->getProductionUnit());3130 if(pkUnitEntry)3131 {3132 if(pkUnitEntry->GetDomainType() == DOMAIN_SEA && pkUnitEntry->GetDefaultUnitAIType() == UNITAI_EXPLORE_SEA)3133 {3134 if(!pkUnitEntry->GetFreePromotions(eOceanImpassablePromotion))3135 {3136 return false;3137 }3138 }3139 }3140 }3141 }3142 return true;3143 }3144 else if(GET_TEAM(pPlayer->getTeam()).canEmbark()) // get a trireme out there NOW!3145 {3146 CvUnit* pLoopUnit;3147 CvCity* pLoopCity;3148 int iLoop;31493150 // Current Units3151 for(pLoopUnit = pPlayer->firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = pPlayer->nextUnit(&iLoop))3152 {3153 if(pLoopUnit->AI_getUnitAIType() == UNITAI_EXPLORE_SEA)3154 {3155 return false;3156 }3157 }31583159 // Units being trained now3160 for(pLoopCity = pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = pPlayer->nextCity(&iLoop))3161 {3162 if(pLoopCity->isProductionUnit())3163 {3164 CvUnitEntry* pkUnitEntry = GC.getUnitInfo(pLoopCity->getProductionUnit());3165 if(pkUnitEntry)3166 {3167 if(pkUnitEntry->GetDomainType() == DOMAIN_SEA && pkUnitEntry->GetDefaultUnitAIType() == UNITAI_EXPLORE_SEA)3168 {3169 return false;3170 }3171 }3172 }3173 }3174 return true;3175 }3176 }31773178 return false;3179}
Calls
- CvCity::getProductionUnit() const
- CvCity::isProductionUnit() const
- CvEconomicAI::GetNavalReconState() const
- CvGlobals::getNumPromotionInfos()
- CvGlobals::getPromotionInfo(PromotionTypes)
- CvGlobals::getUnitInfo(UnitTypes)
- CvPlayer::firstCity(int *, bool)
- CvPlayer::firstUnit(int *, bool)
- CvPlayer::GetEconomicAI() const
- CvPlayer::getTeam() const
- CvPlayer::nextCity(int *, bool)
- CvPlayer::nextUnit(int *, bool)
- CvPromotionEntry::GetTerrainImpassable(int) const
- CvPromotionEntry::GetTerrainPassableTech(int) const
- CvTeam::canEmbark() const
- CvTeam::canEmbarkAllWaterPassage() const
- CvTeam::getTeam(TeamTypes)
- CvUnit::AI_getUnitAIType() const
- CvUnit::isTerrainImpassable(TerrainTypes) const
- CvUnitEntry::GetDefaultUnitAIType() const
- CvUnitEntry::GetDomainType() const
- CvUnitEntry::GetFreePromotions(int) const