mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Fix a potential crash when loading script locals from savegame
This commit is contained in:
parent
9fb5cef287
commit
b358cf2423
1 changed files with 9 additions and 4 deletions
|
@ -20,11 +20,16 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
|
|||
if (state.mHasLocals)
|
||||
{
|
||||
std::string scriptId = mClass->getScript (ptr);
|
||||
|
||||
mData.setLocals (*MWBase::Environment::get().getWorld()->getStore().
|
||||
get<ESM::Script>().find (scriptId));
|
||||
// Make sure we still have a script. It could have been coming from a content file that is no longer active.
|
||||
if (!scriptId.empty())
|
||||
{
|
||||
if (const ESM::Script* script = MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().search (scriptId))
|
||||
{
|
||||
mData.setLocals (*script);
|
||||
mData.getLocals().read (state.mLocals, scriptId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mClass->readAdditionalState (ptr, state);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue