Skip to content

Commit

Permalink
4.18.2 fixes (#11528)
Browse files Browse the repository at this point in the history
* fix #11524
removed a wrong assert

* fix #11526
added an assert in case i missed something
  • Loading branch information
azum4roll authored Jan 14, 2025
1 parent a5f2629 commit 661bb3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 7 additions & 6 deletions CvGameCoreDLL_Expansion2/CvCity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27341,7 +27341,7 @@ void CvCity::GetBuyablePlotList(std::vector<int>& aiPlotList, bool bForPurchase,

int iYieldLoop = 0;

// we have to use a larger value than iMaxRange because straight lines may be blocked by mountains etc.
// We have to use a larger value than iMaxRange because straight lines may be blocked by mountains etc.
SPathFinderUserData data(getOwner(), PT_CITY_INFLUENCE, 2 * iMaxRange);

int iWorkPlotDistance = getWorkPlotDistance();
Expand Down Expand Up @@ -27653,8 +27653,8 @@ int CvCity::calculateInfluenceDistance(CvPlot* pDest, int iMaxRange) const
if (pDest == NULL)
return -1;

// we have to use iMaxRange + 1 to find plots that are at up to iMaxRange tiles away because for influence pathfinding iStartMoves = 0 is used
SPathFinderUserData data(getOwner(), PT_CITY_INFLUENCE, iMaxRange + 1);
// We have to use a larger value than iMaxRange because straight lines may be blocked by mountains etc.
SPathFinderUserData data(getOwner(), PT_CITY_INFLUENCE, 2 * iMaxRange);
SPath path = GC.GetStepFinder().GetPath(getX(), getY(), pDest->getX(), pDest->getY(), data);
if (!path)
return -1; // no passable path exists
Expand Down Expand Up @@ -28326,12 +28326,13 @@ void CvCity::DoUpdateCheapestPlotInfluenceDistance()
vector<int> plots;
GetBuyablePlotList(plots, false);

int iInfluenceDistance = INT_MAX;
if (!plots.empty())
{
SetCheapestPlotInfluenceDistance(calculateInfluenceDistance(GC.getMap().plotByIndex(plots.front()), /*5*/ range(GD_INT_GET(MAXIMUM_ACQUIRE_PLOT_DISTANCE), 1, MAX_CITY_RADIUS)));
iInfluenceDistance = calculateInfluenceDistance(GC.getMap().plotByIndex(plots.front()), /*5*/ range(GD_INT_GET(MAXIMUM_ACQUIRE_PLOT_DISTANCE), 1, MAX_CITY_RADIUS));
ASSERT(iInfluenceDistance != -1, "Plots returned from GetBuyablePlotList() should always be reachable");
}
else
SetCheapestPlotInfluenceDistance(INT_MAX);
SetCheapestPlotInfluenceDistance(iInfluenceDistance);
}

void CvCity::UpdateYieldsFromExistingFriendsAndAllies(bool bRemove)
Expand Down
1 change: 0 additions & 1 deletion CvGameCoreDLL_Expansion2/CvUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19006,7 +19006,6 @@ int CvUnit::GetNumFriendlyUnitsAdjacent(const CvUnit* pUnitToExclude) const
/// Is a particular enemy city next to us?
bool CvUnit::IsEnemyCityAdjacent(const CvCity* pSpecifyCity) const
{
ASSERT(pSpecifyCity, "City is NULL when checking if it is adjacent to a unit");
if (plot() != NULL)
{
return plot()->IsEnemyCityAdjacent(getTeam(), pSpecifyCity);
Expand Down

0 comments on commit 661bb3a

Please sign in to comment.