diff options
author | terkhen <terkhen@openttd.org> | 2011-06-12 20:47:45 +0000 |
---|---|---|
committer | terkhen <terkhen@openttd.org> | 2011-06-12 20:47:45 +0000 |
commit | 00e5c1df18449992cc974b99c61a44d1385bf4a7 (patch) | |
tree | 7433db92049848236fe05f18b99d6f80c99442c6 /src/saveload/industry_sl.cpp | |
parent | 9f55abf51aac0f408e60d905fb2ac1b8a1405bb9 (diff) | |
download | openttd-00e5c1df18449992cc974b99c61a44d1385bf4a7.tar.xz |
(svn r22567) -Codechange: Store persistent storages inside a pool.
Diffstat (limited to 'src/saveload/industry_sl.cpp')
-rw-r--r-- | src/saveload/industry_sl.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 2ba07a1a6..cfd87c728 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -11,10 +11,13 @@ #include "../stdafx.h" #include "../industry.h" +#include "../newgrf.h" #include "saveload.h" #include "newgrf_sl.h" +static OldPersistentStorage _old_ind_persistent_storage; + static const SaveLoad _industry_desc[] = { SLE_CONDVAR(Industry, location.tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), SLE_CONDVAR(Industry, location.tile, SLE_UINT32, 6, SL_MAX_VERSION), @@ -50,7 +53,8 @@ static const SaveLoad _industry_desc[] = { SLE_CONDVAR(Industry, last_cargo_accepted_at, SLE_INT32, 70, SL_MAX_VERSION), SLE_CONDVAR(Industry, selected_layout, SLE_UINT8, 73, SL_MAX_VERSION), - SLE_CONDARR(Industry, psa.storage, SLE_UINT32, 16, 76, SL_MAX_VERSION), + SLEG_CONDARR(_old_ind_persistent_storage.storage, SLE_UINT32, 16, 76, 160), + SLE_CONDREF(Industry, psa, REF_STORAGE, 161, SL_MAX_VERSION), SLE_CONDVAR(Industry, random_triggers, SLE_UINT8, 82, SL_MAX_VERSION), SLE_CONDVAR(Industry, random, SLE_UINT16, 82, SL_MAX_VERSION), @@ -90,6 +94,14 @@ static void Load_INDY() while ((index = SlIterateArray()) != -1) { Industry *i = new (index) Industry(); SlObject(i, _industry_desc); + + /* Before savegame version 161, persistent storages were not stored in a pool. */ + if (IsSavegameVersionBefore(161) && !IsSavegameVersionBefore(76)) { + /* Store the old persistent storage. The GRFID will be added later. */ + assert(PersistentStorage::CanAllocateItem()); + i->psa = new PersistentStorage(0); + memcpy(i->psa->storage, _old_ind_persistent_storage.storage, sizeof(i->psa->storage)); + } Industry::IncIndustryTypeCount(i->type); } } |