1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-31 14:36:41 +00:00

Merge pull request #804 from zelurker/improves_interetercontext_updateptr_again_for_scrawl

improves InterpreterContext::updatePtr
This commit is contained in:
scrawl 2015-11-12 18:15:18 +01:00
commit f5d90f7d98
3 changed files with 13 additions and 12 deletions

View file

@ -601,9 +601,9 @@ namespace MWScript
return mTargetId; return mTargetId;
} }
void InterpreterContext::updatePtr(const MWWorld::Ptr& updated) void InterpreterContext::updatePtr(const MWWorld::Ptr& base, const MWWorld::Ptr& updated)
{ {
if (!mReference.isEmpty()) if (!mReference.isEmpty() && base == mReference)
mReference = updated; mReference = updated;
} }
} }

View file

@ -167,7 +167,7 @@ namespace MWScript
MWWorld::Ptr getReference(bool required=true); MWWorld::Ptr getReference(bool required=true);
///< Reference, that the script is running from (can be empty) ///< Reference, that the script is running from (can be empty)
void updatePtr(const MWWorld::Ptr& updated); void updatePtr(const MWWorld::Ptr& base, const MWWorld::Ptr& updated);
///< Update the Ptr stored in mReference, if there is one stored there. Should be called after the reference has been moved to a new cell. ///< Update the Ptr stored in mReference, if there is one stored there. Should be called after the reference has been moved to a new cell.
virtual std::string getTargetId() const; virtual std::string getTargetId() const;

View file

@ -232,7 +232,7 @@ namespace MWScript
else else
throw std::runtime_error ("invalid axis: " + axis); throw std::runtime_error ("invalid axis: " + axis);
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(updated); dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr,updated);
} }
}; };
@ -312,9 +312,9 @@ namespace MWScript
} }
if(store) if(store)
{ {
MWWorld::Ptr base = ptr;
ptr = MWBase::Environment::get().getWorld()->moveObject(ptr,store,x,y,z); ptr = MWBase::Environment::get().getWorld()->moveObject(ptr,store,x,y,z);
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(base,ptr);
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr);
float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]); float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]);
float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]); float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]);
@ -360,6 +360,7 @@ namespace MWScript
// another morrowind oddity: player will be moved to the exterior cell at this location, // another morrowind oddity: player will be moved to the exterior cell at this location,
// non-player actors will move within the cell they are in. // non-player actors will move within the cell they are in.
MWWorld::Ptr base = ptr;
if (ptr == MWMechanics::getPlayer()) if (ptr == MWMechanics::getPlayer())
{ {
MWWorld::CellStore* cell = MWBase::Environment::get().getWorld()->getExterior(cx,cy); MWWorld::CellStore* cell = MWBase::Environment::get().getWorld()->getExterior(cx,cy);
@ -369,7 +370,7 @@ namespace MWScript
{ {
ptr = MWBase::Environment::get().getWorld()->moveObject(ptr, x, y, z); ptr = MWBase::Environment::get().getWorld()->moveObject(ptr, x, y, z);
} }
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr); dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(base,ptr);
float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]); float ax = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[0]);
float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]); float ay = osg::RadiansToDegrees(ptr.getRefData().getPosition().rot[1]);
@ -626,7 +627,7 @@ namespace MWScript
MWBase::Environment::get().getWorld()->rotateObject(ptr, xr, yr, zr); MWBase::Environment::get().getWorld()->rotateObject(ptr, xr, yr, zr);
dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr( dynamic_cast<MWScript::InterpreterContext&>(runtime.getContext()).updatePtr(ptr,
MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().pos[0], MWBase::Environment::get().getWorld()->moveObject(ptr, ptr.getCellRef().getPosition().pos[0],
ptr.getCellRef().getPosition().pos[1], ptr.getCellRef().getPosition().pos[2])); ptr.getCellRef().getPosition().pos[1], ptr.getCellRef().getPosition().pos[2]));