From 1dda7d6486decf558d2ef848af3c22ee945801e6 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sun, 31 Jan 2021 04:04:22 -0500 Subject: Fix: don't walk out of the map when trying to build tunnels (#8600) --- src/town_cmd.cpp | 1 + 1 file changed, 1 insertion(+) 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; -- cgit v1.2.3-54-g00ecf