diff --git a/apps/openmw/mwrender/weaponanimation.cpp b/apps/openmw/mwrender/weaponanimation.cpp index d75c0ce5a..e36fd93ec 100644 --- a/apps/openmw/mwrender/weaponanimation.cpp +++ b/apps/openmw/mwrender/weaponanimation.cpp @@ -45,7 +45,12 @@ void WeaponAnimation::attachArrow(MWWorld::Ptr actor) { MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor); MWWorld::ContainerStoreIterator weaponSlot = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); - if (weaponSlot != inv.end() && weaponSlot->get()->mBase->mData.mType == ESM::Weapon::MarksmanThrown) + if (weaponSlot == inv.end()) + return; + if (weaponSlot->getTypeName() != typeid(ESM::Weapon).name()) + return; + int weaponType = weaponSlot->get()->mBase->mData.mType; + if (weaponType == ESM::Weapon::MarksmanThrown) { std::string soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot); if(!soundid.empty()) @@ -55,7 +60,7 @@ void WeaponAnimation::attachArrow(MWWorld::Ptr actor) } showWeapon(true); } - else + else if (weaponType == ESM::Weapon::MarksmanBow || weaponType == ESM::Weapon::MarksmanCrossbow) { NifOgre::ObjectScenePtr weapon = getWeapon(); if (!weapon.get()) @@ -81,6 +86,8 @@ void WeaponAnimation::releaseArrow(MWWorld::Ptr actor) MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight); if (weapon == inv.end()) return; + if (weapon->getTypeName() != typeid(ESM::Weapon).name()) + return; // The orientation of the launched projectile. Always the same as the actor orientation, even if the ArrowBone's orientation dictates otherwise. Ogre::Quaternion orient = Ogre::Quaternion(Ogre::Radian(actor.getRefData().getPosition().rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z) * diff --git a/apps/openmw/mwrender/weaponanimation.hpp b/apps/openmw/mwrender/weaponanimation.hpp index cbe910c71..e1ccd9465 100644 --- a/apps/openmw/mwrender/weaponanimation.hpp +++ b/apps/openmw/mwrender/weaponanimation.hpp @@ -35,8 +35,11 @@ namespace MWRender WeaponAnimation() : mPitchFactor(0) {} virtual ~WeaponAnimation() {} - virtual void attachArrow(MWWorld::Ptr actor); - virtual void releaseArrow(MWWorld::Ptr actor); + /// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op. + void attachArrow(MWWorld::Ptr actor); + + /// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op. + void releaseArrow(MWWorld::Ptr actor); protected: NifOgre::ObjectScenePtr mAmmunition;