aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2020-06-12 01:29:18 +0200
committerShauren <shauren.trinity@gmail.com>2020-06-12 01:29:18 +0200
commitc7306439e7004288fb85890d6a5f730cf1761d71 (patch)
treea1b6fd4af385923f321ff24ef4d66d09374397b9 /src/server/game/Globals/ObjectMgr.cpp
parent1cdd1d0249ad49c860e117e1e39d451e1a3fbe43 (diff)
Core/Spells: Implement using different difficulty data from all spell related db2s, not just SpellEffect and SpellPower
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 0b2b6ca4ae6..e38539429ae 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -639,14 +639,14 @@ void ObjectMgr::LoadCreatureTemplateAddons()
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
{
uint32 spellId = uint32(atoul(*itr));
- SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(spellId);
+ SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE);
if (!AdditionalSpellInfo)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has wrong spell %u defined in `auras` field in `creature_template_addon`.", entry, spellId);
continue;
}
- if (AdditionalSpellInfo->HasAura(DIFFICULTY_NONE, SPELL_AURA_CONTROL_VEHICLE))
+ if (AdditionalSpellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_template_addon`.", entry, spellId);
if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellId) != creatureAddon.auras.end())
@@ -1024,7 +1024,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
for (uint8 j = 0; j < MAX_CREATURE_SPELLS; ++j)
{
- if (cInfo->spells[j] && !sSpellMgr->GetSpellInfo(cInfo->spells[j]))
+ if (cInfo->spells[j] && !sSpellMgr->GetSpellInfo(cInfo->spells[j], DIFFICULTY_NONE))
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has non-existing Spell%d (%u), set to 0.", cInfo->Entry, j+1, cInfo->spells[j]);
const_cast<CreatureTemplate*>(cInfo)->spells[j] = 0;
@@ -1124,14 +1124,14 @@ void ObjectMgr::LoadCreatureAddons()
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
{
uint32 spellId = uint32(atoul(*itr));
- SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(spellId);
+ SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE);
if (!AdditionalSpellInfo)
{
TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has wrong spell %u defined in `auras` field in `creature_addon`.", guid, spellId);
continue;
}
- if (AdditionalSpellInfo->HasAura(DIFFICULTY_NONE, SPELL_AURA_CONTROL_VEHICLE))
+ if (AdditionalSpellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE))
TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_addon`.", guid, spellId);
if (std::find(creatureAddon.auras.begin(), creatureAddon.auras.end(), spellId) != creatureAddon.auras.end())
@@ -4273,7 +4273,7 @@ void ObjectMgr::LoadQuests()
if (qinfo->_sourceSpellID)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->_sourceSpellID);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->_sourceSpellID, DIFFICULTY_NONE);
if (!spellInfo)
{
TC_LOG_ERROR("sql.sql", "Quest %u has `SourceSpellid` = %u but spell %u doesn't exist, quest can't be done.",
@@ -4356,7 +4356,7 @@ void ObjectMgr::LoadQuests()
TC_LOG_ERROR("sql.sql", "Quest %u objective %u has invalid currency amount %d", qinfo->GetQuestId(), obj.ID, obj.Amount);
break;
case QUEST_OBJECTIVE_LEARNSPELL:
- if (!sSpellMgr->GetSpellInfo(obj.ObjectID))
+ if (!sSpellMgr->GetSpellInfo(obj.ObjectID, DIFFICULTY_NONE))
TC_LOG_ERROR("sql.sql", "Quest %u objective %u has non existing spell id %d", qinfo->GetQuestId(), obj.ID, obj.ObjectID);
break;
case QUEST_OBJECTIVE_WINPETBATTLEAGAINSTNPC:
@@ -4489,7 +4489,7 @@ void ObjectMgr::LoadQuests()
{
if (qinfo->RewardDisplaySpell[i])
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardDisplaySpell[i]);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewardDisplaySpell[i], DIFFICULTY_NONE);
if (!spellInfo)
{
@@ -4509,7 +4509,7 @@ void ObjectMgr::LoadQuests()
if (qinfo->_rewardSpell > 0)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->_rewardSpell);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->_rewardSpell, DIFFICULTY_NONE);
if (!spellInfo)
{
@@ -4679,13 +4679,13 @@ void ObjectMgr::LoadQuests()
}
// check QUEST_SPECIAL_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE
- for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
+ for (SpellNameEntry const* spellNameEntry : sSpellNameStore)
{
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(i);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellNameEntry->ID, DIFFICULTY_NONE);
if (!spellInfo)
continue;
- for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
+ for (SpellEffectInfo const* effect : spellInfo->GetEffects())
{
if (!effect || effect->Effect != SPELL_EFFECT_QUEST_COMPLETE)
continue;
@@ -5136,7 +5136,7 @@ void ObjectMgr::LoadScripts(ScriptsType type)
case SCRIPT_COMMAND_REMOVE_AURA:
{
- if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
+ if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID, DIFFICULTY_NONE))
{
TC_LOG_ERROR("sql.sql", "Table `%s` using non-existent spell (id: %u) in SCRIPT_COMMAND_REMOVE_AURA for script id %u",
tableName.c_str(), tmp.RemoveAura.SpellID, tmp.id);
@@ -5153,7 +5153,7 @@ void ObjectMgr::LoadScripts(ScriptsType type)
case SCRIPT_COMMAND_CAST_SPELL:
{
- if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
+ if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID, DIFFICULTY_NONE))
{
TC_LOG_ERROR("sql.sql", "Table `%s` using non-existent spell (id: %u) in SCRIPT_COMMAND_CAST_SPELL for script id %u",
tableName.c_str(), tmp.CastSpell.SpellID, tmp.id);
@@ -5239,7 +5239,7 @@ void ObjectMgr::LoadSpellScripts()
for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
{
uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE);
if (!spellInfo)
{
@@ -5267,9 +5267,9 @@ void ObjectMgr::LoadEventScripts()
evt_scripts.insert(eventId);
// Load all possible script entries from spells
- for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
- if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(i))
- for (SpellEffectInfo const* effect : spell->GetEffectsForDifficulty(DIFFICULTY_NONE))
+ for (SpellNameEntry const* spellNameEntry : sSpellNameStore)
+ if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(spellNameEntry->ID, DIFFICULTY_NONE))
+ for (SpellEffectInfo const* effect : spell->GetEffects())
if (effect && effect->Effect == SPELL_EFFECT_SEND_EVENT)
if (effect->MiscValue)
evt_scripts.insert(effect->MiscValue);
@@ -5358,7 +5358,7 @@ void ObjectMgr::LoadSpellScriptNames()
spellId = -spellId;
}
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE);
if (!spellInfo)
{
TC_LOG_ERROR("sql.sql", "Scriptname: `%s` spell (Id: %d) does not exist.", scriptName.c_str(), fields[0].GetInt32());
@@ -5410,7 +5410,7 @@ void ObjectMgr::ValidateSpellScripts()
for (auto spell : _spellScriptsStore)
{
- SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell.first);
+ SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell.first, DIFFICULTY_NONE);
auto const bounds = sObjectMgr->GetSpellScriptsBounds(spell.first);
@@ -5662,7 +5662,7 @@ void ObjectMgr::LoadInstanceEncounters()
break;
}
case ENCOUNTER_CREDIT_CAST_SPELL:
- if (!sSpellMgr->GetSpellInfo(creditEntry))
+ if (!sSpellMgr->GetSpellInfo(creditEntry, DIFFICULTY_NONE))
{
TC_LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry %u) linked to the encounter %u (%s), skipped!",
creditEntry, entry, dungeonEncounter->Name->Str[sWorld->GetDefaultDbcLocale()]);
@@ -6963,7 +6963,7 @@ inline void CheckGOLinkedTrapId(GameObjectTemplate const* goInfo, uint32 dataN,
inline void CheckGOSpellId(GameObjectTemplate const* goInfo, uint32 dataN, uint32 N)
{
- if (sSpellMgr->GetSpellInfo(dataN))
+ if (sSpellMgr->GetSpellInfo(dataN, DIFFICULTY_NONE))
return;
TC_LOG_ERROR("sql.sql", "Gameobject (Entry: %u GoType: %u) have data%d=%u but Spell (Entry %u) not exist.",
@@ -7798,7 +7798,7 @@ void ObjectMgr::LoadNPCSpellClickSpells()
}
uint32 spellid = fields[1].GetUInt32();
- SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid);
+ SpellInfo const* spellinfo = sSpellMgr->GetSpellInfo(spellid, DIFFICULTY_NONE);
if (!spellinfo)
{
TC_LOG_ERROR("sql.sql", "Table npc_spellclick_spells creature: %u references unknown spellid %u. Skipping entry.", npc_entry, spellid);
@@ -8637,7 +8637,7 @@ void ObjectMgr::LoadTrainers()
spell.ReqAbility[2] = fields[7].GetUInt32();
spell.ReqLevel = fields[8].GetUInt8();
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell.SpellId);
+ SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell.SpellId, DIFFICULTY_NONE);
if (!spellInfo)
{
TC_LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (SpellId: %u) for TrainerId %u, ignoring", spell.SpellId, trainerId);
@@ -8655,7 +8655,7 @@ void ObjectMgr::LoadTrainers()
for (std::size_t i = 0; i < spell.ReqAbility.size(); ++i)
{
uint32 requiredSpell = spell.ReqAbility[i];
- if (requiredSpell && !sSpellMgr->GetSpellInfo(requiredSpell))
+ if (requiredSpell && !sSpellMgr->GetSpellInfo(requiredSpell, DIFFICULTY_NONE))
{
TC_LOG_ERROR("sql.sql", "Table `trainer_spell` references non-existing spell (ReqAbility" SZFMTD ": %u) for TrainerId %u and SpellId %u, ignoring",
i + 1, requiredSpell, spell.SpellId, trainerId);
@@ -9471,9 +9471,9 @@ void ObjectMgr::LoadFactionChangeSpells()
uint32 alliance = fields[0].GetUInt32();
uint32 horde = fields[1].GetUInt32();
- if (!sSpellMgr->GetSpellInfo(alliance))
+ if (!sSpellMgr->GetSpellInfo(alliance, DIFFICULTY_NONE))
TC_LOG_ERROR("sql.sql", "Spell %u (alliance_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
- else if (!sSpellMgr->GetSpellInfo(horde))
+ else if (!sSpellMgr->GetSpellInfo(horde, DIFFICULTY_NONE))
TC_LOG_ERROR("sql.sql", "Spell %u (horde_id) referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
else
FactionChangeSpells[alliance] = horde;