CvPlayer::GetClosestGoodyPlot(bool)
- Defined in
- CvPlayer.cpp, line 27329
- Class
- CvPlayer
- Hook name
CivHooks::CvPlayer_GetClosestGoodyPlot
Hooks
static bool BeforeCvPlayer_GetClosestGoodyPlot(CvPlayer* self, bool bStopAfterFindingFirst, CvPlot*& result);static void AfterCvPlayer_GetClosestGoodyPlot(CvPlayer* self, bool bStopAfterFindingFirst, CvPlot*& result);static CvPlot* ReplaceCvPlayer_GetClosestGoodyPlot(CvPlot* (*original)(CvPlayer*, bool), CvPlayer* self, bool bStopAfterFindingFirst);CivRegisterBefore<CivHooks::CvPlayer_GetClosestGoodyPlot>(host, &BeforeCvPlayer_GetClosestGoodyPlot);CivRegisterAfter<CivHooks::CvPlayer_GetClosestGoodyPlot>(host, &AfterCvPlayer_GetClosestGoodyPlot);CivRegisterReplace<CivHooks::CvPlayer_GetClosestGoodyPlot>(host, &ReplaceCvPlayer_GetClosestGoodyPlot);
Code
27329CvPlot* CvPlayer::GetClosestGoodyPlot(bool bStopAfterFindingFirst)27330{27331 FFastVector<int> aiGoodyPlots = GetEconomicAI()->GetGoodyHutPlots();2733227333 CvPlot* pResultPlot = NULL;27334 int iShortestPath = INT_MAX;2733527336 // cycle through goodies27337 for(uint uiGoodyIndex = 0; uiGoodyIndex < aiGoodyPlots.size(); uiGoodyIndex++)27338 {27339 CvPlot* pPlot = GC.getMap().plotByIndex(aiGoodyPlots[uiGoodyIndex]);27340 if(!pPlot || !pPlot->isGoody(getTeam()))27341 {27342 continue;27343 }2734427345 // cycle through units27346 int iUnitLoop;27347 CvUnit* pLoopUnit = NULL;2734827349 // Setup m_units27350 for(pLoopUnit = firstUnit(&iUnitLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iUnitLoop))27351 {27352 if(!pLoopUnit)27353 {27354 continue;27355 }2735627357 if(pPlot->getArea() != pLoopUnit->getArea() && !pLoopUnit->CanEverEmbark())27358 {27359 continue;27360 }2736127362 int iReturnValue = INT_MAX;27363 bool bResult = pLoopUnit->GeneratePath(pPlot, MOVE_UNITS_IGNORE_DANGER, true, &iReturnValue);2736427365 if(bResult)27366 {27367 if(iReturnValue < iShortestPath)27368 {27369 pResultPlot = pPlot;27370 }2737127372 if(bStopAfterFindingFirst)27373 {27374 return pPlot;27375 }27376 }27377 }27378 }2737927380 return pResultPlot;27381}
Calls
BaseVector::operator[]BaseVector::size- CvEconomicAI::GetGoodyHutPlots()
- CvGlobals::getMap()
- CvMap::plotByIndex(int) const
- CvPlayer::firstUnit(int *, bool)
- CvPlayer::GetEconomicAI() const
- CvPlayer::getTeam() const
- CvPlayer::nextUnit(int *, bool)
- CvPlot::getArea() const
- CvPlot::isGoody(TeamTypes) const
- CvUnit::CanEverEmbark() const
- CvUnit::GeneratePath(const CvPlot *, int, bool, int *) const
- CvUnit::getArea() const
FFastVector::FFastVector