aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp60
1 files changed, 34 insertions, 26 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 76fa55b4a1c..e2f7e32c46b 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -7950,6 +7950,9 @@ int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const
bool Unit::IsImmunedToDamage(SpellSchoolMask schoolMask) const
{
+ if (schoolMask == SPELL_SCHOOL_MASK_NONE)
+ return false;
+
// If m_immuneToSchool type contain this school type, IMMUNE damage.
uint32 schoolImmunityMask = GetSchoolImmunityMask();
if ((schoolImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
@@ -7975,22 +7978,24 @@ bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const
if (spellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) || spellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
return false;
- uint32 schoolMask = spellInfo->GetSchoolMask();
- // If m_immuneToSchool type contain this school type, IMMUNE damage.
- uint32 schoolImmunityMask = 0;
- SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
- for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr)
- if ((itr->first & schoolMask) && !spellInfo->CanPierceImmuneAura(sSpellMgr->GetSpellInfo(itr->second)))
- schoolImmunityMask |= itr->first;
+ if (uint32 schoolMask = spellInfo->GetSchoolMask())
+ {
+ // If m_immuneToSchool type contain this school type, IMMUNE damage.
+ uint32 schoolImmunityMask = 0;
+ SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
+ for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr)
+ if ((itr->first & schoolMask) && !spellInfo->CanPierceImmuneAura(sSpellMgr->GetSpellInfo(itr->second)))
+ schoolImmunityMask |= itr->first;
- // // We need to be immune to all types
- if ((schoolImmunityMask & schoolMask) == schoolMask)
- return true;
+ // // We need to be immune to all types
+ if ((schoolImmunityMask & schoolMask) == schoolMask)
+ return true;
- // If m_immuneToDamage type contain magic, IMMUNE damage.
- uint32 damageImmunityMask = GetDamageImmunityMask();
- if ((damageImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
- return true;
+ // If m_immuneToDamage type contain magic, IMMUNE damage.
+ uint32 damageImmunityMask = GetDamageImmunityMask();
+ if ((damageImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
+ return true;
+ }
return false;
}
@@ -8041,21 +8046,24 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
if (immuneToAllEffects) //Return immune only if the target is immune to all spell effects.
return true;
- uint32 schoolImmunityMask = 0;
- SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
- for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr)
+ if (uint32 schoolMask = spellInfo->GetSchoolMask())
{
- if ((itr->first & spellInfo->GetSchoolMask()) == 0)
- continue;
+ uint32 schoolImmunityMask = 0;
+ SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL];
+ for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr)
+ {
+ if ((itr->first & schoolMask) == 0)
+ continue;
- SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->second);
- if (!(immuneSpellInfo && immuneSpellInfo->IsPositive() && spellInfo->IsPositive() && caster && IsFriendlyTo(caster)))
- if (!spellInfo->CanPierceImmuneAura(immuneSpellInfo))
- schoolImmunityMask |= itr->first;
- }
+ SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->second);
+ if (!(immuneSpellInfo && immuneSpellInfo->IsPositive() && spellInfo->IsPositive() && caster && IsFriendlyTo(caster)))
+ if (!spellInfo->CanPierceImmuneAura(immuneSpellInfo))
+ schoolImmunityMask |= itr->first;
+ }
- if ((schoolImmunityMask & spellInfo->GetSchoolMask()) == spellInfo->GetSchoolMask())
- return true;
+ if ((schoolImmunityMask & schoolMask) == schoolMask)
+ return true;
+ }
return false;
}