summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-26 23:23:22 +0000
committerrubidium <rubidium@openttd.org>2007-05-26 23:23:22 +0000
commit8602acc4335c35f5c777114d78b7a297a52257f6 (patch)
treec533a58b51705923658e6cb07a8a96923e339327 /src
parentc69458d894a4db6e4d5c19dabde204ddf5dec3f9 (diff)
downloadopenttd-8602acc4335c35f5c777114d78b7a297a52257f6.tar.xz
(svn r9950) -Feature(tte): allow terraforming under bridges.
Diffstat (limited to 'src')
-rw-r--r--src/clear_cmd.cpp32
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);
}
}
}