From a4165325fa6e023d160e6212ac8c3c093190dfc9 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 25 Apr 2017 01:47:43 +0300 Subject: [PATCH] [Client] Improve synchronization of Actor swings --- apps/openmw/mwmechanics/aicombat.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 155776fcb..ebdcbe986 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -210,6 +210,24 @@ namespace MWMechanics storage.updateCombatMove(duration); if (storage.mReadyToAttack) updateActorsMovement(actor, duration, storage); storage.updateAttack(characterController); + + /* + Start of tes3mp addition + + Record that this actor is updating an attack so that a packet will be sent about it + */ + mwmp::Attack *localAttack = mwmp::Main::get().getMechanicsHelper()->getLocalAttack(actor); + + if (localAttack && localAttack->pressed != storage.mAttack) + { + mwmp::Main::get().getMechanicsHelper()->resetAttack(localAttack); + localAttack->type = mwmp::Attack::MELEE; + localAttack->pressed = storage.mAttack; + localAttack->shouldSend = true; + } + /* + End of tes3mp addition + */ } else { @@ -272,7 +290,7 @@ namespace MWMechanics */ mwmp::Attack *localAttack = mwmp::Main::get().getMechanicsHelper()->getLocalAttack(actor); - if (localAttack->pressed != false) + if (localAttack && localAttack->pressed != false) { mwmp::Main::get().getMechanicsHelper()->resetAttack(localAttack); localAttack->type = mwmp::Attack::MELEE; @@ -625,7 +643,7 @@ namespace MWMechanics */ mwmp::Attack *localAttack = mwmp::Main::get().getMechanicsHelper()->getLocalAttack(actor); - if (localAttack->pressed != true) + if (localAttack && localAttack->pressed != true) { mwmp::Main::get().getMechanicsHelper()->resetAttack(localAttack); localAttack->type = mwmp::Attack::MELEE;