Fix crash when onPcEquip script removes the equipped item (Fixes #3016)

openmw-38
scrawl 9 years ago
parent 1b77428c59
commit edfcb45ad7

@ -471,16 +471,18 @@ namespace MWGui
MWBase::Environment::get().getScriptManager()->run (script, interpreterContext);
}
if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0)
mSkippedToEquip = MWWorld::Ptr();
if (ptr.getRefData().getCount()) // make sure the item is still there, the script might have removed it
{
boost::shared_ptr<MWWorld::Action> action = ptr.getClass().use(ptr);
action->execute (player);
if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0)
{
boost::shared_ptr<MWWorld::Action> action = ptr.getClass().use(ptr);
mSkippedToEquip = MWWorld::Ptr();
action->execute (player);
}
else
mSkippedToEquip = ptr;
}
else
mSkippedToEquip = ptr;
if (isVisible())
{

@ -52,7 +52,12 @@ namespace MWWorld
}
}
assert(it != invStore.end());
if (it == invStore.end())
{
std::stringstream error;
error << "ActionEquip can't find item " << object.getCellRef().getRefId();
throw std::runtime_error(error.str());
}
// equip the item in the first free slot
std::vector<int>::const_iterator slot=slots_.first.begin();

Loading…
Cancel
Save