From 5a703390ec90451f89c0657fb66471214f63b2bb Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 11 Mar 2007 23:03:14 +0000 Subject: [PATCH] (svn r9128) [0.5] -Fix: trains slow down under bridges when they were going down on the tile before the bridge tile. --- tunnelbridge_cmd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 893972358b..981ee16797 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -1430,7 +1430,13 @@ static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y } } else if (IsBridge(tile)) { // XXX is this necessary? if (v->type == VEH_Road || (v->type == VEH_Train && IsFrontEngine(v))) { - if (IsBridgeRamp(tile) || v->z_pos > GetTileMaxZ(tile)) { + /* The train calls this (EnterTile) function before entering the tile. + * This has a drawback that the position of the train has not yet + * changed. So, when a train comes down a slope it is above the tile + * height of the current slope. Catch this situation by adding a + * small correction when trying to determine whether the train is on + * the bridge or under the bridge */ + if (IsBridgeRamp(tile) || v->z_pos > (GetTileMaxZ(tile) + 1)) { /* modify speed of vehicle */ uint16 spd = _bridge[GetBridgeType(tile)].speed; if (v->type == VEH_Road) spd *= 2;