CityStrategyAIHelpers::IsTestCityStrategy_ForestCity(CvCity *)
- Defined in
- CvCityStrategyAI.cpp, line 3063
- Hook name
CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_ForestCity
Hooks
static bool BeforeCityStrategyAIHelpers_IsTestCityStrategy_ForestCity(CvCity* pCity, bool& result);static void AfterCityStrategyAIHelpers_IsTestCityStrategy_ForestCity(CvCity* pCity, bool& result);static bool ReplaceCityStrategyAIHelpers_IsTestCityStrategy_ForestCity(bool (*original)(CvCity*), CvCity* pCity);CivRegisterBefore<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_ForestCity>(host, &BeforeCityStrategyAIHelpers_IsTestCityStrategy_ForestCity);CivRegisterAfter<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_ForestCity>(host, &AfterCityStrategyAIHelpers_IsTestCityStrategy_ForestCity);CivRegisterReplace<CivHooks::CityStrategyAIHelpers_IsTestCityStrategy_ForestCity>(host, &ReplaceCityStrategyAIHelpers_IsTestCityStrategy_ForestCity);
Code
3062/// "Forest City" City Strategy: give a little flavor to this city3063bool CityStrategyAIHelpers::IsTestCityStrategy_ForestCity(CvCity* pCity)3064{3065 // scan the nearby tiles to see if there are at least two forests in the vicinity3066 const int iRange = 2;3067 int iNumForests = 0;3068 CvPlot* pPlot = pCity->plot();30693070 for(int iDX = -iRange; iDX <= iRange; iDX++)3071 {3072 for(int iDY = -iRange; iDY <= iRange; iDY++)3073 {3074 CvPlot* pLoopPlot = plotXYWithRangeCheck(pPlot->getX(), pPlot->getY(), iDX, iDY, iRange);3075 if(pLoopPlot)3076 {3077 // FEATURE_FOREST seems dubious to me...3078 if(pLoopPlot->getFeatureType() == FEATURE_FOREST && pLoopPlot->getOwner() == pPlot->getOwner())3079 {3080 iNumForests++;3081 if(iNumForests > 1)3082 {3083 return true;3084 }3085 }3086 }3087 }3088 }30893090 return false;3091}