Fix a potential crash when loading script locals from savegame

deque
scrawl 11 years ago
parent 9fb5cef287
commit b358cf2423

@ -20,10 +20,15 @@ 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));
mData.getLocals().read (state.mLocals, 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…
Cancel
Save