From d2178e5414a4232f0316c4788e8203adc68652af Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 16 Apr 2017 17:09:47 +0300 Subject: [PATCH] [Client] Assign LocalActor movement settings before rotations get reset --- apps/openmw/mwmechanics/character.cpp | 39 ++++++++++++++------------- apps/openmw/mwmp/LocalActor.cpp | 6 ++--- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index b9da153b8..e1c44acfd 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1661,6 +1661,26 @@ void CharacterController::update(float duration) if(mHitState != CharState_None && mJumpState == JumpState_None) vec = osg::Vec3f(0.f, 0.f, 0.f); + + /* + Start of tes3mp addition + + Character movement setting rotations get reset here, so we have to assign movement + settings to a relevant LocalActor now + */ + if (isLocalActor) + { + localActor->direction.pos[0] = cls.getMovementSettings(mPtr).mPosition[0]; + localActor->direction.pos[1] = cls.getMovementSettings(mPtr).mPosition[1]; + localActor->direction.pos[2] = cls.getMovementSettings(mPtr).mPosition[2]; + localActor->direction.rot[0] = cls.getMovementSettings(mPtr).mRotation[0]; + localActor->direction.rot[1] = cls.getMovementSettings(mPtr).mRotation[1]; + localActor->direction.rot[2] = cls.getMovementSettings(mPtr).mRotation[2]; + } + /* + End of tes3mp addition + */ + osg::Vec3f rot = cls.getRotationVector(mPtr); speed = cls.getSpeed(mPtr); @@ -1947,25 +1967,6 @@ void CharacterController::update(float duration) movement = vec; - /* - Start of tes3mp addition - - Character movement setting positions get reset here, so we have to assign them to a - relevant LocalActor now - */ - if (isLocalActor) - { - localActor->direction.pos[0] = cls.getMovementSettings(mPtr).mPosition[0]; - localActor->direction.pos[1] = cls.getMovementSettings(mPtr).mPosition[1]; - localActor->direction.pos[2] = cls.getMovementSettings(mPtr).mPosition[2]; - localActor->direction.rot[0] = cls.getMovementSettings(mPtr).mRotation[0]; - localActor->direction.rot[1] = cls.getMovementSettings(mPtr).mRotation[1]; - localActor->direction.rot[2] = cls.getMovementSettings(mPtr).mRotation[2]; - } - /* - End of tes3mp addition - */ - cls.getMovementSettings(mPtr).mPosition[0] = cls.getMovementSettings(mPtr).mPosition[1] = 0; // Can't reset jump state (mPosition[2]) here; we don't know for sure whether the PhysicSystem will actually handle it in this frame diff --git a/apps/openmw/mwmp/LocalActor.cpp b/apps/openmw/mwmp/LocalActor.cpp index 6db117b38..8a86f9b50 100644 --- a/apps/openmw/mwmp/LocalActor.cpp +++ b/apps/openmw/mwmp/LocalActor.cpp @@ -172,7 +172,7 @@ void LocalActor::setPtr(const MWWorld::Ptr& newPtr) mpNum = ptr.getCellRef().getMpNum(); lastDrawState = ptr.getClass().getNpcStats(ptr).getDrawState(); - oldHealth = *(&ptr.getClass().getCreatureStats(ptr).getHealth()); - oldMagicka = *(&ptr.getClass().getCreatureStats(ptr).getMagicka()); - oldFatigue = *(&ptr.getClass().getCreatureStats(ptr).getFatigue()); + oldHealth = ptr.getClass().getCreatureStats(ptr).getHealth(); + oldMagicka = ptr.getClass().getCreatureStats(ptr).getMagicka(); + oldFatigue = ptr.getClass().getCreatureStats(ptr).getFatigue(); }