diff options
| author | Shauren <shauren.trinity@gmail.com> | 2021-08-31 00:13:44 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-08-31 00:13:44 +0200 |
| commit | e50102178b8d794991968649807156eac0ade5a0 (patch) | |
| tree | 5aef233d7ec9c026ef41e6773fd778d3003ac25a /src/server/game/Entities/Player | |
| parent | 665f215486ebe89801a557580e9b51cc23959f25 (diff) | |
Core/Spells: Spell effect info access refactoring part 3 - removed direct SpellInfo::Effects field access from game
Diffstat (limited to 'src/server/game/Entities/Player')
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e7fd4ab5b53..f8d90a45e39 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -3457,9 +3457,9 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent LearnDefaultSkill(pSkill->ID, 0); if (pSkill->ID == SKILL_MOUNTS && !Has310Flyer(false)) - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && - spellInfo->Effects[i].CalcValue() == 310) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) + if (spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && + spellEffectInfo.CalcValue() == 310) SetHas310Flyer(true); } } @@ -3531,9 +3531,9 @@ bool Player::HandlePassiveSpellLearn(SpellInfo const* spellInfo) // passive spells which apply aura and have an item requirement are to be added manually, instead of casted if (spellInfo->EquippedItemClass >= 0) { - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { - if (spellInfo->Effects[i].IsAura()) + if (spellEffectInfo.IsAura()) { if (!HasAura(spellInfo->Id) && HasItemFitToSpellRequirements(spellInfo)) AddAura(spellInfo->Id, this); @@ -3706,10 +3706,10 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) if (_spell_idx->second->SkillLine == SKILL_MOUNTS) { - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { - if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && - spellInfo->Effects[i].CalcValue() == 310) + if (spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && + spellEffectInfo.CalcValue() == 310) { Has310Flyer(true, spell_id); // with true as first argument its also used to set/remove the flag break; @@ -3813,13 +3813,15 @@ bool Player::Has310Flyer(bool checkAllSpells, uint32 excludeSpellId) break; // We can break because mount spells belong only to one skillline (at least 310 flyers do) spellInfo = sSpellMgr->AssertSpellInfo(itr->first); - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && - spellInfo->Effects[i].CalcValue() == 310) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) + { + if (spellEffectInfo.ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && + spellEffectInfo.CalcValue() == 310) { SetHas310Flyer(true); return true; } + } } } } @@ -3934,9 +3936,9 @@ bool Player::ResetTalents(bool no_cost) continue; RemoveSpell(talentInfo->SpellRank[rank], true); // search for spells that the talent teaches and unlearn them - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (_spellEntry->Effects[i].TriggerSpell > 0 && _spellEntry->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL) - RemoveSpell(_spellEntry->Effects[i].TriggerSpell, true); + for (SpellEffectInfo const& spellEffectInfo : _spellEntry->GetEffects()) + if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && spellEffectInfo.TriggerSpell > 0) + RemoveSpell(spellEffectInfo.TriggerSpell, true); // if this talent rank can be found in the PlayerTalentMap, mark the talent as removed so it gets deleted PlayerTalentMap::iterator plrTalent = m_talents[m_activeSpec]->find(talentInfo->SpellRank[rank]); if (plrTalent != m_talents[m_activeSpec]->end()) @@ -8065,11 +8067,9 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT int32 const effectPct = std::max(0, 100 - (lvlDifference * lvlPenaltyFactor)); - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - { - if (spellInfo->Effects[i].IsEffect()) - args.AddSpellMod(static_cast<SpellValueMod>(SPELLVALUE_BASE_POINT0 + i), CalculatePct(spellInfo->Effects[i].CalcValue(this), effectPct)); - } + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) + if (spellEffectInfo.IsEffect()) + args.AddSpellMod(static_cast<SpellValueMod>(SPELLVALUE_BASE_POINT0 + spellEffectInfo.EffectIndex), CalculatePct(spellEffectInfo.CalcValue(this), effectPct)); } CastSpell(target, spellInfo->Id, args); } @@ -23100,9 +23100,9 @@ void Player::LearnQuestRewardedSpells(Quest const* quest) // check learned spells state bool found = false; - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { - if (spellInfo->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->Effects[i].TriggerSpell)) + if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && !HasSpell(spellEffectInfo.TriggerSpell)) { found = true; break; @@ -23113,7 +23113,7 @@ void Player::LearnQuestRewardedSpells(Quest const* quest) if (!found) return; - uint32 learned_0 = spellInfo->Effects[0].TriggerSpell; + uint32 learned_0 = spellInfo->GetEffect(EFFECT_0).TriggerSpell; if (!HasSpell(learned_0)) { SpellInfo const* learnedInfo = sSpellMgr->GetSpellInfo(learned_0); @@ -23121,7 +23121,7 @@ void Player::LearnQuestRewardedSpells(Quest const* quest) return; // profession specialization can be re-learned from npc - if (learnedInfo->Effects[0].Effect == SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effects[1].Effect == 0 && !learnedInfo->SpellLevel) + if (learnedInfo->GetEffect(EFFECT_0).Effect == SPELL_EFFECT_TRADE_SKILL && learnedInfo->GetEffect(EFFECT_1).Effect == 0 && !learnedInfo->SpellLevel) return; } @@ -23720,11 +23720,9 @@ bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item cons // special check to filter things like Shield Wall, the aura is not permanent and must stay even without required item if (!spellInfo->IsPassive()) - { - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (spellInfo->Effects[i].IsAura()) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) + if (spellEffectInfo.IsAura()) return true; - } } // tabard not have dependent spells @@ -26127,9 +26125,9 @@ void Player::ActivateSpec(uint8 spec) continue; RemoveSpell(talentInfo->SpellRank[rank], true); // removes the talent, and all dependant, learned, and chained spells.. if (SpellInfo const* _spellEntry = sSpellMgr->GetSpellInfo(talentInfo->SpellRank[rank])) - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) // search through the SpellInfo for valid trigger spells - if (_spellEntry->Effects[i].TriggerSpell > 0 && _spellEntry->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL) - RemoveSpell(_spellEntry->Effects[i].TriggerSpell, true); // and remove any spells that the talent teaches + for (SpellEffectInfo const& spellEffectInfo : _spellEntry->GetEffects()) // search through the SpellInfo for valid trigger spells + if (spellEffectInfo.IsEffect(SPELL_EFFECT_LEARN_SPELL) && spellEffectInfo.TriggerSpell > 0) + RemoveSpell(spellEffectInfo.TriggerSpell, true); // and remove any spells that the talent teaches // if this talent rank can be found in the PlayerTalentMap, mark the talent as removed so it gets deleted //PlayerTalentMap::iterator plrTalent = m_talents[m_activeSpec]->find(talentInfo->RankID[rank]); //if (plrTalent != m_talents[m_activeSpec]->end()) |
