From 41dc409238c59d9159f5f6aa95cb99b9cb7ef40d Mon Sep 17 00:00:00 2001
From: Evil Eye <malusluminis@hotmail.com>
Date: Sat, 9 Dec 2023 18:20:10 +0100
Subject: [PATCH] Don't consider empty effect lists exceptional

---
 apps/openmw/mwmechanics/character.cpp | 104 ++++++++++++++------------
 1 file changed, 55 insertions(+), 49 deletions(-)

diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp
index 262283b365..713add719b 100644
--- a/apps/openmw/mwmechanics/character.cpp
+++ b/apps/openmw/mwmechanics/character.cpp
@@ -1605,61 +1605,67 @@ namespace MWMechanics
                             effects = &spell->mEffects.mList;
                             cast.playSpellCastingEffects(spell);
                         }
-                        if (mCanCast && !effects->empty())
+                        if (!effects->empty())
                         {
-                            const ESM::MagicEffect* effect = store.get<ESM::MagicEffect>().find(
-                                effects->back().mEffectID); // use last effect of list for color of VFX_Hands
-
-                            const ESM::Static* castStatic
-                                = world->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Hands"));
-
-                            const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
-
-                            if (mAnimation->getNode("Bip01 L Hand"))
-                                mAnimation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs),
-                                    -1, false, "Bip01 L Hand", effect->mParticle);
-
-                            if (mAnimation->getNode("Bip01 R Hand"))
-                                mAnimation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs),
-                                    -1, false, "Bip01 R Hand", effect->mParticle);
-                        }
-
-                        const ESM::ENAMstruct& firstEffect = effects->at(0); // first effect used for casting animation
-
-                        std::string startKey;
-                        std::string stopKey;
-                        if (isRandomAttackAnimation(mCurrentWeapon))
-                        {
-                            startKey = "start";
-                            stopKey = "stop";
                             if (mCanCast)
-                                world->castSpell(
-                                    mPtr, mCastingManualSpell); // No "release" text key to use, so cast immediately
-                            mCastingManualSpell = false;
-                            mCanCast = false;
-                        }
-                        else
-                        {
-                            switch (firstEffect.mRange)
                             {
-                                case 0:
-                                    mAttackType = "self";
-                                    break;
-                                case 1:
-                                    mAttackType = "touch";
-                                    break;
-                                case 2:
-                                    mAttackType = "target";
-                                    break;
+                                const ESM::MagicEffect* effect = store.get<ESM::MagicEffect>().find(
+                                    effects->back().mEffectID); // use last effect of list for color of VFX_Hands
+
+                                const ESM::Static* castStatic
+                                    = world->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Hands"));
+
+                                const VFS::Manager* const vfs
+                                    = MWBase::Environment::get().getResourceSystem()->getVFS();
+
+                                if (mAnimation->getNode("Bip01 L Hand"))
+                                    mAnimation->addEffect(
+                                        Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), -1, false,
+                                        "Bip01 L Hand", effect->mParticle);
+
+                                if (mAnimation->getNode("Bip01 R Hand"))
+                                    mAnimation->addEffect(
+                                        Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), -1, false,
+                                        "Bip01 R Hand", effect->mParticle);
+                            }
+                            // first effect used for casting animation
+                            const ESM::ENAMstruct& firstEffect = effects->front();
+
+                            std::string startKey;
+                            std::string stopKey;
+                            if (isRandomAttackAnimation(mCurrentWeapon))
+                            {
+                                startKey = "start";
+                                stopKey = "stop";
+                                if (mCanCast)
+                                    world->castSpell(
+                                        mPtr, mCastingManualSpell); // No "release" text key to use, so cast immediately
+                                mCastingManualSpell = false;
+                                mCanCast = false;
+                            }
+                            else
+                            {
+                                switch (firstEffect.mRange)
+                                {
+                                    case 0:
+                                        mAttackType = "self";
+                                        break;
+                                    case 1:
+                                        mAttackType = "touch";
+                                        break;
+                                    case 2:
+                                        mAttackType = "target";
+                                        break;
+                                }
+
+                                startKey = mAttackType + " start";
+                                stopKey = mAttackType + " stop";
                             }
 
-                            startKey = mAttackType + " start";
-                            stopKey = mAttackType + " stop";
+                            mAnimation->play(mCurrentWeapon, priorityWeapon, MWRender::Animation::BlendMask_All, false,
+                                1, startKey, stopKey, 0.0f, 0);
+                            mUpperBodyState = UpperBodyState::Casting;
                         }
-
-                        mAnimation->play(mCurrentWeapon, priorityWeapon, MWRender::Animation::BlendMask_All, false, 1,
-                            startKey, stopKey, 0.0f, 0);
-                        mUpperBodyState = UpperBodyState::Casting;
                     }
                     else
                     {