From c2e9eb7d7bddf40236434733073ca944a13f1d74 Mon Sep 17 00:00:00 2001 From: Darkvater Date: Sat, 20 May 2006 20:16:08 +0000 Subject: [PATCH] (svn r4931) - Backport from trunk (r4766): Vehicles on a sloped tile under a bridge were affected by the bridge speed limit --- tunnelbridge_cmd.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index fa25cc28af..aba652c0c7 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -1208,6 +1208,23 @@ static inline DiagDirection GetBridgeRampDirection(TileIndex t) {return (DiagDir static inline bool IsTransportUnderBridge(TileIndex t) {return HASBIT(_m[t].m5, 5);} static inline uint GetBridgeAxis(TileIndex t) {return GB(_m[t].m5, 0, 1);} +static uint GetTileMaxZ(TileIndex t) +{ + uint max; + uint h; + + h = TileHeight(t); + max = h; + h = TileHeight(t + TileDiffXY(1, 0)); + if (h > max) max = h; + h = TileHeight(t + TileDiffXY(0, 1)); + if (h > max) max = h; + h = TileHeight(t + TileDiffXY(1, 1)); + if (h > max) max = h; + return max * 8; +} + + static uint GetSlopeZ_TunnelBridge(const TileInfo* ti) { TileIndex tile = ti->tile; @@ -1522,12 +1539,7 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y } } else if (_m[tile].m5 & 0x80) { if (v->type == VEH_Road || (v->type == VEH_Train && IsFrontEngine(v))) { - uint h; - - if (GetTileSlope(tile, &h) != 0) - h += 8; // Compensate for possible foundation - if (!(_m[tile].m5 & 0x40) || // start/end tile of bridge - myabs(h - v->z_pos) > 2) { // high above the ground -> on the bridge + if (IsBridgeRamp(tile) || v->z_pos > GetTileMaxZ(tile)) { /* modify speed of vehicle */ uint16 spd = _bridge[GetBridgeType(tile)].speed; if (v->type == VEH_Road) spd *= 2;