summaryrefslogtreecommitdiff
path: root/src/saveload/afterload.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-20 12:20:53 +0000
committerrubidium <rubidium@openttd.org>2009-10-20 12:20:53 +0000
commit9696e3e39bcfa5092221e1db9d75769700f0482b (patch)
tree87659518e7abb1155c43c7d08ebff35b18904481 /src/saveload/afterload.cpp
parentcfcf3159b2a4c20f2457c1ac360139c18617b93d (diff)
downloadopenttd-9696e3e39bcfa5092221e1db9d75769700f0482b.tar.xz
(svn r17816) -Codechange: move the CargoList invalidation-after-saveload to the function that handles the CargoPackets instead of spreading it around over the saveload files. Also add some code to validate whether the caches are valid; to be removed later when no problems turn up
Diffstat (limited to 'src/saveload/afterload.cpp')
-rw-r--r--src/saveload/afterload.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index bcfa76885..0e663ee1c 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -535,6 +535,14 @@ bool AfterLoadGame()
/* Connect front and rear engines of multiheaded trains */
ConnectMultiheadedTrains();
+ /* Fix the CargoPackets *and* fix the caches of CargoLists.
+ * If this isn't done before Stations and especially Vehicles are
+ * running their AfterLoad we might get in trouble. In the case of
+ * vehicles we could give the wrong (cached) count of items in a
+ * vehicle which causes different results when getting their caches
+ * filled; and that could eventually lead to desyncs. */
+ CargoPacket::AfterLoad();
+
/* Update all vehicles */
AfterLoadVehicles(true);
@@ -1226,8 +1234,6 @@ bool AfterLoadGame()
}
}
- CargoPacket::AfterLoad();
-
if (CheckSavegameVersion(45)) {
Vehicle *v;
/* Originally just the fact that some cargo had been paid for was
@@ -1237,7 +1243,6 @@ bool AfterLoadGame()
* amount that has been paid is stored. */
FOR_ALL_VEHICLES(v) {
ClrBit(v->vehicle_flags, 2);
- v->cargo.InvalidateCache();
}
}