tunnelbridge_cmd.c
branch0.5
changeset 5458 0a52d7d0e410
parent 5439 7af52897085a
child 5459 74356913b47d
--- a/tunnelbridge_cmd.c	Tue Feb 27 22:13:15 2007 +0000
+++ b/tunnelbridge_cmd.c	Sun Mar 11 23:03:14 2007 +0000
@@ -1430,7 +1430,13 @@
 		}
 	} 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;