summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-07-22 07:28:04 +0000
committertron <tron@openttd.org>2006-07-22 07:28:04 +0000
commitaf7fa1df24de5e473ad00fb35ceba3c36a1ab6ae (patch)
treef1aa6252ef5dc2c3e7bd6b1b9de799834b2fb753
parent16b923260cfbe0973acf3231378070243856f53d (diff)
downloadopenttd-af7fa1df24de5e473ad00fb35ceba3c36a1ab6ae.tar.xz
(svn r5580) -Regression: Under certain circumstances it was possible to remove/convert bridges while a vehicle was on it. Fix this by properly calculating the height of a bridge
-rw-r--r--tunnelbridge_cmd.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 5b5ee00b9..bbae3bbc6 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -597,13 +597,12 @@ 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) +
- TILE_HEIGHT;
+ uint h;
+ uint tileh = GetTileSlope(t, &h);
+ uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t)));
+
+ // one height level extra if the ramp is on a flat foundation
+ return h + TILE_HEIGHT + (IS_INT_INSIDE(f, 1, 15) ? TILE_HEIGHT : 0);
}