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/newgrf_industrytiles.cpp | |
parent | 9f55abf51aac0f408e60d905fb2ac1b8a1405bb9 (diff) | |
download | openttd-00e5c1df18449992cc974b99c61a44d1385bf4a7.tar.xz |
(svn r22567) -Codechange: Store persistent storages inside a pool.
Diffstat (limited to 'src/newgrf_industrytiles.cpp')
-rw-r--r-- | src/newgrf_industrytiles.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 0da052f2b..a69d655cb 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -158,7 +158,19 @@ void IndustryTileStorePSA(ResolverObject *object, uint pos, int32 value) { Industry *ind = object->u.industry.ind; if (object->scope != VSG_SCOPE_PARENT || ind->index == INVALID_INDUSTRY) return; - ind->psa.StoreValue(pos, value); + + if (ind->psa == NULL) { + /* There is no need to create a storage if the value is zero. */ + if (value == 0) return; + + /* Create storage on first modification. */ + const IndustrySpec *indsp = GetIndustrySpec(ind->type); + uint32 grfid = (indsp->grf_prop.grffile != NULL) ? indsp->grf_prop.grffile->grfid : 0; + assert(PersistentStorage::CanAllocateItem()); + ind->psa = new PersistentStorage(grfid); + } + + ind->psa->StoreValue(pos, value); } static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIndex tile, Industry *indus) |