diff options
author | smatz <smatz@openttd.org> | 2011-01-21 16:35:12 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2011-01-21 16:35:12 +0000 |
commit | a6fcd7853882abf9dea0a1a035f1372751de432f (patch) | |
tree | 1967cb1d5c2f9421c97ccade00633697d9490217 /src | |
parent | e308c348f0f1dad5d18349aba5c19a2a4b372df3 (diff) | |
download | openttd-a6fcd7853882abf9dea0a1a035f1372751de432f.tar.xz |
(svn r21880) -Fix: when a train after reversing ended at the last bit of a bridge ramp and directed outside the bridge, it could still have track set to TRACK_BIT_WORMHOLE
Diffstat (limited to 'src')
-rw-r--r-- | src/train_cmd.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 6f1cc9003..108e75597 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1454,6 +1454,22 @@ static void UpdateStatusAfterSwap(Train *v) /* Call the proper EnterTile function unless we are in a wormhole. */ if (v->track != TRACK_BIT_WORMHOLE) { VehicleEnterTile(v, v->tile, v->x_pos, v->y_pos); + } else { + /* VehicleEnter_TunnelBridge() sets TRACK_BIT_WORMHOLE when the vehicle + * is on the last bit of the bridge head (frame == TILE_SIZE - 1). + * If we were swapped with such a vehicle, we have set TRACK_BIT_WORMHOLE, + * when we shouldn't have. Check if this is the case. */ + TileIndex vt = TileVirtXY(v->x_pos, v->y_pos); + if (IsTileType(vt, MP_TUNNELBRIDGE)) { + VehicleEnterTile(v, vt, v->x_pos, v->y_pos); + if (v->track != TRACK_BIT_WORMHOLE && IsBridgeTile(v->tile)) { + /* We have just left the wormhole, possibly set the + * "goingdown" bit. UpdateInclination() can be used + * because we are at the border of the tile. */ + v->UpdateInclination(true, true); + return; + } + } } v->UpdateViewport(true, true); |