From ce04c49e3d021451e8ad17e8a53e4e515f261209 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 21 Sep 2014 11:40:11 +0000 Subject: (svn r26882) -Feature: allow limiting the height of bridges (ic111) --- src/terraform_cmd.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/terraform_cmd.cpp') diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index 50ae42f6b..82554d43e 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -254,10 +254,20 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin if (pass == 0) { /* Check if bridge would take damage */ - if (direction == 1 && IsBridgeAbove(tile) && - GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max) { - _terraform_err_tile = tile; // highlight the tile under the bridge - return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); + if (IsBridgeAbove(tile)) { + int bridge_height = GetBridgeHeight(GetSouthernBridgeEnd(tile)); + + /* Check if bridge would take damage. */ + if (direction == 1 && bridge_height <= z_max) { + _terraform_err_tile = tile; // highlight the tile under the bridge + return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); + } + + /* Is the bridge above not too high afterwards? */ + if (direction == -1 && bridge_height > (z_min + _settings_game.construction.max_bridge_height)) { + _terraform_err_tile = tile; + return_cmd_error(STR_ERROR_BRIDGE_TOO_HIGH_AFTER_LOWER_LAND); + } } /* Check if tunnel would take damage */ if (direction == -1 && IsTunnelInWay(tile, z_min)) { -- cgit v1.2.3-54-g00ecf