--- a/train_cmd.c Sun Dec 31 16:08:00 2006 +0000
+++ b/train_cmd.c Sun Dec 31 18:03:21 2006 +0000
@@ -3093,7 +3093,7 @@
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
}
- } else {
+ } else new_tile:{
/* A new tile is about to be entered. */
byte bits;
@@ -3209,7 +3209,14 @@
SetSpeedLimitOnBridge(v);
if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) && ((VehicleEnterTile(v, gp.new_tile, gp.x, gp.y) & 0x4) != 0)) {
- /* vehicle just left the bridge/tunnel wormhole and entered ramp/exit from inside */
+ if (IsBridgeTile(gp.new_tile)) {
+ /* when on a bridge, v->tile points to one of the bridge heads. GetNewVehicleDirection will
+ * fail, because it expects the new and old tile (gp.{new|old}tile) to be adjacent to each
+ * other. So we set the old_tile here manually by using the current vehicle coordinates */
+ gp.old_tile = TileVirtXY(v->x_pos, v->y_pos);
+ goto new_tile; /* We need the same code when entering from a bridge than from any other tile */
+ }
+
} else {
/* vehicle stays in the bridge/tunnel wormhole */
v->x_pos = gp.x;