From 490303dc0bef1d7ef31ef21ab165723fc2de3c11 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 15 Sep 2018 04:11:43 +0300 Subject: [PATCH] [Client] Clean up MechanicsHelper::processAttack() slightly The debug is now more descriptive and some code is now skipped for non-ranged attacks. --- apps/openmw/mwmp/MechanicsHelper.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwmp/MechanicsHelper.cpp b/apps/openmw/mwmp/MechanicsHelper.cpp index af903657f..f10db42a7 100644 --- a/apps/openmw/mwmp/MechanicsHelper.cpp +++ b/apps/openmw/mwmp/MechanicsHelper.cpp @@ -222,10 +222,11 @@ bool MechanicsHelper::getSpellSuccess(std::string spellId, const MWWorld::Ptr& c void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker) { + LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Processing attack from %s of type %i", + attacker.getClass().getName(attacker).c_str(), attack.type); + if (!attack.pressed) { - LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Processing attack from %s of type %i", - attacker.getCellRef().getRefId().c_str(), attack.type); LOG_APPEND(Log::LOG_VERBOSE, "- success: %s", attack.success ? "true" : "false"); if (attack.success) @@ -266,12 +267,16 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker) MWWorld::InventoryStore &inventoryStore = attacker.getClass().getInventoryStore(attacker); MWWorld::ContainerStoreIterator weaponSlot = inventoryStore.getSlot( MWWorld::InventoryStore::Slot_CarriedRight); - MWWorld::ContainerStoreIterator projectileSlot = inventoryStore.getSlot( - MWWorld::InventoryStore::Slot_Ammunition); - // TODO: Fix for when arrows, bolts and throwing weapons have just run out weapon = weaponSlot != inventoryStore.end() ? *weaponSlot : MWWorld::Ptr(); - projectile = projectileSlot != inventoryStore.end() ? *projectileSlot : MWWorld::Ptr(); + + if (isRanged) + { + // TODO: Fix for when arrows, bolts and throwing weapons have just run out + MWWorld::ContainerStoreIterator projectileSlot = inventoryStore.getSlot( + MWWorld::InventoryStore::Slot_Ammunition); + projectile = projectileSlot != inventoryStore.end() ? *projectileSlot : MWWorld::Ptr(); + } if (!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name()) weapon = MWWorld::Ptr();