Code
12751/// What is the cheapest plot we can get12752void CvCity::DoUpdateCheapestPlotInfluence()12753{12754 int iLowestCost = INT_MAX;1275512756 CvPlot* pLoopPlot = NULL;12757 CvPlot* pThisPlot = plot();12758 const int iMaxRange = /*5*/ GC.getMAXIMUM_ACQUIRE_PLOT_DISTANCE();12759 CvMap& thisMap = GC.getMap();1276012761 int iDX, iDY;1276212763 for(iDX = -iMaxRange; iDX <= iMaxRange; iDX++)12764 {12765 for(iDY = -iMaxRange; iDY <= iMaxRange; iDY++)12766 {12767 pLoopPlot = plotXYWithRangeCheck(getX(), getY(), iDX, iDY, iMaxRange);12768 if(pLoopPlot != NULL)12769 {12770#if defined(MOD_BUGFIX_MINOR)12771 // If the plot's owned by anyone, we can't acquire it, so it doesn't matter12772#else12773 // If the plot's not owned by us, it doesn't matter12774#endif12775 if(pLoopPlot->getOwner() != NO_PLAYER)12776 continue;12777 12778#if defined(MOD_EVENTS_CITY_BORDERS)12779 // If we can't acquire it, it also doesn't matter12780 if (MOD_EVENTS_CITY_BORDERS) {12781 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_CityCanAcquirePlot, getOwner(), GetID(), pLoopPlot->getX(), pLoopPlot->getY()) == GAMEEVENTRETURN_FALSE) {12782 continue;12783 }12784 }12785#endif 1278612787 // we can use the faster, but slightly inaccurate pathfinder here - after all we are using a rand in the equation12788 int iInfluenceCost = thisMap.calculateInfluenceDistance(pThisPlot, pLoopPlot, iMaxRange, false);1278912790 if(iInfluenceCost > 0)12791 {12792 // Are we the cheapest yet?12793 if(iInfluenceCost < iLowestCost)12794 iLowestCost = iInfluenceCost;12795 }12796 }12797 }12798 }1279912800 SetCheapestPlotInfluence(iLowestCost);12801}