Skip to content

Commit

Permalink
Fix bug Return-To-The-Roots#968 - Roads are no longer allowed to be i…
Browse files Browse the repository at this point in the history
…n no-mans land or in border
  • Loading branch information
Xellzul committed Apr 2, 2024
1 parent fd16215 commit a21b83b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions libs/s25main/world/GameWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,21 @@ void GameWorld::RecalcTerritory(const noBaseBuilding& building, TerritoryChangeR
// Destroy remaining roads going through non-owned territory
for(const MapPoint& curMapPt : ptsWithChangedOwners)
{
// Skip if there is an object. We are looking only for roads going through, not ending here
// (objects here are already destroyed and if the road ended there it would have been as well)
if(GetNode(curMapPt).obj)
continue;
Direction dir;
noFlag* flag = GetRoadFlag(curMapPt, dir);
if(!flag || flag->GetPlayer() + 1 == GetNode(curMapPt).owner)
continue;
flag->DestroyRoad(dir);
// Destroy everything around this point as this is at best a border node where nothing should be around
// TODO: What about this point?
for(const MapPoint neighbourPt : GetNeighbours(curMapPt))
{
const auto& test = GetNode(neighbourPt);
// Skip if there is an object. We are looking only for roads going through, not ending here
// (objects here are already destroyed and if the road ended there it would have been as well)
if(GetNode(neighbourPt).obj)
continue;
Direction dir;
noFlag* flag = GetRoadFlag(neighbourPt, dir);
if(!flag || (flag->GetPlayer() + 1 == GetNode(neighbourPt).owner && !IsBorderNode(neighbourPt, GetNode(neighbourPt).owner)))
continue;
flag->DestroyRoad(dir);
}
}

// Notify
Expand Down

0 comments on commit a21b83b

Please sign in to comment.