CvCity::GetBuyPlotScore(int &, int &)
- Defined in
- CvCity.cpp, line 12552
- Class
- CvCity
- Hook name
CivHooks::CvCity_GetBuyPlotScore
Hooks
static bool BeforeCvCity_GetBuyPlotScore(CvCity* self, int& iBestX, int& iBestY, int& result);static void AfterCvCity_GetBuyPlotScore(CvCity* self, int& iBestX, int& iBestY, int& result);static int ReplaceCvCity_GetBuyPlotScore(int (*original)(CvCity*, int&, int&), CvCity* self, int& iBestX, int& iBestY);CivRegisterBefore<CivHooks::CvCity_GetBuyPlotScore>(host, &BeforeCvCity_GetBuyPlotScore);CivRegisterAfter<CivHooks::CvCity_GetBuyPlotScore>(host, &AfterCvCity_GetBuyPlotScore);CivRegisterReplace<CivHooks::CvCity_GetBuyPlotScore>(host, &ReplaceCvCity_GetBuyPlotScore);
Code
12551/// Compute how valuable buying a plot is to this city12552int CvCity::GetBuyPlotScore(int& iBestX, int& iBestY)12553{12554 VALIDATE_OBJECT12555 CvPlot* pLoopPlot = NULL;12556#if defined(MOD_GLOBAL_CITY_WORKING)12557 const int iMaxRange = getBuyPlotDistance();12558#else12559 const int iMaxRange = /*3*/ GC.getMAXIMUM_BUY_PLOT_DISTANCE();12560#endif1256112562 int iBestScore = -1;12563 int iTempScore;1256412565 int iDX, iDY;1256612567 for(iDX = -iMaxRange; iDX <= iMaxRange; iDX++)12568 {12569 for(iDY = -iMaxRange; iDY <= iMaxRange; iDY++)12570 {12571 pLoopPlot = plotXYWithRangeCheck(getX(), getY(), iDX, iDY, iMaxRange);12572 if(pLoopPlot != NULL)12573 {12574 // Can we actually buy this plot?12575 if(CanBuyPlot(pLoopPlot->getX(), pLoopPlot->getY()))12576 {12577 iTempScore = GetIndividualPlotScore(pLoopPlot);1257812579 if(iTempScore > iBestScore)12580 {12581 iBestScore = iTempScore;12582 iBestX = pLoopPlot->getX();12583 iBestY = pLoopPlot->getY();12584 }12585 }12586 }12587 }12588 }1258912590 return iBestScore;12591}