summaryrefslogtreecommitdiff
path: root/tunnelbridge_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-05-07 11:55:28 +0000
committertron <tron@openttd.org>2006-05-07 11:55:28 +0000
commit8bd664f81f3664ee4ce13cfa547f113a34eccbcc (patch)
treef46b4df77eb436c939fa048f1b0db6f8b6e42887 /tunnelbridge_cmd.c
parent9208cd3f42796b85672636cf61a1439779d60bed (diff)
downloadopenttd-8bd664f81f3664ee4ce13cfa547f113a34eccbcc.tar.xz
(svn r4771) -Regression: It was possible to remove a bridge while a vehicle was on it
Diffstat (limited to 'tunnelbridge_cmd.c')
-rw-r--r--tunnelbridge_cmd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 9d80be942..5fc8b6108 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -583,6 +583,15 @@ static int32 DoClearTunnel(TileIndex tile, uint32 flags)
}
+static uint GetBridgeHeightRamp(TileIndex t)
+{
+ /* Return the height there (the height of the NORTH CORNER)
+ * If the end of the bridge is on a tile with all corners except the north corner raised,
+ * the z coordinate is 1 height level too low. Compensate for that */
+ return TilePixelHeight(t) + (GetTileSlope(t, NULL) == SLOPE_WSE ? TILE_HEIGHT : 0);
+}
+
+
static int32 DoClearBridge(TileIndex tile, uint32 flags)
{
DiagDirection direction;
@@ -650,7 +659,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
v = FindVehicleBetween(
tile + delta,
endtile - delta,
- TilePixelHeight(tile) + TILE_HEIGHT + GetCorrectTileHeight(tile)
+ GetBridgeHeightRamp(tile) + TILE_HEIGHT
);
if (v != NULL) {
VehicleInTheWayErrMsg(v);
@@ -802,12 +811,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
// fast routine for getting the height of a middle bridge tile. 'tile' MUST be a middle bridge tile.
uint GetBridgeHeight(TileIndex t)
{
- TileIndex tile = GetSouthernBridgeEnd(t);
-
- /* Return the height there (the height of the NORTH CORNER)
- * If the end of the bridge is on a tile with all corners except the north corner raised,
- * the z coordinate is 1 height level too low. Compensate for that */
- return TilePixelHeight(tile) + (GetTileSlope(tile, NULL) == SLOPE_WSE ? TILE_HEIGHT : 0);
+ return GetBridgeHeightRamp(GetSouthernBridgeEnd(t));
}
static const byte _bridge_foundations[2][16] = {