CvStartPositioner::ComputeTileFertilityValues()
- Defined in
- CvStartPositioner.cpp, line 330
- Class
- CvStartPositioner
- Hook name
CivHooks::CvStartPositioner_ComputeTileFertilityValues
Hooks
static bool BeforeCvStartPositioner_ComputeTileFertilityValues(CvStartPositioner* self);static void AfterCvStartPositioner_ComputeTileFertilityValues(CvStartPositioner* self);static void ReplaceCvStartPositioner_ComputeTileFertilityValues(void (*original)(CvStartPositioner*), CvStartPositioner* self);CivRegisterBefore<CivHooks::CvStartPositioner_ComputeTileFertilityValues>(host, &BeforeCvStartPositioner_ComputeTileFertilityValues);CivRegisterAfter<CivHooks::CvStartPositioner_ComputeTileFertilityValues>(host, &AfterCvStartPositioner_ComputeTileFertilityValues);CivRegisterReplace<CivHooks::CvStartPositioner_ComputeTileFertilityValues>(host, &ReplaceCvStartPositioner_ComputeTileFertilityValues);
Code
329/// Compute the fertility of each tile on the map330void CvStartPositioner::ComputeTileFertilityValues()331{332 CvArea* pLoopArea(NULL);333 int iLoop;334 CvPlot* pLoopPlot(NULL);335 int iI;336 int uiFertility;337338 // Set all area fertilities to 0339 for(pLoopArea = GC.getMap().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMap().nextArea(&iLoop))340 {341 pLoopArea->setTotalFoundValue(0);342 }343344 // Now process through the map345 for(iI = 0; iI < GC.getMap().numPlots(); iI++)346 {347 pLoopPlot = GC.getMap().plotByIndexUnchecked(iI);348 CvAssert(pLoopPlot);349 if(!pLoopPlot) continue;350351 // Compute fertility and save off in player 0's found value slot352 // (Normally shouldn't be using a hard-coded player reference, but here in the pre-game initialization it is safe to do so.353 // Allows us to reuse this data storage instead of jamming even more data into the CvPlot class that will never be used at run-time).354 uiFertility = m_pSiteEvaluator->PlotFertilityValue(pLoopPlot);355 pLoopPlot->setFoundValue((PlayerTypes)0, uiFertility);356357 if(uiFertility > 0)358 {359 // Add to total for area360 CvArea* pArea = GC.getMap().getArea(pLoopPlot->getArea());361 CvAssert(pArea);362 if(!pArea) continue;363 pArea->setTotalFoundValue(pArea->getTotalFoundValue() + uiFertility);364 }365 }366}
Calls
- CvArea::getTotalFoundValue() const
- CvArea::setTotalFoundValue(int)
- CvCitySiteEvaluator::PlotFertilityValue(CvPlot *)
- CvGlobals::getMap()
- CvMap::firstArea(int *, bool)
- CvMap::getArea(int)
- CvMap::nextArea(int *, bool)
- CvMap::numPlots() const
- CvMap::plotByIndexUnchecked(int) const
- CvPlot::getArea() const
- CvPlot::setFoundValue(PlayerTypes, int)