From b595586bf053e6638b3e11edca0d97094cd7332d Mon Sep 17 00:00:00 2001 From: Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> Date: Wed, 28 Aug 2024 07:13:42 -0400 Subject: [PATCH] refactor(Core/SpellMgr): Remove nested ifs for binary evaluation. (#19762) * Init. Co-Authored-By: Anton Popovichenko * Whitespace. * Tiny nitpick. Co-Authored-By: Anton Popovichenko * Tiny nitpick.* Today Bench learns the difference between break and continue. Co-Authored-By: Anton Popovichenko * Parentheses warnings. * Apply suggestion. Co-Authored-By: Anton Popovichenko --------- Co-authored-by: Anton Popovichenko --- src/server/game/Spells/SpellMgr.cpp | 32 +++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 3511aa90e..2e3c2d2ce 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3065,17 +3065,27 @@ void SpellMgr::LoadSpellInfoCustomAttributes() continue; [[fallthrough]]; /// @todo: Not sure whether the fallthrough was a mistake (forgetting a break) or intended. This should be double-checked. default: - if (spellInfo->Effects[j].CalcValue() || ((spellInfo->Effects[j].Effect == SPELL_EFFECT_INTERRUPT_CAST || spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH)) && !spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))) - if (spellInfo->Id != 69649 && spellInfo->Id != 71056 && spellInfo->Id != 71057 && spellInfo->Id != 71058 && spellInfo->Id != 73061 && spellInfo->Id != 73062 && spellInfo->Id != 73063 && spellInfo->Id != 73064) // Sindragosa Frost Breath - if (spellInfo->SpellFamilyName != SPELLFAMILY_MAGE || !(spellInfo->SpellFamilyFlags[0] & 0x20)) // frostbolt - if (spellInfo->Id != 55095) // frost fever - if (spellInfo->SpellFamilyName != SPELLFAMILY_WARLOCK || !(spellInfo->SpellFamilyFlags[1] & 0x40000)) // Haunt - if (spellInfo->SpellFamilyName != SPELLFAMILY_WARLOCK || !(spellInfo->SpellFamilyFlags[0] & 0x4000)) // Drain Soul - { - spellInfo->AttributesCu |= SPELL_ATTR0_CU_BINARY_SPELL; - break; - } - continue; + if (!(spellInfo->Effects[j].CalcValue() && + ((spellInfo->Effects[j].Effect == SPELL_EFFECT_INTERRUPT_CAST || spellInfo->HasAttribute(SPELL_ATTR0_CU_DONT_BREAK_STEALTH)) && + !spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES)))) + continue; + + if (spellInfo->Id == 69649 || spellInfo->Id == 71056 || spellInfo->Id == 71057 || spellInfo->Id == 71058 || + spellInfo->Id == 73061 || spellInfo->Id == 73062 || spellInfo->Id == 73063 || spellInfo->Id == 73064) + continue; + + if (spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (spellInfo->SpellFamilyFlags[0] & 0x20)) // Frostbolt + continue; + + if (spellInfo->Id == 55095) // Frost Fever + continue; + + if (spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK && + ((spellInfo->SpellFamilyFlags[1] & 0x40000) || (spellInfo->SpellFamilyFlags[0] & 0x4000))) // Haunt/Drain Soul + continue; + + spellInfo->AttributesCu |= SPELL_ATTR0_CU_BINARY_SPELL; + break; } } }