From e3bfe2b668ed470e599d2a8a9bfb4763103f027e Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 22 Oct 2024 00:33:29 +0100 Subject: [PATCH] Fix: Don't invalidate water regions on the other side of the map. (#13012) When invalidating water regions with a tile at the very edge of the map, the region on the opposite side of the map would also be invalidated. --- src/pathfinder/water_regions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pathfinder/water_regions.cpp b/src/pathfinder/water_regions.cpp index 6ef8d2c998..9cfb9c7729 100644 --- a/src/pathfinder/water_regions.cpp +++ b/src/pathfinder/water_regions.cpp @@ -324,7 +324,8 @@ void InvalidateWaterRegion(TileIndex tile) * traversability. This means that if we invalidate any region edge tiles we might also change the traversability * of the adjacent region. This code ensures the adjacent regions also get invalidated in such a case. */ for (DiagDirection side = DIAGDIR_BEGIN; side < DIAGDIR_END; side++) { - const TileIndex adjacent_tile = TileAddByDiagDir(tile, side); + const TileIndex adjacent_tile = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(side)); + if (adjacent_tile == INVALID_TILE) continue; if (GetWaterRegionIndex(adjacent_tile) != GetWaterRegionIndex(tile)) invalidate_region(adjacent_tile); } }