summaryrefslogtreecommitdiff
path: root/src/saveload/station_sl.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2011-02-08 18:34:13 +0000
committersmatz <smatz@openttd.org>2011-02-08 18:34:13 +0000
commit887a7724dc3f68cdd3d0c566c66adf00696e4bc0 (patch)
tree00a9055a6bc84b0f9d278e3a8faac022dd0a3778 /src/saveload/station_sl.cpp
parent364ef8e6e6342f8f777da561571422c8c57c402b (diff)
downloadopenttd-887a7724dc3f68cdd3d0c566c66adf00696e4bc0.tar.xz
(svn r22025) -Fix: verify there is enough space in the pool when creating new pool items while loading old savegames
Diffstat (limited to 'src/saveload/station_sl.cpp')
-rw-r--r--src/saveload/station_sl.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index b0535d9d2..330425024 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -284,7 +284,11 @@ static void Load_STNS()
/* In old versions, enroute_from used 0xFF as INVALID_STATION */
StationID source = (IsSavegameVersionBefore(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
- /* Don't construct the packet with station here, because that'll fail with old savegames */
+ /* Make sure we can allocate the CargoPacket. This is safe
+ * as there can only be ~64k stations and 32 cargos in these
+ * savegame versions. As the CargoPacketPool has more than
+ * 16 million entries; it fits by an order of magnitude. */
+ assert(CargoPacket::CanAllocateItem());
ge->cargo.Append(new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_days, source, _cargo_source_xy, _cargo_source_xy, _cargo_feeder_share));
SB(ge->acceptance_pickup, GoodsEntry::PICKUP, 1, 1);
}