forked from mirror/openmw-tes3mp
Fix crash when onPcEquip script removes the equipped item (Fixes #3016)
This commit is contained in:
parent
1b77428c59
commit
edfcb45ad7
2 changed files with 15 additions and 8 deletions
|
@ -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);
|
||||
if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0)
|
||||
{
|
||||
boost::shared_ptr<MWWorld::Action> action = ptr.getClass().use(ptr);
|
||||
|
||||
action->execute (player);
|
||||
|
||||
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…
Reference in a new issue