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/afterload.cpp | |
parent | 9f55abf51aac0f408e60d905fb2ac1b8a1405bb9 (diff) | |
download | openttd-00e5c1df18449992cc974b99c61a44d1385bf4a7.tar.xz |
(svn r22567) -Codechange: Store persistent storages inside a pool.
Diffstat (limited to 'src/saveload/afterload.cpp')
-rw-r--r-- | src/saveload/afterload.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 33cff5aa3..7f6a7f700 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2595,6 +2595,58 @@ bool AfterLoadGame() } } + if (IsSavegameVersionBefore(161)) { + /* Before savegame version 161, persistent storages were not stored in a pool. */ + + if (!IsSavegameVersionBefore(76)) { + Industry *ind; + FOR_ALL_INDUSTRIES(ind) { + assert(ind->psa != NULL); + + /* Check if the old storage was empty. */ + bool is_empty = true; + for (uint i = 0; i < sizeof(ind->psa->storage); i++) { + if (ind->psa->GetValue(i) != 0) { + is_empty = false; + break; + } + } + + if (!is_empty) { + ind->psa->grfid = _industry_mngr.GetGRFID(ind->type); + } else { + delete ind->psa; + ind->psa = NULL; + } + } + } + + if (!IsSavegameVersionBefore(145)) { + Station *st; + FOR_ALL_STATIONS(st) { + if (!st->facilities & FACIL_AIRPORT) continue; + assert(st->airport.psa != NULL); + + /* Check if the old storage was empty. */ + bool is_empty = true; + for (uint i = 0; i < sizeof(st->airport.psa->storage); i++) { + if (st->airport.psa->GetValue(i) != 0) { + is_empty = false; + break; + } + } + + if (!is_empty) { + st->airport.psa->grfid = _airport_mngr.GetGRFID(st->airport.type); + } else { + delete st->airport.psa; + st->airport.psa = NULL; + + } + } + } + } + /* Road stops is 'only' updating some caches */ AfterLoadRoadStops(); AfterLoadLabelMaps(); |