summaryrefslogtreecommitdiff
path: root/src/saveload/station_sl.cpp
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2011-06-12 20:47:45 +0000
committerterkhen <terkhen@openttd.org>2011-06-12 20:47:45 +0000
commit00e5c1df18449992cc974b99c61a44d1385bf4a7 (patch)
tree7433db92049848236fe05f18b99d6f80c99442c6 /src/saveload/station_sl.cpp
parent9f55abf51aac0f408e60d905fb2ac1b8a1405bb9 (diff)
downloadopenttd-00e5c1df18449992cc974b99c61a44d1385bf4a7.tar.xz
(svn r22567) -Codechange: Store persistent storages inside a pool.
Diffstat (limited to 'src/saveload/station_sl.cpp')
-rw-r--r--src/saveload/station_sl.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp
index 5cd2196dd..78277d4bd 100644
--- a/src/saveload/station_sl.cpp
+++ b/src/saveload/station_sl.cpp
@@ -15,6 +15,7 @@
#include "../roadstop_base.h"
#include "../vehicle_base.h"
#include "../newgrf_station.h"
+#include "../newgrf.h"
#include "saveload.h"
#include "table/strings.h"
@@ -344,6 +345,8 @@ static const SaveLoad _base_station_desc[] = {
SLE_END()
};
+static OldPersistentStorage _old_st_persistent_storage;
+
static const SaveLoad _station_desc[] = {
SLE_WRITEBYTE(Station, facilities, FACIL_NONE),
SLE_ST_INCLUDE(),
@@ -362,7 +365,8 @@ static const SaveLoad _station_desc[] = {
SLE_CONDVAR(Station, airport.layout, SLE_UINT8, 145, SL_MAX_VERSION),
SLE_VAR(Station, airport.flags, SLE_UINT64),
SLE_CONDVAR(Station, airport.rotation, SLE_UINT8, 145, SL_MAX_VERSION),
- SLE_CONDARR(Station, airport.psa.storage, SLE_UINT32, 16, 145, SL_MAX_VERSION),
+ SLEG_CONDARR(_old_st_persistent_storage.storage, SLE_UINT32, 16, 145, 160),
+ SLE_CONDREF(Station, airport.psa, REF_STORAGE, 161, SL_MAX_VERSION),
SLE_VAR(Station, indtype, SLE_UINT8),
@@ -437,6 +441,15 @@ static void Load_STNN()
if (!waypoint) {
Station *st = Station::From(bst);
+
+ /* Before savegame version 161, persistent storages were not stored in a pool. */
+ if (IsSavegameVersionBefore(161) && !IsSavegameVersionBefore(145) && st->facilities & FACIL_AIRPORT) {
+ /* Store the old persistent storage. The GRFID will be added later. */
+ assert(PersistentStorage::CanAllocateItem());
+ st->airport.psa = new PersistentStorage(0);
+ memcpy(st->airport.psa->storage, _old_st_persistent_storage.storage, sizeof(st->airport.psa->storage));
+ }
+
for (CargoID i = 0; i < NUM_CARGO; i++) {
SlObject(&st->goods[i], GetGoodsDesc());
}