Mercurial > hg > openttd
diff src/saveload/afterload.cpp @ 17782:043b87d0dbec draft
(svn r22567) -Codechange: Store persistent storages inside a pool.
author | terkhen <terkhen@openttd.org> |
---|---|
date | Sun, 12 Jun 2011 20:47:45 +0000 |
parents | 6e539d6e9fe0 |
children | 5d14fa020688 |
line wrap: on
line diff
--- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2595,6 +2595,58 @@ } } + 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();