From a3d1b916d1b6e3c4bbb3877f0fc9c72644a58861 Mon Sep 17 00:00:00 2001 From: Andreas Schmitt Date: Thu, 17 Jun 2021 09:40:16 +0200 Subject: [PATCH] Limit tunnel length at the proper place --- src/road.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/road.cpp b/src/road.cpp index 119b567f5d..c2315f03e1 100644 --- a/src/road.cpp +++ b/src/road.cpp @@ -382,12 +382,13 @@ static TileIndex BuildTunnel(PathNode *current, TileIndex end_tile = INVALID_TIL const TileIndexDiff delta = TileOffsByDiagDir(direction); end_tile = start_tile; int end_z; + const uint tunnel_length_limit = std::min(_settings_game.construction.max_tunnel_length, 30); for (int tunnel_length = 1;;tunnel_length++) { end_tile += delta; if (!IsValidTile(end_tile)) return INVALID_TILE; - if (tunnel_length > _settings_game.construction.max_tunnel_length) return INVALID_TILE; + if (tunnel_length > tunnel_length_limit) return INVALID_TILE; GetTileSlope(end_tile, &end_z);