GetReachablePlot(UnitHandle, WeightedPlotVector &, int)
- Defined in
- CvTacticalAI.cpp, line 6813
- Hook name
CivHooks::CvTacticalAI_cpp_GetReachablePlot
Hooks
static bool BeforeCvTacticalAI_cpp_GetReachablePlot(FObjectHandle<CvUnit> pUnit, CvWeightedVector<CvPlot *, 1, true> & aPlots, int iTurns, CvPlot *& result);static void AfterCvTacticalAI_cpp_GetReachablePlot(FObjectHandle<CvUnit> pUnit, CvWeightedVector<CvPlot *, 1, true> & aPlots, int iTurns, CvPlot *& result);static CvPlot * ReplaceCvTacticalAI_cpp_GetReachablePlot(CvPlot * (*original)(FObjectHandle<CvUnit>, CvWeightedVector<CvPlot *, 1, true> &, int), FObjectHandle<CvUnit> pUnit, CvWeightedVector<CvPlot *, 1, true> & aPlots, int iTurns);CivRegisterBefore<CivHooks::CvTacticalAI_cpp_GetReachablePlot>(host, &BeforeCvTacticalAI_cpp_GetReachablePlot);CivRegisterAfter<CivHooks::CvTacticalAI_cpp_GetReachablePlot>(host, &AfterCvTacticalAI_cpp_GetReachablePlot);CivRegisterReplace<CivHooks::CvTacticalAI_cpp_GetReachablePlot>(host, &ReplaceCvTacticalAI_cpp_GetReachablePlot);
Code
6811// Return the first reachable plot in the weighted plot list.6812// It is assumed that the list has yet to be sorted and will do so.6813static CvPlot* GetReachablePlot(UnitHandle pUnit, WeightedPlotVector& aPlots, int iTurns)6814{6815 uint uiListSize;6816 if ((uiListSize = aPlots.size()) > 0)6817 {6818 aPlots.SortItems();6819 for (uint i = uiListSize; i--; ) // Go backward, the CvWeightedVector sorts highest to lowest and we want the least dangerous location6820 {6821 CvPlot* pPlot = aPlots.GetElement(i);6822 if(CanReachInXTurns(pUnit, pPlot, iTurns))6823 {6824 return pPlot;6825 }6826 }6827 }6828 return NULL;6829}
Calls
- CanReachInXTurns(UnitHandle, CvPlot *, int, bool, int *)
CvWeightedVector::GetElementCvWeightedVector::sizeCvWeightedVector::SortItemsFObjectHandle::FObjectHandle