From 7d221509cd345357308ee3607c3417820dc0d31a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 10 Sep 2018 12:02:21 +0300 Subject: [PATCH] [Client] Move item magic hook to correct location Previously, synchronization for strike enchantments was partially broken because it triggered the sending of ITEM_MAGIC attack packets, which are only supposed to be sent when a spell is cast from a magical inventory item. --- apps/openmw/mwmechanics/spellcasting.cpp | 19 ------------------- apps/openmw/mwworld/worldimp.cpp | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 060db70f9..deb24dbdc 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -938,25 +938,6 @@ namespace MWMechanics else if (isProjectile || !mTarget.isEmpty()) inflict(mTarget, mCaster, enchantment->mEffects, ESM::RT_Target); - /* - Start of tes3mp addition - - If this mCaster belongs to a LocalPlayer or LocalActor, get their Attack and prepare - it for sending - */ - mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(mCaster); - - if (localAttack) - { - MechanicsHelper::resetAttack(localAttack); - localAttack->type = mwmp::Attack::ITEM_MAGIC; - localAttack->itemId = item.getCellRef().getRefId(); - localAttack->shouldSend = true; - } - /* - End of tes3mp addition - */ - return true; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 2b7830a4e..0f0e16a6b 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -19,6 +19,7 @@ #include "../mwmp/DedicatedActor.hpp" #include "../mwmp/ObjectList.hpp" #include "../mwmp/CellController.hpp" +#include "../mwmp/MechanicsHelper.hpp" /* End of tes3mp addition */ @@ -3260,7 +3261,28 @@ namespace MWWorld { MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor); if (inv.getSelectedEnchantItem() != inv.end()) + /* + Start of tes3mp change (minor) + + If this actor is a LocalPlayer or LocalActor, get their Attack and prepare + it for sending + */ + { cast.cast(*inv.getSelectedEnchantItem()); + + mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(actor); + + if (localAttack) + { + MechanicsHelper::resetAttack(localAttack); + localAttack->type = mwmp::Attack::ITEM_MAGIC; + localAttack->itemId = inv.getSelectedEnchantItem()->getCellRef().getRefId(); + localAttack->shouldSend = true; + } + } + /* + End of tes3mp addition + */ } }