Changeset - r16461:eb27f731001d
[Not reviewed]
master
0 1 0
rubidium - 14 years ago 2010-11-14 21:39:12
rubidium@openttd.org
(svn r21195) -Fix [FS#4230] (r21135): in some corner cases the savegame conversion didn't do the right thing
1 file changed with 13 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/saveload/afterload.cpp
Show inline comments
 
@@ -2343,27 +2343,32 @@ bool AfterLoadGame()
 

	
 
			/* Have we passed the visibility "switch" state already? */
 
			byte pos = (DiagDirToAxis(vdir) == AXIS_X ? v->x_pos : v->y_pos) & TILE_UNIT_MASK;
 
			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) {
 
					case VEH_TRAIN: Train::From(v)->track       = TRACK_BIT_WORMHOLE; break;
 
					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) {
 
					case VEH_TRAIN: Train::From(v)->track       = DiagDirToDiagTrackBits(vdir); break;
 
					case VEH_ROAD:  RoadVehicle::From(v)->state = DiagDirToDiagTrackdir(vdir);  break;
 
					default: NOT_REACHED();
0 comments (0 inline, 0 general)