summaryrefslogtreecommitdiff
path: root/src/saveload/afterload.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-02-26 14:07:42 +0000
committersmatz <smatz@openttd.org>2009-02-26 14:07:42 +0000
commit3fdac6f702b0a2e8534b8f1c26faba02118ed8df (patch)
tree0664bda97b6877da1207d3896c81ef561dbf9313 /src/saveload/afterload.cpp
parenta41b143e58d1290f36ab62fd402953a05e9b7e0b (diff)
downloadopenttd-3fdac6f702b0a2e8534b8f1c26faba02118ed8df.tar.xz
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
Diffstat (limited to 'src/saveload/afterload.cpp')
-rw-r--r--src/saveload/afterload.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 97f114c4e..2f2362a81 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1615,14 +1615,6 @@ bool AfterLoadGame()
}
}
}
-
- /* Give owners to waypoints, based on rail tracks it is sitting on.
- * If none is available, specify OWNER_NONE */
- Waypoint *wp;
- FOR_ALL_WAYPOINTS(wp) {
- Owner owner = (IsRailWaypointTile(wp->xy) ? GetTileOwner(wp->xy) : OWNER_NONE);
- wp->owner = IsValidCompanyID(owner) ? owner : OWNER_NONE;
- }
}
if (CheckSavegameVersion(102)) {
@@ -1722,6 +1714,26 @@ bool AfterLoadGame()
}
}
+ if (CheckSavegameVersion(114)) {
+ /* There could be (deleted) stations with invalid owner, set owner to OWNER NONE.
+ * The conversion affects oil rigs and buoys too, but it doesn't matter as
+ * they have st->owner == OWNER_NONE already. */
+ Station *st;
+ FOR_ALL_STATIONS(st) {
+ if (!IsValidCompanyID(st->owner)) st->owner = OWNER_NONE;
+ }
+
+ /* Give owners to waypoints, based on rail tracks it is sitting on.
+ * If none is available, specify OWNER_NONE.
+ * This code was in CheckSavegameVersion(101) in the past, but in some cases,
+ * the owner of waypoints could be incorrect. */
+ Waypoint *wp;
+ FOR_ALL_WAYPOINTS(wp) {
+ Owner owner = IsTileType(wp->xy, MP_RAILWAY) ? GetTileOwner(wp->xy) : OWNER_NONE;
+ wp->owner = IsValidCompanyID(owner) ? owner : OWNER_NONE;
+ }
+ }
+
GamelogPrintDebug(1);
bool ret = InitializeWindowsAndCaches();