1
0
Fork 0

Fix: don't walk out of the map when trying to build tunnels (#8600)

pull/8626/head
Tyler Trahan 2021-01-31 04:04:22 -05:00 committed by GitHub
parent 0e54c32452
commit 1dda7d6486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -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. */ /* 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; TileIndex slope_tile = tile;
for (uint8 tiles = 0; tiles < 4; tiles++) { for (uint8 tiles = 0; tiles < 4; tiles++) {
if (!IsValidTile(slope_tile)) return false;
slope = GetTileSlope(slope_tile); slope = GetTileSlope(slope_tile);
if (slope != InclinedSlope(tunnel_dir) && !IsSteepSlope(slope) && !IsSlopeWithOneCornerRaised(slope)) return false; if (slope != InclinedSlope(tunnel_dir) && !IsSteepSlope(slope) && !IsSlopeWithOneCornerRaised(slope)) return false;
slope_tile += delta; slope_tile += delta;