(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

This commit is contained in:
rubidium
2009-10-20 12:20:53 +00:00
parent 8e1f62993d
commit 079b7fa034
5 changed files with 41 additions and 10 deletions

View File

@@ -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();
}
}
}
/**