forked from teamnwah/openmw-tes3coop
Do not assert() for invalid land data in plugins (Bug #3037)
The resizing of LTEX store to the correct number of plugins was done in the load() method, but the load method won't be called if a plugin contains LAND records but doesn't contain LTEX records. For such plugins the Store<ESM::LandTexture>::search() function would then fail an assertion.
This commit is contained in:
parent
5b8fd79b4b
commit
4687c4baad
3 changed files with 19 additions and 6 deletions
|
@ -32,6 +32,12 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
|
|||
|
||||
ESM::Dialogue *dialogue = 0;
|
||||
|
||||
// Land texture loading needs to use a separate internal store for each plugin.
|
||||
// We set the number of plugins here to avoid continual resizes during loading,
|
||||
// and so we can properly verify if valid plugin indices are being passed to the
|
||||
// LandTexture Store retrieval methods.
|
||||
mLandTextures.resize(esm.getGlobalReaderList()->size());
|
||||
|
||||
/// \todo Move this to somewhere else. ESMReader?
|
||||
// Cache parent esX files by tracking their indices in the global list of
|
||||
// all files/readers used by the engine. This will greaty accelerate
|
||||
|
|
|
@ -351,8 +351,9 @@ namespace MWWorld
|
|||
assert(plugin < mStatic.size());
|
||||
const LandTextureList <exl = mStatic[plugin];
|
||||
|
||||
assert(index < ltexl.size());
|
||||
return <exl.at(index);
|
||||
if (index >= ltexl.size())
|
||||
return NULL;
|
||||
return <exl[index];
|
||||
}
|
||||
const ESM::LandTexture *Store<ESM::LandTexture>::find(size_t index, size_t plugin) const
|
||||
{
|
||||
|
@ -380,10 +381,8 @@ namespace MWWorld
|
|||
|
||||
lt.load(esm, isDeleted);
|
||||
|
||||
// Make sure we have room for the structure
|
||||
if (plugin >= mStatic.size()) {
|
||||
mStatic.resize(plugin+1);
|
||||
}
|
||||
assert(plugin < mStatic.size());
|
||||
|
||||
LandTextureList <exl = mStatic[plugin];
|
||||
if(lt.mIndex + 1 > (int)ltexl.size())
|
||||
ltexl.resize(lt.mIndex+1);
|
||||
|
@ -407,6 +406,11 @@ namespace MWWorld
|
|||
assert(plugin < mStatic.size());
|
||||
return mStatic[plugin].end();
|
||||
}
|
||||
void Store<ESM::LandTexture>::resize(size_t num)
|
||||
{
|
||||
if (mStatic.size() < num)
|
||||
mStatic.resize(num);
|
||||
}
|
||||
|
||||
// Land
|
||||
//=========================================================================
|
||||
|
|
|
@ -210,6 +210,9 @@ namespace MWWorld
|
|||
const ESM::LandTexture *search(size_t index, size_t plugin) const;
|
||||
const ESM::LandTexture *find(size_t index, size_t plugin) const;
|
||||
|
||||
/// Resize the internal store to hold at least \a num plugins.
|
||||
void resize(size_t num);
|
||||
|
||||
size_t getSize() const;
|
||||
size_t getSize(size_t plugin) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue