Changeset - r8521:2c1a4a289a7b
[Not reviewed]
master
0 1 0
smatz - 16 years ago 2008-02-09 17:36:21
smatz@openttd.org
(svn r12096) -Fix: remove leftover property when loading older savegames
1 file changed with 32 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/openttd.cpp
Show inline comments
 
@@ -2359,12 +2359,44 @@ bool AfterLoadGame()
 

	
 
			if (IsTileType(t, MP_WATER) && IsLock(t)) SetWaterClassDependingOnSurroundings(t);
 
			if (IsTileType(t, MP_STATION) && (IsDock(t) || IsBuoy(t))) SetWaterClassDependingOnSurroundings(t);
 
		}
 
	}
 

	
 
	if (CheckSavegameVersion(87)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (IsBuoyTile(t) || IsDriveThroughStopTile(t) || IsTileType(t, MP_WATER)) {
 
				Owner o = GetTileOwner(t);
 
				if (IsValidPlayer(o) && !GetPlayer(o)->is_active) {
 
					_current_player = o;
 
					ChangeTileOwner(t, o, PLAYER_SPECTATOR);
 
				}
 
				if (IsBuoyTile(t)) {
 
					/* reset buoy owner to OWNER_NONE in the station struct
 
					 * (even if it is owned by active player) */
 
					GetStationByTile(t)->owner = OWNER_NONE;
 
				}
 
			} else if (IsTileType(t, MP_ROAD)) {
 
				/* works for all RoadTileType */
 
				for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
 
					/* update even non-existing road types to update tile owner too */
 
					Owner o = GetRoadOwner(t, rt);
 
					if (IsValidPlayer(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE);
 
				}
 
				if (GetRoadTileType(t) == ROAD_TILE_CROSSING) {
 
					Owner o = GetTileOwner(t);
 
					if (!GetPlayer(o)->is_active) {
 
						/* remove leftover rail piece from crossing (from very old savegames) */
 
						_current_player = o;
 
						DoCommand(t, 0, AxisToTrack(OtherAxis(GetCrossingRoadAxis(t))), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL);
 
					}
 
				}
 
			}
 
		}
 
	}
 

	
 
	return InitializeWindowsAndCaches();
 
}
 

	
 
/** Reload all NewGRF files during a running game. This is a cut-down
 
 * version of AfterLoadGame().
 
 * XXX - We need to reset the vehicle position hash because with a non-empty
0 comments (0 inline, 0 general)