1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-01 03:15:32 +00:00

Fix a potential crash when loading script locals from savegame

This commit is contained in:
scrawl 2014-05-10 18:14:35 +02:00
parent 9fb5cef287
commit b358cf2423

View file

@ -20,11 +20,16 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
if (state.mHasLocals) if (state.mHasLocals)
{ {
std::string scriptId = mClass->getScript (ptr); std::string scriptId = mClass->getScript (ptr);
// Make sure we still have a script. It could have been coming from a content file that is no longer active.
mData.setLocals (*MWBase::Environment::get().getWorld()->getStore(). if (!scriptId.empty())
get<ESM::Script>().find (scriptId)); {
if (const ESM::Script* script = MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().search (scriptId))
{
mData.setLocals (*script);
mData.getLocals().read (state.mLocals, scriptId); mData.getLocals().read (state.mLocals, scriptId);
} }
}
}
mClass->readAdditionalState (ptr, state); mClass->readAdditionalState (ptr, state);
} }