diff options
author | smatz <smatz@openttd.org> | 2011-02-02 22:20:48 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2011-02-02 22:20:48 +0000 |
commit | 3bfad0243b0e7abf143f928060ececade449588f (patch) | |
tree | a32af1eb880ad3200b428856cbf35d7847406f77 /src | |
parent | 547421496ec06e77b1897d2ba8df2140bd073022 (diff) | |
download | openttd-3bfad0243b0e7abf143f928060ececade449588f.tar.xz |
(svn r21947) -Fix (r21195): crash when converting a savegame with vehicles crashed in a tunnel entry, or with vehicles reversing there
Diffstat (limited to 'src')
-rw-r--r-- | src/saveload/afterload.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 05f15165f..531db1d1d 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2390,12 +2390,19 @@ bool AfterLoadGame() bool hidden; if (dir == vdir) { // Entering tunnel hidden = frame >= _tunnel_visibility_frame[dir]; + v->tile = vtile; } else if (dir == ReverseDiagDir(vdir)) { // Leaving tunnel hidden = frame < TILE_SIZE - _tunnel_visibility_frame[dir]; - } else { // Something freaky going on? - NOT_REACHED(); + /* v->tile changes at the moment when the vehicle leaves the tunnel. */ + v->tile = hidden ? GetOtherTunnelBridgeEnd(vtile) : vtile; + } else { + /* We could get here in two cases: + * - for road vehicles, it is reversing at the end of the tunnel + * - it is crashed in the tunnel entry (both train or RV destroyed by UFO) + * Whatever case it is, do not change anything and use the old values. + * Especially changing RV's state would break its reversing in the middle. */ + continue; } - v->tile = vtile; if (hidden) { v->vehstatus |= VS_HIDDEN; |