summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTyler Trahan <tyler@tylertrahan.com>2021-01-31 04:04:22 -0500
committerGitHub <noreply@github.com>2021-01-31 10:04:22 +0100
commit1dda7d6486decf558d2ef848af3c22ee945801e6 (patch)
tree91928df69f0e76e309bebb96f8d008e9aac7851a /src
parent0e54c32452767edb46dc442ae1b88468494c6662 (diff)
downloadopenttd-1dda7d6486decf558d2ef848af3c22ee945801e6.tar.xz
Fix: don't walk out of the map when trying to build tunnels (#8600)
Diffstat (limited to 'src')
-rw-r--r--src/town_cmd.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index e87c4437f..1aadd5927 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1256,6 +1256,7 @@ static bool GrowTownWithTunnel(const Town* t, const TileIndex tile, const DiagDi
/* Only tunnel under a mountain if the slope is continuous for at least 4 tiles. We want tunneling to be a last resort for large hills. */
TileIndex slope_tile = tile;
for (uint8 tiles = 0; tiles < 4; tiles++) {
+ if (!IsValidTile(slope_tile)) return false;
slope = GetTileSlope(slope_tile);
if (slope != InclinedSlope(tunnel_dir) && !IsSteepSlope(slope) && !IsSlopeWithOneCornerRaised(slope)) return false;
slope_tile += delta;