mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 02:15:32 +00:00
Fix attachArrow exception when changing weapon (Fixes #2332)
This commit is contained in:
parent
fec8cf91f5
commit
56799c79f4
2 changed files with 14 additions and 4 deletions
|
@ -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<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanThrown)
|
||||
if (weaponSlot == inv.end())
|
||||
return;
|
||||
if (weaponSlot->getTypeName() != typeid(ESM::Weapon).name())
|
||||
return;
|
||||
int weaponType = weaponSlot->get<ESM::Weapon>()->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) *
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue