summaryrefslogtreecommitdiff
path: root/clear_cmd.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-12-27 12:38:02 +0000
committercelestar <celestar@openttd.org>2006-12-27 12:38:02 +0000
commitd95e2c2dd10a0dfc1704962a68a2bd32b635d158 (patch)
tree28100daed109de06e979123edd0601487ecc8261 /clear_cmd.c
parentd92103d6ff97ae413e2e6eae602e04b05addaf17 (diff)
downloadopenttd-d95e2c2dd10a0dfc1704962a68a2bd32b635d158.tar.xz
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
Diffstat (limited to 'clear_cmd.c')
-rw-r--r--clear_cmd.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/clear_cmd.c b/clear_cmd.c
index 9ebd9e8bd..4d1a78ba9 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -12,6 +12,7 @@
#include "viewport.h"
#include "command.h"
#include "tunnel_map.h"
+#include "bridge_map.h"
#include "variables.h"
#include "table/sprites.h"
#include "unmovable_map.h"
@@ -276,25 +277,32 @@ int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
}
- if (direction == -1) {
+ {
/* Check if tunnel would take damage */
int count;
TileIndex *ti = ts.tile_table;
for (count = ts.tile_table_count; count != 0; count--, ti++) {
- uint z, t;
TileIndex tile = *ti;
- 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 (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) {
+ return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
+ }
+
+ if (direction == -1) {
+ uint z, t;
- if (IsTunnelInWay(tile, z * TILE_HEIGHT)) {
- return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
+ 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);
+ }
}
}
}
@@ -534,6 +542,7 @@ static void DrawTile_Clear(TileInfo *ti)
}
DrawClearLandFence(ti);
+ DrawBridgeMiddle(ti);
}
static uint GetSlopeZ_Clear(TileIndex tile, uint x, uint y)