summaryrefslogtreecommitdiff
path: root/src/terraform_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-09-21 11:40:11 +0000
committerrubidium <rubidium@openttd.org>2014-09-21 11:40:11 +0000
commitce04c49e3d021451e8ad17e8a53e4e515f261209 (patch)
tree457f5c42490de310cb026744673048b0e7bb8781 /src/terraform_cmd.cpp
parentfedc1acd620f3fd364e6907ae760cc9cc9a057dc (diff)
downloadopenttd-ce04c49e3d021451e8ad17e8a53e4e515f261209.tar.xz
(svn r26882) -Feature: allow limiting the height of bridges (ic111)
Diffstat (limited to 'src/terraform_cmd.cpp')
-rw-r--r--src/terraform_cmd.cpp18
1 files changed, 14 insertions, 4 deletions
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)) {