1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-29 09:32:45 +00:00

Update reference of the interpreter context when an Activate results in a take action (Fixes #3727)

This commit is contained in:
scrawl 2017-01-18 21:57:50 +01:00
parent 70c5f64caa
commit 45fb4f04b1
4 changed files with 14 additions and 2 deletions

View File

@ -480,6 +480,10 @@ namespace MWScript
{
boost::shared_ptr<MWWorld::Action> action = (ptr.getClass().activate(ptr, actor));
action->execute (actor);
if (action->getTarget() != MWWorld::Ptr() && action->getTarget() != ptr)
{
updatePtr(ptr, action->getTarget());
}
}
float InterpreterContext::getSecondsPassed() const

View File

@ -12,6 +12,11 @@ const MWWorld::Ptr& MWWorld::Action::getTarget() const
return mTarget;
}
void MWWorld::Action::setTarget(const MWWorld::Ptr& target)
{
mTarget = target;
}
MWWorld::Action::Action (bool keepSound, const Ptr& target) : mKeepSound (keepSound), mSoundOffset(0), mTarget (target)
{}

View File

@ -23,10 +23,12 @@ namespace MWWorld
protected:
const Ptr& getTarget() const;
void setTarget(const Ptr&);
public:
const Ptr& getTarget() const;
Action (bool keepSound = false, const Ptr& target = Ptr());
///< \param keepSound Keep playing the sound even if the object the sound is played on is removed.

View File

@ -16,7 +16,8 @@ namespace MWWorld
{
MWBase::Environment::get().getMechanicsManager()->itemTaken(
actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
setTarget(newitem);
}
}