summaryrefslogtreecommitdiff
path: root/src/saveload/cargopacket_sl.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/cargopacket_sl.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/cargopacket_sl.cpp')
-rw-r--r--src/saveload/cargopacket_sl.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/saveload/cargopacket_sl.cpp b/src/saveload/cargopacket_sl.cpp
index 57081fc51..77ee2ca7e 100644
--- a/src/saveload/cargopacket_sl.cpp
+++ b/src/saveload/cargopacket_sl.cpp
@@ -33,7 +33,6 @@
cp->source_xy = Station::IsValidID(cp->source) ? Station::Get(cp->source)->xy : v->tile;
cp->loaded_at_xy = cp->source_xy;
}
- v->cargo.InvalidateCache();
}
/* Store position of the station where the goods come from, so there
@@ -63,6 +62,19 @@
if (!Station::IsValidID(cp->source)) cp->source = INVALID_STATION;
}
}
+
+ if (!CheckSavegameVersion(68)) {
+ /* Only since version 68 we have cargo packets. Savegames from before used
+ * 'new CargoPacket' + cargolist.Append so their caches are already
+ * correct and do not need rebuilding. */
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) v->cargo.InvalidateCache();
+
+ Station *st;
+ FOR_ALL_STATIONS(st) {
+ for (CargoID c = 0; c < NUM_CARGO; c++) st->goods[c].cargo.InvalidateCache();
+ }
+ }
}
/**