summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-14 21:39:12 +0000
committerrubidium <rubidium@openttd.org>2010-11-14 21:39:12 +0000
commitd5721005850cc3f6b66ab5609244dcd99536c080 (patch)
tree0c7d245e66ffc916561b7a3bc9c9e4a9d014867b
parentc370f56bf3553c1ff37564d7b2c6c5848deb3651 (diff)
downloadopenttd-d5721005850cc3f6b66ab5609244dcd99536c080.tar.xz
(svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
-rw-r--r--src/saveload/afterload.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 6c6458940..7ed394d20 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2346,10 +2346,18 @@ bool AfterLoadGame()
byte frame = (vdir == DIAGDIR_NE || vdir == DIAGDIR_NW) ? TILE_SIZE - 1 - pos : pos;
extern const byte _tunnel_visibility_frame[DIAGDIR_END];
- if (dir == vdir && !(v->vehstatus & VS_HIDDEN)) {
- if (frame < _tunnel_visibility_frame[dir]) continue;
- /* Tunnel entrance, make us invisible. */
- v->tile = vtile;
+ /* Should the vehicle be hidden or not? */
+ bool hidden;
+ if (dir == vdir) { // Entering tunnel
+ hidden = frame >= _tunnel_visibility_frame[dir];
+ } else if (dir == ReverseDiagDir(vdir)) { // Leaving tunnel
+ hidden = frame < TILE_SIZE - _tunnel_visibility_frame[dir];
+ } else { // Something freaky going on?
+ NOT_REACHED();
+ }
+ v->tile = vtile;
+
+ if (hidden) {
v->vehstatus |= VS_HIDDEN;
switch (v->type) {
@@ -2357,10 +2365,7 @@ bool AfterLoadGame()
case VEH_ROAD: RoadVehicle::From(v)->state = RVSB_WORMHOLE; break;
default: NOT_REACHED();
}
- } else if (dir == ReverseDiagDir(vdir) && (v->vehstatus & VS_HIDDEN)) {
- if (frame < TILE_SIZE - _tunnel_visibility_frame[dir]) continue;
- /* Tunnel exit, make us visible again. */
- v->tile = vtile;
+ } else {
v->vehstatus &= ~VS_HIDDEN;
switch (v->type) {