summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-02-09 17:36:21 +0000
committersmatz <smatz@openttd.org>2008-02-09 17:36:21 +0000
commit5bfcd657c317f0f4d4d14f092b13c069be622e5e (patch)
tree1b32c3425543ea6f10fcc8bf81c56fcee57ad268 /src/openttd.cpp
parent98e81e95a535f7d940057e79ab46902498d0d067 (diff)
downloadopenttd-5bfcd657c317f0f4d4d14f092b13c069be622e5e.tar.xz
(svn r12096) -Fix: remove leftover property when loading older savegames
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 09d79153c..d7d36b3a5 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -2362,6 +2362,38 @@ bool AfterLoadGame()
}
}
+ 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();
}