diff options
author | rubidium <rubidium@openttd.org> | 2007-05-26 23:23:22 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-05-26 23:23:22 +0000 |
commit | 0be092ec71c1533ced2910a015c6276ea36799ac (patch) | |
tree | c533a58b51705923658e6cb07a8a96923e339327 | |
parent | fe9bf75436abb5db6567857982375911e876c8a9 (diff) | |
download | openttd-0be092ec71c1533ced2910a015c6276ea36799ac.tar.xz |
(svn r9950) -Feature(tte): allow terraforming under bridges.
-rw-r--r-- | src/clear_cmd.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index baf560cb5..f2ed0df81 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -291,24 +291,24 @@ int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) for (count = ts.tile_table_count; count != 0; count--, ti++) { TileIndex tile = *ti; - if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) { + uint z_min = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0)); + uint z_max = z_min; + uint t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0)); + z_min = min(z_min, t); + z_max = max(z_max, t); + t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1)); + z_min = min(z_min, t); + z_max = max(z_max, t); + t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1)); + z_min = min(z_min, t); + z_max = max(z_max, t); + + if (direction == 1 && MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) && + GetBridgeHeight(GetSouthernBridgeEnd(tile)) <= z_max * TILE_HEIGHT) { return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); } - - if (direction == -1) { - uint z, t; - - z = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0)); - t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0)); - if (t <= z) z = t; - t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1)); - if (t <= z) z = t; - t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1)); - if (t <= z) z = t; - - if (IsTunnelInWay(tile, z * TILE_HEIGHT)) { - return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE); - } + if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) { + return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE); } } } |