From 6cb91b8d6f269b194b65c2482062bb0d86a75f81 Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:58:30 +0000 Subject: [PATCH] Fix #11802: Don't set edge traversability bit on aqueducts crossing that same edge side Neighbouring regions on the same x_or_y may indeed have the traversability bits sets, but that doesn't necessarily mean ships can traverse their edges. --- src/pathfinder/water_regions.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/pathfinder/water_regions.cpp b/src/pathfinder/water_regions.cpp index 477e3edfd3..414a160e51 100644 --- a/src/pathfinder/water_regions.cpp +++ b/src/pathfinder/water_regions.cpp @@ -173,10 +173,25 @@ public: const int top_x = TileX(tile_area.tile); const int top_y = TileY(tile_area.tile); for (int i = 0; i < WATER_REGION_EDGE_LENGTH; ++i) { - if (GetWaterTracks(TileXY(top_x + i, top_y)) & TRACK_BIT_3WAY_NW) SetBit(this->edge_traversability_bits[DIAGDIR_NW], i); // NW edge - if (GetWaterTracks(TileXY(top_x + i, top_y + WATER_REGION_EDGE_LENGTH - 1)) & TRACK_BIT_3WAY_SE) SetBit(this->edge_traversability_bits[DIAGDIR_SE], i); // SE edge - if (GetWaterTracks(TileXY(top_x, top_y + i)) & TRACK_BIT_3WAY_NE) SetBit(this->edge_traversability_bits[DIAGDIR_NE], i); // NE edge - if (GetWaterTracks(TileXY(top_x + WATER_REGION_EDGE_LENGTH - 1, top_y + i)) & TRACK_BIT_3WAY_SW) SetBit(this->edge_traversability_bits[DIAGDIR_SW], i); // SW edge + TileIndex edge_tile = TileXY(top_x + i, top_y); // NW edge + if ((GetWaterTracks(edge_tile) & TRACK_BIT_3WAY_NW) != 0 && (!IsAqueductTile(edge_tile) || GetTunnelBridgeDirection(edge_tile) != DIAGDIR_NW)) { + SetBit(this->edge_traversability_bits[DIAGDIR_NW], i); + } + + edge_tile = TileXY(top_x + i, top_y + WATER_REGION_EDGE_LENGTH - 1); // SE edge + if ((GetWaterTracks(edge_tile) & TRACK_BIT_3WAY_SE) != 0 && (!IsAqueductTile(edge_tile) || GetTunnelBridgeDirection(edge_tile) != DIAGDIR_SE)) { + SetBit(this->edge_traversability_bits[DIAGDIR_SE], i); + } + + edge_tile = TileXY(top_x, top_y + i); // NE edge + if ((GetWaterTracks(edge_tile) & TRACK_BIT_3WAY_NE) != 0 && (!IsAqueductTile(edge_tile) || GetTunnelBridgeDirection(edge_tile) != DIAGDIR_NE)) { + SetBit(this->edge_traversability_bits[DIAGDIR_NE], i); + } + + edge_tile = TileXY(top_x + WATER_REGION_EDGE_LENGTH - 1, top_y + i); // SW edge + if ((GetWaterTracks(edge_tile) & TRACK_BIT_3WAY_SW) != 0 && (!IsAqueductTile(edge_tile) || GetTunnelBridgeDirection(edge_tile) != DIAGDIR_SW)) { + SetBit(this->edge_traversability_bits[DIAGDIR_SW], i); + } } }