From d95e2c2dd10a0dfc1704962a68a2bd32b635d158 Mon Sep 17 00:00:00 2001 From: celestar Date: Wed, 27 Dec 2006 12:38:02 +0000 Subject: (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals) --- clear_cmd.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'clear_cmd.c') 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) -- cgit v1.2.3-54-g00ecf