diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index 0b82c60efe..71a171c665 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -270,7 +270,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin } } /* Check if tunnel would take damage */ - if (direction == -1 && IsTunnelInWay(tile, z_min, false)) { + if (direction == -1 && IsTunnelInWay(tile, z_min, true)) { _terraform_err_tile = tile; // highlight the tile above the tunnel return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE); } diff --git a/src/tunnel_map.cpp b/src/tunnel_map.cpp index 358e83efc9..5ffb409c47 100644 --- a/src/tunnel_map.cpp +++ b/src/tunnel_map.cpp @@ -44,10 +44,10 @@ TileIndex GetOtherTunnelEnd(TileIndex tile) * Is there a tunnel in the way in any direction? * @param tile the tile to search from. * @param z the 'z' to search on. - * @param not_allowed Only terra forming does not search between tunnel portals. + * @param chunnel_allowed True if chunnel mid-parts are allowed, used when terraforming. * @return true if and only if there is a tunnel. */ -bool IsTunnelInWay(TileIndex tile, int z, bool not_allowed) +bool IsTunnelInWay(TileIndex tile, int z, bool chunnel_allowed) { uint x = TileX(tile); uint y = TileY(tile); @@ -62,7 +62,7 @@ bool IsTunnelInWay(TileIndex tile, int z, bool not_allowed) if (TileY(t->tile_n) != y || (int)TileHeight(t->tile_n) != z) continue; // dir DIAGDIR_SW } - if (t->is_chunnel > not_allowed) { + if (t->is_chunnel && chunnel_allowed) { /* Only if tunnel was build over water terraforming is allowed between portals. */ TileIndexDiff delta = GetTunnelBridgeDirection(t->tile_n) == DIAGDIR_SE ? TileOffsByDiagDir(DIAGDIR_SE) * 4 : 4; // 4 tiles ramp. if (tile < t->tile_n + delta || t->tile_s - delta < tile) return true; diff --git a/src/tunnel_map.h b/src/tunnel_map.h index 5d77822c6a..2ea126523f 100644 --- a/src/tunnel_map.h +++ b/src/tunnel_map.h @@ -51,7 +51,7 @@ static inline TunnelID GetTunnelIndex(TileIndex t) } TileIndex GetOtherTunnelEnd(TileIndex); -bool IsTunnelInWay(TileIndex, int z, bool not_allowed = true); +bool IsTunnelInWay(TileIndex, int z, bool chunnel_allowed = false); /** * Makes a road tunnel entrance diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index b06c20fe65..e0be7f26e1 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -740,7 +740,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, head_tiles = 0; found_tunnel_tile = INVALID_TILE; } - if (!_cheats.crossing_tunnels.value && IsTunnelInWay(end_tile, start_z, false)) { + if (!_cheats.crossing_tunnels.value && IsTunnelInWay(end_tile, start_z, true)) { if (found_tunnel_tile == INVALID_TILE || is_chunnel) { // Remember the first or the last when we pass a tunnel. found_tunnel_tile = end_tile; head_tiles = 0;