From 9696e3e39bcfa5092221e1db9d75769700f0482b Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 20 Oct 2009 12:20:53 +0000 Subject: (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 --- src/saveload/cargopacket_sl.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/saveload/cargopacket_sl.cpp') 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(); + } + } } /** -- cgit v1.2.3-54-g00ecf