diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Battlegrounds/Battleground.cpp | 17 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 30 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 44 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.h | 4 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 92 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 29 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 5 |
10 files changed, 104 insertions, 129 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 62a42db2192..a910df7b0a9 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -553,20 +553,15 @@ inline void Battleground::_ProcessJoin(uint32 diff) if (!player->IsGameMaster()) { // remove auras with duration lower than 30s - Unit::AuraApplicationMap & auraMap = player->GetAppliedAuras(); - for (Unit::AuraApplicationMap::iterator iter = auraMap.begin(); iter != auraMap.end();) + player->RemoveAppliedAuras([](AuraApplication const* aurApp) { - AuraApplication * aurApp = iter->second; Aura* aura = aurApp->GetBase(); - if (!aura->IsPermanent() - && aura->GetDuration() <= 30*IN_MILLISECONDS + return !aura->IsPermanent() + && aura->GetDuration() <= 30 * IN_MILLISECONDS && aurApp->IsPositive() - && (!(aura->GetSpellInfo()->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)) - && (!aura->HasEffectType(SPELL_AURA_MOD_INVISIBILITY))) - player->RemoveAura(iter); - else - ++iter; - } + && !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) + && !aura->HasEffectType(SPELL_AURA_MOD_INVISIBILITY); + }); } } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a04a4fa397e..d4cd8a7ba09 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3624,7 +3624,7 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId // Call OnDispel hook on AuraScript aura->CallScriptDispel(&dispelInfo); - if (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) + if (aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES)) aura->ModCharges(-dispelInfo.GetRemovedCharges(), AURA_REMOVE_BY_ENEMY_SPELL); else aura->ModStackAmount(-dispelInfo.GetRemovedCharges(), AURA_REMOVE_BY_ENEMY_SPELL); @@ -3669,7 +3669,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, U } } - bool stealCharge = (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) != 0; + bool stealCharge = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES); // Cast duration to unsigned to prevent permanent aura's such as Righteous Fury being permanently added to caster uint32 dur = std::min(2u * MINUTE * IN_MILLISECONDS, uint32(aura->GetDuration())); @@ -3932,17 +3932,13 @@ void Unit::RemoveArenaAuras() { // in join, remove positive buffs, on end, remove negative // used to remove positive visible auras in arenas - for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) + RemoveAppliedAuras([](AuraApplication const* aurApp) { - AuraApplication const* aurApp = iter->second; Aura const* aura = aurApp->GetBase(); - if (!(aura->GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_UNK21) // don't remove stances, shadowform, pally/hunter auras - && !aura->IsPassive() // don't remove passive auras - && (aurApp->IsPositive() || !(aura->GetSpellInfo()->AttributesEx3 & SPELL_ATTR3_DEATH_PERSISTENT))) // not negative death persistent auras - RemoveAura(iter); - else - ++iter; - } + return !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR4_UNK21) // don't remove stances, shadowform, pally/hunter auras + && !aura->IsPassive() // don't remove passive auras + && (aurApp->IsPositive() || !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR3_DEATH_PERSISTENT)); // not negative death persistent auras + }); } void Unit::RemoveAurasOnEvade() @@ -4201,8 +4197,8 @@ void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelCharges // The charges / stack amounts don't count towards the total number of auras that can be dispelled. // Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell // Polymorph instead of 1 / (5 + 1) -> 16%. - bool dispel_charges = (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) != 0; - uint8 charges = dispel_charges ? aura->GetCharges() : aura->GetStackAmount(); + bool dispelCharges = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES); + uint8 charges = dispelCharges ? aura->GetCharges() : aura->GetStackAmount(); if (charges > 0) dispelList.push_back(std::make_pair(aura, charges)); } @@ -7914,7 +7910,7 @@ float Unit::SpellDamagePctDone(Unit* victim, SpellInfo const* spellProto, Damage { if ((*i)->GetSpellInfo()->EquippedItemClass == -1) AddPct(DoneTotalMod, (*i)->GetAmount()); - else if (!((*i)->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0)) + else if (!(*i)->GetSpellInfo()->HasAttribute(SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0)) AddPct(DoneTotalMod, (*i)->GetAmount()); else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo())) AddPct(DoneTotalMod, (*i)->GetAmount()); @@ -8886,7 +8882,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType { if ((*i)->GetSpellInfo()->EquippedItemClass == -1) AddPct(DoneTotalMod, (*i)->GetAmount()); - else if (!((*i)->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0)) + else if (!(*i)->GetSpellInfo()->HasAttribute(SPELL_ATTR5_SPECIAL_ITEM_CLASS_CHECK) && ((*i)->GetSpellInfo()->EquippedItemSubClassMask == 0)) AddPct(DoneTotalMod, (*i)->GetAmount()); else if (ToPlayer() && ToPlayer()->HasItemFitToSpellRequirements((*i)->GetSpellInfo())) AddPct(DoneTotalMod, (*i)->GetAmount()); @@ -10479,7 +10475,7 @@ void Unit::ModSpellCastTime(SpellInfo const* spellInfo, int32 & castTime, Spell* if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, castTime, spell); - if (!((spellInfo->Attributes & (SPELL_ATTR0_ABILITY | SPELL_ATTR0_TRADESPELL)) || (spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS))) && + if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) castTime = int32(float(castTime) * GetFloatValue(UNIT_MOD_CAST_SPEED)); else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG)) @@ -13973,7 +13969,7 @@ Aura* Unit::AddAura(uint32 spellId, Unit* target) if (!spellInfo) return NULL; - if (!target->IsAlive() && !spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_DEAD)) + if (!target->IsAlive() && !spellInfo->IsPassive() && !spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_DEAD)) return NULL; return AddAura(spellInfo, MAX_EFFECT_MASK, target); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 26618e63680..96e2a18a4cc 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -1357,7 +1357,7 @@ void AuraEffect::HandleShapeshiftBoosts(Unit* target, bool apply) const continue; SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); - if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR0_PASSIVE | SPELL_ATTR0_HIDDEN_CLIENTSIDE))) + if (!spellInfo || !(spellInfo->IsPassive() || spellInfo->HasAttribute(SPELL_ATTR0_HIDDEN_CLIENTSIDE))) continue; if ((spellInfo->HasAttribute(SPELL_ATTR8_MASTERY_SPECIALIZATION)) && !plrTarget->IsCurrentSpecMasterySpell(spellInfo)) @@ -3408,7 +3408,7 @@ void AuraEffect::HandleModStateImmunityMask(AuraApplication const* aurApp, uint8 for (std::list <AuraType>::iterator iter = aura_immunity_list.begin(); iter != aura_immunity_list.end(); ++iter) target->ApplySpellImmune(GetId(), IMMUNITY_STATE, *iter, apply); - if (apply && GetSpellInfo()->AttributesEx & SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY) + if (apply && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)) { target->RemoveAurasWithMechanic(mechanic_immunity_list, AURA_REMOVE_BY_DEFAULT, GetId()); for (std::list <AuraType>::iterator iter = aura_immunity_list.begin(); iter != aura_immunity_list.end(); ++iter) @@ -3465,7 +3465,7 @@ void AuraEffect::HandleModMechanicImmunity(AuraApplication const* aurApp, uint8 break; } - if (apply && GetSpellInfo()->AttributesEx & SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY) + if (apply && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)) target->RemoveAurasWithMechanic(mechanic, AURA_REMOVE_BY_DEFAULT, GetId()); } @@ -3501,7 +3501,7 @@ void AuraEffect::HandleAuraModStateImmunity(AuraApplication const* aurApp, uint8 target->ApplySpellImmune(GetId(), IMMUNITY_STATE, GetMiscValue(), apply); - if (apply && GetSpellInfo()->AttributesEx & SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY) + if (apply && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY)) target->RemoveAurasByType(AuraType(GetMiscValue()), ObjectGuid::Empty, GetBase()); } @@ -3537,30 +3537,24 @@ void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); // remove all flag auras (they are positive, but they must be removed when you are immune) - if (GetSpellInfo()->AttributesEx & SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY - && GetSpellInfo()->AttributesEx2 & SPELL_ATTR2_DAMAGE_REDUCED_SHIELD) + if (GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY) + && GetSpellInfo()->HasAttribute(SPELL_ATTR2_DAMAGE_REDUCED_SHIELD)) target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); /// @todo optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else - if ((apply) - && GetSpellInfo()->AttributesEx & SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY - && GetSpellInfo()->IsPositive()) //Only positive immunity removes auras + if (apply + && GetSpellInfo()->HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY) + && GetSpellInfo()->IsPositive()) // Only positive immunity removes auras { - uint32 school_mask = GetMiscValue(); - Unit::AuraApplicationMap& Auras = target->GetAppliedAuras(); - for (Unit::AuraApplicationMap::iterator iter = Auras.begin(); iter != Auras.end();) + uint32 schoolMask = GetMiscValue(); + target->RemoveAppliedAuras([this, schoolMask](AuraApplication const* aurApp) { - SpellInfo const* spell = iter->second->GetBase()->GetSpellInfo(); - if ((spell->GetSchoolMask() & school_mask)//Check for school mask + SpellInfo const* spell = aurApp->GetBase()->GetSpellInfo(); + return (spell->GetSchoolMask() & schoolMask) // Check for school mask && GetSpellInfo()->CanDispelAura(spell) - && !iter->second->IsPositive() //Don't remove positive spells - && spell->Id != GetId()) //Don't remove self - { - target->RemoveAura(iter); - } - else - ++iter; - } + && !aurApp->IsPositive() // Don't remove positive spells + && spell->Id != GetId(); // Don't remove self + }); } } @@ -6015,7 +6009,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const int32 dmg = damage; - if (!(GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_FIXED_DAMAGE)) + if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE)) caster->ApplyResilience(target, &dmg); damage = dmg; @@ -6113,7 +6107,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c damage = caster->SpellCriticalDamageBonus(m_spellInfo, damage, target); int32 dmg = damage; - if (!(GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_FIXED_DAMAGE)) + if (!GetSpellInfo()->HasAttribute(SPELL_ATTR4_FIXED_DAMAGE)) caster->ApplyResilience(target, &dmg); damage = dmg; @@ -6197,7 +6191,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const } // heal for caster damage (must be alive) - if (target != caster && GetSpellInfo()->AttributesEx2 & SPELL_ATTR2_HEALTH_FUNNEL && !caster->IsAlive()) + if (target != caster && GetSpellInfo()->HasAttribute(SPELL_ATTR2_HEALTH_FUNNEL) && !caster->IsAlive()) return; // don't regen when permanent aura target has full power diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index fefdcc96030..147d127543c 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -181,7 +181,7 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo auraData.SpellID = aura->GetId(); auraData.SpellXSpellVisualID = aura->GetSpellXSpellVisualId(); auraData.Flags = GetFlags(); - if (aura->GetMaxDuration() > 0 && !(aura->GetSpellInfo()->AttributesEx5 & SPELL_ATTR5_HIDE_DURATION)) + if (aura->GetMaxDuration() > 0 && !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR5_HIDE_DURATION)) auraData.Flags |= AFLAG_DURATION; auraData.ActiveFlags = GetEffectMask(); diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 172210a80cb..a282cf4f136 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -195,8 +195,8 @@ class TC_GAME_API Aura { return GetCasterGUID() == target->GetGUID() && m_spellInfo->Stances - && !(m_spellInfo->AttributesEx2 & SPELL_ATTR2_NOT_NEED_SHAPESHIFT) - && !(m_spellInfo->Attributes & SPELL_ATTR0_NOT_SHAPESHIFT); + && !m_spellInfo->HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT) + && !m_spellInfo->HasAttribute(SPELL_ATTR0_NOT_SHAPESHIFT); } bool CanBeSaved() const; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 961d077d83e..6c84bf3e964 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4712,7 +4712,7 @@ void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOT SpellCastResult Spell::CheckCast(bool strict) { // check death state - if (!m_caster->IsAlive() && !m_spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE) && !((m_spellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD)) || (IsTriggered() && !m_triggeredByAuraSpell))) + if (!m_caster->IsAlive() && !m_spellInfo->IsPassive() && !(m_spellInfo->HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_DEAD) || (IsTriggered() && !m_triggeredByAuraSpell))) return SPELL_FAILED_CASTER_DEAD; // check cooldowns to prevent cheating @@ -4876,7 +4876,7 @@ SpellCastResult Spell::CheckCast(bool strict) // those spells may have incorrect target entries or not filled at all (for example 15332) // such spells when learned are not targeting anyone using targeting system, they should apply directly to caster instead // also, such casts shouldn't be sent to client - if (!((m_spellInfo->HasAttribute(SPELL_ATTR0_PASSIVE)) && (!m_targets.GetUnitTarget() || m_targets.GetUnitTarget() == m_caster))) + if (!(m_spellInfo->IsPassive() && (!m_targets.GetUnitTarget() || m_targets.GetUnitTarget() == m_caster))) { // Check explicit target for m_originalCaster - todo: get rid of such workarounds SpellCastResult castResult = m_spellInfo->CheckExplicitTarget(m_originalCaster ? m_originalCaster : m_caster, m_targets.GetObjectTarget(), m_targets.GetItemTarget()); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index a2ab004e4ec..227b26531ae 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -4987,14 +4987,14 @@ void Spell::EffectStealBeneficialBuff(SpellEffIndex /*effIndex*/) if ((aura->GetSpellInfo()->GetDispelMask()) & dispelMask) { // Need check for passive? this - if (!aurApp->IsPositive() || aura->IsPassive() || aura->GetSpellInfo()->AttributesEx4 & SPELL_ATTR4_NOT_STEALABLE) + if (!aurApp->IsPositive() || aura->IsPassive() || aura->GetSpellInfo()->HasAttribute(SPELL_ATTR4_NOT_STEALABLE)) continue; // The charges / stack amounts don't count towards the total number of auras that can be dispelled. // Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell // Polymorph instead of 1 / (5 + 1) -> 16%. - bool dispel_charges = (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES) != 0; - uint8 charges = dispel_charges ? aura->GetCharges() : aura->GetStackAmount(); + bool dispelCharges = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES); + uint8 charges = dispelCharges ? aura->GetCharges() : aura->GetStackAmount(); if (charges > 0) steal_list.push_back(std::make_pair(aura, charges)); } diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index b2ab5a8a57e..64f089cf56a 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1363,14 +1363,14 @@ bool SpellInfo::NeedsToBeTriggeredByCaster(SpellInfo const* triggeringSpell, uin bool SpellInfo::IsPassive() const { - return (Attributes & SPELL_ATTR0_PASSIVE) != 0; + return HasAttribute(SPELL_ATTR0_PASSIVE); } bool SpellInfo::IsAutocastable() const { - if (Attributes & SPELL_ATTR0_PASSIVE) + if (IsPassive()) return false; - if (AttributesEx & SPELL_ATTR1_UNAUTOCASTABLE_BY_PET) + if (HasAttribute(SPELL_ATTR1_UNAUTOCASTABLE_BY_PET)) return false; return true; } @@ -1419,12 +1419,12 @@ bool SpellInfo::IsMultiSlotAura() const bool SpellInfo::IsStackableOnOneSlotWithDifferentCasters() const { /// TODO: Re-verify meaning of SPELL_ATTR3_STACK_FOR_DIFF_CASTERS and update conditions here - return StackAmount > 1 && !IsChanneled() && !(AttributesEx3 & SPELL_ATTR3_STACK_FOR_DIFF_CASTERS); + return StackAmount > 1 && !IsChanneled() && !HasAttribute(SPELL_ATTR3_STACK_FOR_DIFF_CASTERS); } bool SpellInfo::IsCooldownStartedOnEvent() const { - if (Attributes & SPELL_ATTR0_DISABLED_WHILE_ACTIVE) + if (HasAttribute(SPELL_ATTR0_DISABLED_WHILE_ACTIVE)) return true; SpellCategoryEntry const* category = sSpellCategoryStore.LookupEntry(CategoryId); @@ -1433,27 +1433,27 @@ bool SpellInfo::IsCooldownStartedOnEvent() const bool SpellInfo::IsDeathPersistent() const { - return (AttributesEx3 & SPELL_ATTR3_DEATH_PERSISTENT) != 0; + return HasAttribute(SPELL_ATTR3_DEATH_PERSISTENT); } bool SpellInfo::IsRequiringDeadTarget() const { - return (AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_GHOSTS) != 0; + return HasAttribute(SPELL_ATTR3_ONLY_TARGET_GHOSTS); } bool SpellInfo::IsAllowingDeadTarget() const { - return AttributesEx2 & SPELL_ATTR2_CAN_TARGET_DEAD || Targets & (TARGET_FLAG_CORPSE_ALLY | TARGET_FLAG_CORPSE_ENEMY | TARGET_FLAG_UNIT_DEAD); + return HasAttribute(SPELL_ATTR2_CAN_TARGET_DEAD) || Targets & (TARGET_FLAG_CORPSE_ALLY | TARGET_FLAG_CORPSE_ENEMY | TARGET_FLAG_UNIT_DEAD); } bool SpellInfo::CanBeUsedInCombat() const { - return !(Attributes & SPELL_ATTR0_CANT_USED_IN_COMBAT); + return !HasAttribute(SPELL_ATTR0_CANT_USED_IN_COMBAT); } bool SpellInfo::IsPositive() const { - return !(AttributesCu & SPELL_ATTR0_CU_NEGATIVE); + return !HasAttribute(SPELL_ATTR0_CU_NEGATIVE); } bool SpellInfo::IsPositiveEffect(uint8 effIndex) const @@ -1462,27 +1462,27 @@ bool SpellInfo::IsPositiveEffect(uint8 effIndex) const { default: case 0: - return !(AttributesCu & SPELL_ATTR0_CU_NEGATIVE_EFF0); + return !HasAttribute(SPELL_ATTR0_CU_NEGATIVE_EFF0); case 1: - return !(AttributesCu & SPELL_ATTR0_CU_NEGATIVE_EFF1); + return !HasAttribute(SPELL_ATTR0_CU_NEGATIVE_EFF1); case 2: - return !(AttributesCu & SPELL_ATTR0_CU_NEGATIVE_EFF2); + return !HasAttribute(SPELL_ATTR0_CU_NEGATIVE_EFF2); } } bool SpellInfo::IsChanneled() const { - return (AttributesEx & (SPELL_ATTR1_CHANNELED_1 | SPELL_ATTR1_CHANNELED_2)) != 0; + return HasAttribute(SPELL_ATTR1_CHANNELED_1) || HasAttribute(SPELL_ATTR1_CHANNELED_2); } bool SpellInfo::NeedsComboPoints() const { - return (AttributesEx & (SPELL_ATTR1_REQ_COMBO_POINTS1 | SPELL_ATTR1_REQ_COMBO_POINTS2)) != 0; + return HasAttribute(SPELL_ATTR1_REQ_COMBO_POINTS1) || HasAttribute(SPELL_ATTR1_REQ_COMBO_POINTS2); } bool SpellInfo::IsBreakingStealth() const { - return !(AttributesEx & SPELL_ATTR1_NOT_BREAK_STEALTH); + return !HasAttribute(SPELL_ATTR1_NOT_BREAK_STEALTH); } bool SpellInfo::IsRangedWeaponSpell() const @@ -1493,7 +1493,7 @@ bool SpellInfo::IsRangedWeaponSpell() const bool SpellInfo::IsAutoRepeatRangedSpell() const { - return (AttributesEx2 & SPELL_ATTR2_AUTOREPEAT_FLAG) != 0; + return HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG); } bool SpellInfo::HasInitialAggro() const @@ -1503,7 +1503,7 @@ bool SpellInfo::HasInitialAggro() const bool SpellInfo::IsAffectedBySpellMods() const { - return !(AttributesEx3 & SPELL_ATTR3_NO_DONE_BONUS); + return !HasAttribute(SPELL_ATTR3_NO_DONE_BONUS); } bool SpellInfo::IsAffectedBySpellMod(SpellModifier const* mod) const @@ -1526,11 +1526,11 @@ bool SpellInfo::IsAffectedBySpellMod(SpellModifier const* mod) const bool SpellInfo::CanPierceImmuneAura(SpellInfo const* aura) const { // these spells pierce all avalible spells (Resurrection Sickness for example) - if (Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) + if (HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)) return true; // these spells (Cyclone for example) can pierce all... // ...but not these (Divine shield, Ice block, Cyclone and Banish for example) - if ((AttributesEx & SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) && !(aura && (aura->Mechanic == MECHANIC_IMMUNE_SHIELD || aura->Mechanic == MECHANIC_INVULNERABILITY || aura->Mechanic == MECHANIC_BANISH))) + if (HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) && !(aura && (aura->Mechanic == MECHANIC_IMMUNE_SHIELD || aura->Mechanic == MECHANIC_INVULNERABILITY || aura->Mechanic == MECHANIC_BANISH))) return true; return false; @@ -1539,7 +1539,7 @@ bool SpellInfo::CanPierceImmuneAura(SpellInfo const* aura) const bool SpellInfo::CanDispelAura(SpellInfo const* aura) const { // These spells (like Mass Dispel) can dispell all auras, except death persistent ones (like Dungeon and Battleground Deserter) - if (Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY && !aura->IsDeathPersistent()) + if (HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) && !aura->IsDeathPersistent()) return true; // These auras (like Divine Shield) can't be dispelled @@ -1556,7 +1556,7 @@ bool SpellInfo::CanDispelAura(SpellInfo const* aura) const bool SpellInfo::IsSingleTarget() const { // all other single target spells have if it has AttributesEx5 - if (AttributesEx5 & SPELL_ATTR5_SINGLE_TARGET_SPELL) + if (HasAttribute(SPELL_ATTR5_SINGLE_TARGET_SPELL)) return true; switch (GetSpellSpecific()) @@ -1657,7 +1657,7 @@ SpellCastResult SpellInfo::CheckShapeshift(uint32 form) const if (actAsShifted) { - if (Attributes & SPELL_ATTR0_NOT_SHAPESHIFT || (shapeInfo && shapeInfo->Flags & SHAPESHIFT_FORM_PREVENT_USING_OWN_SKILLS)) // not while shapeshifted + if (HasAttribute(SPELL_ATTR0_NOT_SHAPESHIFT) || (shapeInfo && shapeInfo->Flags & SHAPESHIFT_FORM_PREVENT_USING_OWN_SKILLS)) // not while shapeshifted return SPELL_FAILED_NOT_SHAPESHIFT; else if (Stances != 0) // needs other shapeshift return SPELL_FAILED_ONLY_SHAPESHIFT; @@ -1665,7 +1665,7 @@ SpellCastResult SpellInfo::CheckShapeshift(uint32 form) const else { // needs shapeshift - if (!(AttributesEx2 & SPELL_ATTR2_NOT_NEED_SHAPESHIFT) && Stances != 0) + if (!HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT) && Stances != 0) return SPELL_FAILED_ONLY_SHAPESHIFT; } @@ -1693,7 +1693,7 @@ SpellCastResult SpellInfo::CheckLocation(uint32 map_id, uint32 zone_id, uint32 a } // continent limitation (virtual continent) - if (AttributesEx4 & SPELL_ATTR4_CAST_ONLY_IN_OUTLAND) + if (HasAttribute(SPELL_ATTR4_CAST_ONLY_IN_OUTLAND)) { uint32 v_map = sDB2Manager.GetVirtualMapForMapAndZone(map_id, zone_id); MapEntry const* mapEntry = sMapStore.LookupEntry(v_map); @@ -1702,7 +1702,7 @@ SpellCastResult SpellInfo::CheckLocation(uint32 map_id, uint32 zone_id, uint32 a } // raid instance limitation - if (AttributesEx6 & SPELL_ATTR6_NOT_IN_RAID_INSTANCE) + if (HasAttribute(SPELL_ATTR6_NOT_IN_RAID_INSTANCE)) { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry || mapEntry->IsRaid()) @@ -1825,11 +1825,11 @@ SpellCastResult SpellInfo::CheckLocation(uint32 map_id, uint32 zone_id, uint32 a SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* target, bool implicit) const { - if (AttributesEx & SPELL_ATTR1_CANT_TARGET_SELF && caster == target) + if (HasAttribute(SPELL_ATTR1_CANT_TARGET_SELF) && caster == target) return SPELL_FAILED_BAD_TARGETS; // check visibility - ignore stealth for implicit (area) targets - if (!(AttributesEx6 & SPELL_ATTR6_CAN_TARGET_INVISIBLE) && !caster->CanSeeOrDetect(target, implicit)) + if (!HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE) && !caster->CanSeeOrDetect(target, implicit)) return SPELL_FAILED_BAD_TARGETS; Unit const* unitTarget = target->ToUnit(); @@ -1837,7 +1837,7 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta // creature/player specific target checks if (unitTarget) { - if (AttributesEx & SPELL_ATTR1_CANT_TARGET_IN_COMBAT) + if (HasAttribute(SPELL_ATTR1_CANT_TARGET_IN_COMBAT)) { if (unitTarget->IsInCombat()) return SPELL_FAILED_TARGET_AFFECTING_COMBAT; @@ -1849,9 +1849,9 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta } // only spells with SPELL_ATTR3_ONLY_TARGET_GHOSTS can target ghosts - if (((AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_GHOSTS) != 0) != unitTarget->HasAuraType(SPELL_AURA_GHOST)) + if (HasAttribute(SPELL_ATTR3_ONLY_TARGET_GHOSTS) != unitTarget->HasAuraType(SPELL_AURA_GHOST)) { - if (AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_GHOSTS) + if (HasAttribute(SPELL_ATTR3_ONLY_TARGET_GHOSTS)) return SPELL_FAILED_TARGET_NOT_GHOST; else return SPELL_FAILED_BAD_TARGETS; @@ -1862,12 +1862,12 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta if (caster->GetTypeId() == TYPEID_PLAYER) { // Do not allow these spells to target creatures not tapped by us (Banish, Polymorph, many quest spells) - if (AttributesEx2 & SPELL_ATTR2_CANT_TARGET_TAPPED) + if (HasAttribute(SPELL_ATTR2_CANT_TARGET_TAPPED)) if (Creature const* targetCreature = unitTarget->ToCreature()) if (targetCreature->hasLootRecipient() && !targetCreature->isTappedBy(caster->ToPlayer())) return SPELL_FAILED_CANT_CAST_ON_TAPPED; - if (AttributesCu & SPELL_ATTR0_CU_PICKPOCKET) + if (HasAttribute(SPELL_ATTR0_CU_PICKPOCKET)) { if (unitTarget->GetTypeId() == TYPEID_PLAYER) return SPELL_FAILED_BAD_TARGETS; @@ -1907,21 +1907,21 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta else return SPELL_CAST_OK; // corpseOwner and unit specific target checks - if (AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS && !unitTarget->ToPlayer()) + if (HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS) && unitTarget->GetTypeId() != TYPEID_PLAYER) return SPELL_FAILED_TARGET_NOT_PLAYER; if (!IsAllowingDeadTarget() && !unitTarget->IsAlive()) return SPELL_FAILED_TARGETS_DEAD; // check this flag only for implicit targets (chain and area), allow to explicitly target units for spells like Shield of Righteousness - if (implicit && AttributesEx6 & SPELL_ATTR6_CANT_TARGET_CROWD_CONTROLLED && !unitTarget->CanFreeMove()) + if (implicit && HasAttribute(SPELL_ATTR6_CANT_TARGET_CROWD_CONTROLLED) && !unitTarget->CanFreeMove()) return SPELL_FAILED_BAD_TARGETS; // checked in Unit::IsValidAttack/AssistTarget, shouldn't be checked for ENTRY targets - //if (!(AttributesEx6 & SPELL_ATTR6_CAN_TARGET_UNTARGETABLE) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) + //if (!HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) // return SPELL_FAILED_BAD_TARGETS; - //if (!(AttributesEx6 & SPELL_ATTR6_CAN_TARGET_POSSESSED_FRIENDS) + //if (!HasAttribute(SPELL_ATTR6_CAN_TARGET_POSSESSED_FRIENDS)) if (!CheckTargetCreatureType(unitTarget)) { @@ -1942,7 +1942,7 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta } // not allow casting on flying player - if (unitTarget->HasUnitState(UNIT_STATE_IN_FLIGHT) && !(AttributesCu & SPELL_ATTR0_CU_ALLOW_INFLIGHT_TARGET)) + if (unitTarget->HasUnitState(UNIT_STATE_IN_FLIGHT) && !HasAttribute(SPELL_ATTR0_CU_ALLOW_INFLIGHT_TARGET)) return SPELL_FAILED_BAD_TARGETS; /* TARGET_UNIT_MASTER gets blocked here for passengers, because the whole idea of this check is to @@ -2044,7 +2044,7 @@ SpellCastResult SpellInfo::CheckVehicle(Unit const* caster) const checkMask = VEHICLE_SEAT_FLAG_CAN_ATTACK; VehicleSeatEntry const* vehicleSeat = vehicle->GetSeatForPassenger(caster); - if (!(AttributesEx6 & SPELL_ATTR6_CASTABLE_WHILE_ON_VEHICLE) && !(Attributes & SPELL_ATTR0_CASTABLE_WHILE_MOUNTED) + if (!HasAttribute(SPELL_ATTR6_CASTABLE_WHILE_ON_VEHICLE) && !HasAttribute(SPELL_ATTR0_CASTABLE_WHILE_MOUNTED) && (vehicleSeat->Flags[0] & checkMask) != checkMask) return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; @@ -2491,7 +2491,7 @@ uint32 SpellInfo::CalcCastTime(uint8 level, Spell* spell /*= NULL*/) const if (spell) spell->GetCaster()->ModSpellCastTime(this, castTime, spell); - if (Attributes & SPELL_ATTR0_REQ_AMMO && (!IsAutoRepeatRangedSpell()) && !(AttributesEx9 & SPELL_ATTR9_AIMED_SHOT)) + if (HasAttribute(SPELL_ATTR0_REQ_AMMO) && !IsAutoRepeatRangedSpell() && !HasAttribute(SPELL_ATTR9_AIMED_SHOT)) castTime += 500; return (castTime > 0) ? uint32(castTime) : 0; @@ -2544,7 +2544,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp continue; // Spell drain all exist power on cast (Only paladin lay of Hands) - if (AttributesEx & SPELL_ATTR1_DRAIN_ALL_POWER) + if (HasAttribute(SPELL_ATTR1_DRAIN_ALL_POWER)) { // If power type - health drain all if (power->PowerType == POWER_HEALTH) @@ -2612,7 +2612,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp } // Shiv - costs 20 + weaponSpeed*10 energy (apply only to non-triggered spell with energy cost) - if (AttributesEx4 & SPELL_ATTR4_SPELL_VS_EXTEND_COST) + if (HasAttribute(SPELL_ATTR4_SPELL_VS_EXTEND_COST)) { uint32 speed = 0; if (SpellShapeshiftFormEntry const* ss = sSpellShapeshiftFormStore.LookupEntry(caster->GetShapeshiftForm())) @@ -2620,7 +2620,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp else { WeaponAttackType slot = BASE_ATTACK; - if (AttributesEx3 & SPELL_ATTR3_REQ_OFFHAND) + if (HasAttribute(SPELL_ATTR3_REQ_OFFHAND)) slot = OFF_ATTACK; speed = caster->GetAttackTime(slot); @@ -2640,7 +2640,7 @@ std::vector<SpellInfo::CostData> SpellInfo::CalcPowerCost(Unit const* caster, Sp if (!caster->IsControlledByPlayer() && G3D::fuzzyEq(power->ManaCostPercentage, 0.0f) && SpellLevel) { - if (Attributes & SPELL_ATTR0_LEVEL_DAMAGE_CALCULATION) + if (HasAttribute(SPELL_ATTR0_LEVEL_DAMAGE_CALCULATION)) { GtNpcManaCostScalerEntry const* spellScaler = sNpcManaCostScalerGameTable.GetRow(SpellLevel); GtNpcManaCostScalerEntry const* casterScaler = sNpcManaCostScalerGameTable.GetRow(caster->getLevel()); @@ -3015,7 +3015,7 @@ void SpellInfo::_InitializeExplicitTargetMask() bool SpellInfo::_IsPositiveEffect(uint32 effIndex, bool deep) const { // not found a single positive spell with this attribute - if (Attributes & SPELL_ATTR0_NEGATIVE_1) + if (HasAttribute(SPELL_ATTR0_NEGATIVE_1)) return false; switch (SpellFamilyName) @@ -3208,7 +3208,7 @@ bool SpellInfo::_IsPositiveEffect(uint32 effIndex, bool deep) const if (effect->TargetA.GetTarget() != TARGET_UNIT_CASTER) return false; // but not this if this first effect (didn't find better check) - if (Attributes & SPELL_ATTR0_NEGATIVE_1 && effIndex == 0) + if (HasAttribute(SPELL_ATTR0_NEGATIVE_1) && effIndex == 0) return false; break; case SPELL_AURA_MECHANIC_IMMUNITY: diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index a34836ad42a..40dcbd90c10 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3487,13 +3487,9 @@ void SpellMgr::LoadPetFamilySpellsStore() if (!levels->DifficultyID) levelsBySpell[levels->SpellID] = levels; - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) + for (SkillLineAbilityEntry const* skillLine : sSkillLineAbilityStore) { - SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j); - if (!skillLine) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->SpellID); + SpellInfo const* spellInfo = GetSpellInfo(skillLine->SpellID); if (!spellInfo) continue; @@ -3501,24 +3497,17 @@ void SpellMgr::LoadPetFamilySpellsStore() if (levels != levelsBySpell.end() && levels->second->SpellLevel) continue; - if (SpellMiscEntry const* spellMisc = sSpellMiscStore.LookupEntry(spellInfo->MiscID)) + if (spellInfo->IsPassive()) { - if (spellMisc->Attributes & SPELL_ATTR0_PASSIVE) + for (CreatureFamilyEntry const* cFamily : sCreatureFamilyStore) { - for (uint32 i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i) - { - CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(i); - if (!cFamily) - continue; - - if (skillLine->SkillLine != cFamily->SkillLine[0] && skillLine->SkillLine != cFamily->SkillLine[1]) - continue; + if (skillLine->SkillLine != cFamily->SkillLine[0] && skillLine->SkillLine != cFamily->SkillLine[1]) + continue; - if (skillLine->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN) - continue; + if (skillLine->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN) + continue; - sPetFamilySpellsStore[i].insert(spellInfo->ID); - } + sPetFamilySpellsStore[cFamily->ID].insert(spellInfo->Id); } } } diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 9461a3fac60..677b40da524 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1534,8 +1534,6 @@ void World::SetInitialWorldSettings() //Load weighted graph on taxi nodes path sTaxiPathGraph.Initialize(); - sSpellMgr->LoadPetFamilySpellsStore(); - std::unordered_map<uint32, std::vector<uint32>> mapData; for (MapEntry const* mapEntry : sMapStore) { @@ -1562,6 +1560,9 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading SpellInfo custom attributes..."); sSpellMgr->LoadSpellInfoCustomAttributes(); + TC_LOG_INFO("server.loading", "Loading PetFamilySpellsStore Data..."); + sSpellMgr->LoadPetFamilySpellsStore(); + TC_LOG_INFO("server.loading", "Loading GameObject models..."); LoadGameObjectModelList(m_dataPath); |