diff options
| author | Shauren <shauren.trinity@gmail.com> | 2021-09-04 15:13:15 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-09-04 15:13:15 +0200 |
| commit | 8a4e1119ac21e2d1112d1717337597fe073e495f (patch) | |
| tree | 34f3215bec2096b59e3d9b2353661e1c137ff8b4 /src/server/game/AI/SmartScripts | |
| parent | 16ed458eeeebe436f05c43686928252992ae2a20 (diff) | |
Core/Spells: Unify spell effect access api in both branches
Diffstat (limited to 'src/server/game/AI/SmartScripts')
| -rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index f70b00e539b..266cfd08c56 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -1265,14 +1265,13 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) if (!IsSpellValid(e, e.action.cast.spell)) return false; - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(e.action.cast.spell, DIFFICULTY_NONE); - for (SpellEffectInfo const* effect : spellInfo->GetEffects()) + for (SpellEffectInfo const& spellEffectInfo : sSpellMgr->AssertSpellInfo(e.action.cast.spell, DIFFICULTY_NONE)->GetEffects()) { - if (effect && (effect->IsEffect(SPELL_EFFECT_KILL_CREDIT) || effect->IsEffect(SPELL_EFFECT_KILL_CREDIT2))) + if (spellEffectInfo.IsEffect(SPELL_EFFECT_KILL_CREDIT) || spellEffectInfo.IsEffect(SPELL_EFFECT_KILL_CREDIT2)) { - if (effect->TargetA.GetTarget() == TARGET_UNIT_CASTER) + if (spellEffectInfo.TargetA.GetTarget() == TARGET_UNIT_CASTER) TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u Effect: SPELL_EFFECT_KILL_CREDIT: (SpellId: %u targetA: %u - targetB: %u) has invalid target for this Action", - e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.cast.spell, effect->TargetA.GetTarget(), effect->TargetB.GetTarget()); + e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.cast.spell, spellEffectInfo.TargetA.GetTarget(), spellEffectInfo.TargetB.GetTarget()); } } break; @@ -1821,19 +1820,16 @@ void SmartAIMgr::LoadHelperStores() sSpellMgr->ForEachSpellInfo([this](SpellInfo const* spellInfo) { - for (SpellEffectInfo const* effect : spellInfo->GetEffects()) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { - if (!effect) - continue; - - if (effect->IsEffect(SPELL_EFFECT_SUMMON)) - SummonCreatureSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(spellInfo->Id, SpellEffIndex(effect->EffectIndex)))); - else if (effect->IsEffect(SPELL_EFFECT_SUMMON_OBJECT_WILD)) - SummonGameObjectSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(spellInfo->Id, SpellEffIndex(effect->EffectIndex)))); - else if (effect->IsEffect(SPELL_EFFECT_KILL_CREDIT) || effect->IsEffect(SPELL_EFFECT_KILL_CREDIT2)) - KillCreditSpellStore.insert(std::make_pair(uint32(effect->MiscValue), std::make_pair(spellInfo->Id, SpellEffIndex(effect->EffectIndex)))); - else if (effect->IsEffect(SPELL_EFFECT_CREATE_ITEM)) - CreateItemSpellStore.insert(std::make_pair(uint32(effect->ItemType), std::make_pair(spellInfo->Id, SpellEffIndex(effect->EffectIndex)))); + if (spellEffectInfo.IsEffect(SPELL_EFFECT_SUMMON)) + SummonCreatureSpellStore.insert(std::make_pair(uint32(spellEffectInfo.MiscValue), std::make_pair(spellInfo->Id, spellEffectInfo.EffectIndex))); + else if (spellEffectInfo.IsEffect(SPELL_EFFECT_SUMMON_OBJECT_WILD)) + SummonGameObjectSpellStore.insert(std::make_pair(uint32(spellEffectInfo.MiscValue), std::make_pair(spellInfo->Id, spellEffectInfo.EffectIndex))); + else if (spellEffectInfo.IsEffect(SPELL_EFFECT_KILL_CREDIT) || spellEffectInfo.IsEffect(SPELL_EFFECT_KILL_CREDIT2)) + KillCreditSpellStore.insert(std::make_pair(uint32(spellEffectInfo.MiscValue), std::make_pair(spellInfo->Id, spellEffectInfo.EffectIndex))); + else if (spellEffectInfo.IsEffect(SPELL_EFFECT_CREATE_ITEM)) + CreateItemSpellStore.insert(std::make_pair(uint32(spellEffectInfo.ItemType), std::make_pair(spellInfo->Id, spellEffectInfo.EffectIndex))); } }); |
