CityStrategyAIHelpers::IsTestCityStrategy_NeedNavalTileImprovement(CvCity *)
- Defined in
- CvCityStrategyAI.cpp, line 2690
- Hook name
CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement
Hooks
static bool BeforeCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement(CvCity* pCity, bool& result);static void AfterCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement(CvCity* pCity, bool& result);static bool ReplaceCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement(bool (*original)(CvCity*), CvCity* pCity);CivRegisterBefore<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement>(host, &BeforeCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement);CivRegisterAfter<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement>(host, &AfterCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement);CivRegisterReplace<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement>(host, &ReplaceCityStrategyAIHelpers_IsTestCityStrategy_NeedNavalTileImprovement);
Code
2689/// "Need Naval Tile Improvement" City Strategy: If there's an unimproved Resource in the water that we could be using, HIGHLY prioritize NAVAL_TILE_IMPROVEMENT in this City: should give us a Workboat in short order2690bool CityStrategyAIHelpers::IsTestCityStrategy_NeedNavalTileImprovement(CvCity* pCity)2691{2692 int iNumUnimprovedWaterResources = 0;26932694 CvPlot* pLoopPlot;26952696 // Look at all Tiles this City could potentially work to see if there are any Water Resources that could be improved2697#if defined(MOD_GLOBAL_CITY_WORKING)2698 for(int iPlotLoop = 0; iPlotLoop < pCity->GetNumWorkablePlots(); iPlotLoop++)2699#else2700 for(int iPlotLoop = 0; iPlotLoop < NUM_CITY_PLOTS; iPlotLoop++)2701#endif2702 {2703 pLoopPlot = plotCity(pCity->getX(), pCity->getY(), iPlotLoop);27042705 if(pLoopPlot != NULL)2706 {2707 if(pLoopPlot->getOwner() == pCity->getOwner())2708 {2709 if(pLoopPlot->isWater())2710 {2711 // Only look at Tiles THIS City can use; Prevents issue where two Cities can look at the same tile the same turn and both want Workboats for it; By the time this Strategy is called for a City another City isn't guaranteed to have popped it's previous order and registered that it's now training a Workboat! :(2712 if(pCity->GetCityCitizens()->IsCanWork(pLoopPlot))2713 {2714 // Does this Tile already have a Resource, and if so, is it already improved?2715 if(pLoopPlot->getResourceType() != NO_RESOURCE && pLoopPlot->getImprovementType() == NO_IMPROVEMENT)2716 {2717 iNumUnimprovedWaterResources++;2718 }2719 }2720 }2721 }2722 }2723 }27242725 int iNumWaterTileImprovers = GET_PLAYER(pCity->getOwner()).GetNumUnitsWithUnitAI(UNITAI_WORKER_SEA, true, true);27262727 // Are there more Water Resources we can build an Improvement on than we have Naval Tile Improvers?2728 if(iNumUnimprovedWaterResources > iNumWaterTileImprovers)2729 {2730 return true;2731 }27322733 return false;2734}
Calls
- CvCity::GetCityCitizens() const
- CvCity::GetNumWorkablePlots(int) const
- CvCity::getOwner() const
- CvCity::getX() const
- CvCity::getY() const
- CvCityCitizens::IsCanWork(CvPlot *) const
- CvPlayer::GetNumUnitsWithUnitAI(UnitAITypes, bool, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getImprovementType() const
- CvPlot::getOwner() const
- CvPlot::getResourceType(TeamTypes) const
- CvPlot::isWater() const
- plotCity(int, int, int)