# HG changeset patch # User celestar # Date 1167588201 0 # Node ID d6197e6c420e92901bbd4a151fad247c3ba32dba # Parent 623bae81fbd265b272b365018f5dff35d250ef36 (svn r7705) [cbh] - Fix: Trains leave the bridge according to the trackbits that a present on the bridge head. WARNING: zero-length bridges do not work yet diff -r 623bae81fbd2 -r d6197e6c420e train_cmd.c --- 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;