1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-15 22:16:35 +00:00

Move null checks to address feedback

This commit is contained in:
Evil Eye 2024-11-18 17:26:43 +01:00
parent d34aee6257
commit 35eed68269

View file

@ -1008,6 +1008,8 @@ namespace MWMechanics
void CharacterController::handleTextKey( void CharacterController::handleTextKey(
std::string_view groupname, SceneUtil::TextKeyMap::ConstIterator key, const SceneUtil::TextKeyMap& map) std::string_view groupname, SceneUtil::TextKeyMap::ConstIterator key, const SceneUtil::TextKeyMap& map)
{ {
if (!mAnimation)
return;
std::string_view evt = key->second; std::string_view evt = key->second;
MWBase::Environment::get().getLuaManager()->animationTextKey(mPtr, key->second); MWBase::Environment::get().getLuaManager()->animationTextKey(mPtr, key->second);
@ -1153,18 +1155,18 @@ namespace MWMechanics
mPtr, mAttackStrength, ESM::Weapon::AT_Thrust, mAttackVictim, mAttackHitPos, mAttackSuccess); mPtr, mAttackStrength, ESM::Weapon::AT_Thrust, mAttackVictim, mAttackHitPos, mAttackSuccess);
} }
} }
else if (action == "shoot attach" && mAnimation) else if (action == "shoot attach")
mAnimation->attachArrow(); mAnimation->attachArrow();
else if (action == "shoot release") else if (action == "shoot release")
{ {
// See notes for melee release above // See notes for melee release above
if (mReadyToHit && mAnimation) if (mAttackStrength != -1.f && mAnimation)
{ {
mAnimation->releaseArrow(mAttackStrength); mAnimation->releaseArrow(mAttackStrength);
mReadyToHit = false; mReadyToHit = false;
} }
} }
else if (action == "shoot follow attach" && mAnimation) else if (action == "shoot follow attach")
mAnimation->attachArrow(); mAnimation->attachArrow();
// Make sure this key is actually for the RangeType we are casting. The flame atronach has // Make sure this key is actually for the RangeType we are casting. The flame atronach has
// the same animation for all range types, so there are 3 "release" keys on the same time, one for each range // the same animation for all range types, so there are 3 "release" keys on the same time, one for each range
@ -1237,8 +1239,8 @@ namespace MWMechanics
float CharacterController::calculateWindUp() const float CharacterController::calculateWindUp() const
{ {
if (mCurrentWeapon.empty() || mWeaponType == ESM::Weapon::PickProbe || isRandomAttackAnimation(mCurrentWeapon) if (!mAnimation || mCurrentWeapon.empty() || mWeaponType == ESM::Weapon::PickProbe
|| !mAnimation) || isRandomAttackAnimation(mCurrentWeapon))
return -1.f; return -1.f;
float minAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon + ": " + mAttackType + " min attack"); float minAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon + ": " + mAttackType + " min attack");