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/Globals/ObjectMgr.cpp | |
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/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index e31a650b1bb..8a3eb210e22 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -5330,12 +5330,12 @@ void ObjectMgr::LoadQuests() if (!spellInfo) continue; - for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j) + for (SpellEffectInfo const& spellEffectInfo : spellInfo->GetEffects()) { - if (spellInfo->Effects[j].Effect != SPELL_EFFECT_QUEST_COMPLETE) + if (spellEffectInfo.Effect != SPELL_EFFECT_QUEST_COMPLETE) continue; - uint32 quest_id = spellInfo->Effects[j].MiscValue; + uint32 quest_id = spellEffectInfo.MiscValue; Quest const* quest = GetQuestTemplate(quest_id); @@ -5733,10 +5733,16 @@ void ObjectMgr::LoadSpellScripts() continue; } - uint8 i = (uint8)((uint32(itr->first) >> 24) & 0x000000FF); + SpellEffIndex i = SpellEffIndex((uint32(itr->first) >> 24) & 0x000000FF); + if (uint32(i) > MAX_SPELL_EFFECTS) + { + TC_LOG_ERROR("sql.sql", "Table `spell_scripts` has too high effect index %u for spell (Id: %u) as script id", uint32(i), spellId); + continue; + } + //check for correct spellEffect - if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY)) - TC_LOG_ERROR("sql.sql", "Table `spell_scripts` - spell %u effect %u is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, i); + if (!spellInfo->GetEffect(i).Effect || (spellInfo->GetEffect(i).Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->GetEffect(i).Effect != SPELL_EFFECT_DUMMY)) + TC_LOG_ERROR("sql.sql", "Table `spell_scripts` - spell %u effect %u is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, uint32(i)); } } @@ -5753,10 +5759,10 @@ void ObjectMgr::LoadEventScripts() // Load all possible script entries from spells for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i) if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i)) - for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j) - if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT) - if (spell->Effects[j].MiscValue) - evt_scripts.insert(spell->Effects[j].MiscValue); + for (SpellEffectInfo const& spellEffectInfo : spell->GetEffects()) + if (spellEffectInfo.IsEffect(SPELL_EFFECT_SEND_EVENT)) + if (spellEffectInfo.MiscValue) + evt_scripts.insert(spellEffectInfo.MiscValue); for (size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx) { |