forked from teamnwah/openmw-tes3coop
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::InventoryStore& inv = actor.getClass().getInventoryStore(actor);
|
||||||
MWWorld::ContainerStoreIterator weaponSlot = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
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);
|
std::string soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot);
|
||||||
if(!soundid.empty())
|
if(!soundid.empty())
|
||||||
|
@ -55,7 +60,7 @@ void WeaponAnimation::attachArrow(MWWorld::Ptr actor)
|
||||||
}
|
}
|
||||||
showWeapon(true);
|
showWeapon(true);
|
||||||
}
|
}
|
||||||
else
|
else if (weaponType == ESM::Weapon::MarksmanBow || weaponType == ESM::Weapon::MarksmanCrossbow)
|
||||||
{
|
{
|
||||||
NifOgre::ObjectScenePtr weapon = getWeapon();
|
NifOgre::ObjectScenePtr weapon = getWeapon();
|
||||||
if (!weapon.get())
|
if (!weapon.get())
|
||||||
|
@ -81,6 +86,8 @@ void WeaponAnimation::releaseArrow(MWWorld::Ptr actor)
|
||||||
MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
if (weapon == inv.end())
|
if (weapon == inv.end())
|
||||||
return;
|
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.
|
// 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) *
|
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) {}
|
WeaponAnimation() : mPitchFactor(0) {}
|
||||||
virtual ~WeaponAnimation() {}
|
virtual ~WeaponAnimation() {}
|
||||||
|
|
||||||
virtual void attachArrow(MWWorld::Ptr actor);
|
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
|
||||||
virtual void releaseArrow(MWWorld::Ptr actor);
|
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:
|
protected:
|
||||||
NifOgre::ObjectScenePtr mAmmunition;
|
NifOgre::ObjectScenePtr mAmmunition;
|
||||||
|
|
Loading…
Reference in a new issue