Core: Use new SpellInfo class in core. Sadly, this commit is not compatibile with some of the custom code. To make your code work again you may need to change:

*SpellEntry is now SpellInfo
*GetSpellProto is now GetSpellInfo
*SpellEntry::Effect*[effIndex] is now avalible under SpellInfo.Effects[effIndex].*
*sSpellStore.LookupEntry is no longer valid, use sSpellMgr->GetSpellInfo()
*SpellFunctions from SpellMgr.h like DoSpellStuff(spellId) are now: spellInfo->DoStuff()
*SpellMgr::CalculateEffectValue and similar functions are now avalible in SpellEffectInfo class.
*GET_SPELL macro is removed, code which used it is moved to SpellMgr::LoadDbcDataCorrections
*code which affected dbc data in SpellMgr::LoadSpellCustomAttr is now moved to LoadDbcDataCorrections
This commit is contained in:
QAston
2011-07-26 23:09:28 +02:00
parent 29c228a801
commit b0fe236265
195 changed files with 4630 additions and 6929 deletions
+51 -47
View File
@@ -587,7 +587,7 @@ void ObjectMgr::LoadCreatureTemplateAddons()
creatureAddon.auras.resize(tokens.size());
for (Tokens::iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
{
SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(uint32(atol(*itr)));
SpellInfo const *AdditionalSpellInfo = sSpellMgr->GetSpellInfo(uint32(atol(*itr)));
if (!AdditionalSpellInfo)
{
sLog->outErrorDb("Creature (GUID: %u) has wrong spell %u defined in `auras` field in `creature_addon`.", entry, uint32(atol(*itr)));
@@ -869,7 +869,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
for (uint8 j = 0; j < CREATURE_MAX_SPELLS; ++j)
{
if (cInfo->spells[j] && !sSpellStore.LookupEntry(cInfo->spells[j]))
if (cInfo->spells[j] && !sSpellMgr->GetSpellInfo(cInfo->spells[j]))
{
sLog->outErrorDb("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;
@@ -955,7 +955,7 @@ void ObjectMgr::LoadCreatureAddons()
creatureAddon.auras.resize(tokens.size());
for (Tokens::iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
{
SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(uint32(atol(*itr)));
SpellInfo const *AdditionalSpellInfo = sSpellMgr->GetSpellInfo(uint32(atol(*itr)));
if (!AdditionalSpellInfo)
{
sLog->outErrorDb("Creature (GUID: %u) has wrong spell %u defined in `auras` field in `creature_addon`.", guid, uint32(atol(*itr)));
@@ -2401,7 +2401,7 @@ void ObjectMgr::LoadItemTemplates()
}
}
if (itemTemplate.RequiredSpell && !sSpellStore.LookupEntry(itemTemplate.RequiredSpell))
if (itemTemplate.RequiredSpell && !sSpellMgr->GetSpellInfo(itemTemplate.RequiredSpell))
{
sLog->outErrorDb("Item (Entry: %u) has a wrong (non-existing) spell in RequiredSpell (%u)", entry, itemTemplate.RequiredSpell);
itemTemplate.RequiredSpell = 0;
@@ -2509,7 +2509,7 @@ void ObjectMgr::LoadItemTemplates()
}
else if (itemTemplate.Spells[1].SpellId != -1)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(itemTemplate.Spells[1].SpellId);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[1].SpellId);
if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, NULL))
{
sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)", entry, 1+1, itemTemplate.Spells[1].SpellId);
@@ -2557,7 +2557,7 @@ void ObjectMgr::LoadItemTemplates()
if (itemTemplate.Spells[j].SpellId && itemTemplate.Spells[j].SpellId != -1)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(itemTemplate.Spells[j].SpellId);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[j].SpellId);
if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, NULL))
{
sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)", entry, j+1, itemTemplate.Spells[j].SpellId);
@@ -4018,7 +4018,7 @@ void ObjectMgr::LoadQuests()
if (qinfo->SrcSpell)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->SrcSpell);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->SrcSpell);
if (!spellInfo)
{
sLog->outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.",
@@ -4090,7 +4090,7 @@ void ObjectMgr::LoadQuests()
uint32 id = qinfo->ReqSpell[j];
if (id)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(id);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
if (!spellInfo)
{
sLog->outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.",
@@ -4103,8 +4103,8 @@ void ObjectMgr::LoadQuests()
bool found = false;
for (uint8 k = 0; k < MAX_SPELL_EFFECTS; ++k)
{
if ((spellInfo->Effect[k] == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->EffectMiscValue[k]) == qinfo->QuestId) ||
spellInfo->Effect[k] == SPELL_EFFECT_SEND_EVENT)
if ((spellInfo->Effects[k].Effect == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->Effects[k].MiscValue) == qinfo->QuestId) ||
spellInfo->Effects[k].Effect == SPELL_EFFECT_SEND_EVENT)
{
found = true;
break;
@@ -4248,7 +4248,7 @@ void ObjectMgr::LoadQuests()
if (qinfo->RewSpell)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpell);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewSpell);
if (!spellInfo)
{
@@ -4274,7 +4274,7 @@ void ObjectMgr::LoadQuests()
if (qinfo->RewSpellCast > 0)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpellCast);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(qinfo->RewSpellCast);
if (!spellInfo)
{
@@ -4366,18 +4366,18 @@ void ObjectMgr::LoadQuests()
}
// check QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE
for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i)
for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i);
SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(i);
if (!spellInfo)
continue;
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
if (spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE)
if (spellInfo->Effects[j].Effect != SPELL_EFFECT_QUEST_COMPLETE)
continue;
uint32 quest_id = spellInfo->EffectMiscValue[j];
uint32 quest_id = spellInfo->Effects[j].MiscValue;
Quest const* quest = GetQuestTemplate(quest_id);
@@ -4707,7 +4707,7 @@ void ObjectMgr::LoadScripts(ScriptsType type)
case SCRIPT_COMMAND_REMOVE_AURA:
{
if (!sSpellStore.LookupEntry(tmp.RemoveAura.SpellID))
if (!sSpellMgr->GetSpellInfo(tmp.RemoveAura.SpellID))
{
sLog->outErrorDb("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);
@@ -4724,7 +4724,7 @@ void ObjectMgr::LoadScripts(ScriptsType type)
case SCRIPT_COMMAND_CAST_SPELL:
{
if (!sSpellStore.LookupEntry(tmp.CastSpell.SpellID))
if (!sSpellMgr->GetSpellInfo(tmp.CastSpell.SpellID))
{
sLog->outErrorDb("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);
@@ -4830,7 +4830,7 @@ void ObjectMgr::LoadSpellScripts()
for (ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
{
uint32 spellId = uint32(itr->first) & 0x00FFFFFF;
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
@@ -4840,7 +4840,7 @@ void ObjectMgr::LoadSpellScripts()
uint8 i = (uint8)((uint32(itr->first) >> 24) & 0x000000FF);
//check for correct spellEffect
if (!spellInfo->Effect[i] || (spellInfo->Effect[i] != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effect[i] != SPELL_EFFECT_DUMMY))
if (!spellInfo->Effects[i].Effect || (spellInfo->Effects[i].Effect != SPELL_EFFECT_SCRIPT_EFFECT && spellInfo->Effects[i].Effect != SPELL_EFFECT_DUMMY))
sLog->outErrorDb("Table `spell_scripts` - spell %u effect %u is not SPELL_EFFECT_SCRIPT_EFFECT or SPELL_EFFECT_DUMMY", spellId, i);
}
}
@@ -4857,17 +4857,17 @@ void ObjectMgr::LoadEventScripts()
evt_scripts.insert(eventId);
// Load all possible script entries from spells
for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
for (uint32 i = 1; i < sSpellMgr->GetSpellInfoStoreSize(); ++i)
{
SpellEntry const* spell = sSpellStore.LookupEntry(i);
SpellInfo const* spell = sSpellMgr->GetSpellInfo(i);
if (spell)
{
for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
if (spell->Effect[j] == SPELL_EFFECT_SEND_EVENT)
if (spell->Effects[j].Effect == SPELL_EFFECT_SEND_EVENT)
{
if (spell->EffectMiscValue[j])
evt_scripts.insert(spell->EffectMiscValue[j]);
if (spell->Effects[j].MiscValue)
evt_scripts.insert(spell->Effects[j].MiscValue);
}
}
}
@@ -4956,8 +4956,8 @@ void ObjectMgr::LoadSpellScriptNames()
spellId = -spellId;
}
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellId);
if (!spellEntry)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
{
sLog->outErrorDb("Scriptname:`%s` spell (spell_id:%d) does not exist in `Spell.dbc`.", scriptName, fields[0].GetInt32());
continue;
@@ -4970,14 +4970,14 @@ void ObjectMgr::LoadSpellScriptNames()
sLog->outErrorDb("Scriptname:`%s` spell (spell_id:%d) is not first rank of spell.", scriptName, fields[0].GetInt32());
continue;
}
while(spellId)
while(spellInfo)
{
mSpellScripts.insert(SpellScriptsMap::value_type(spellId, GetScriptId(scriptName)));
spellId = sSpellMgr->GetNextSpellInChain(spellId);
mSpellScripts.insert(SpellScriptsMap::value_type(spellInfo->Id, GetScriptId(scriptName)));
spellInfo = sSpellMgr->GetSpellInfo(spellInfo->Id)->GetNextRankSpell();
}
}
else
mSpellScripts.insert(SpellScriptsMap::value_type(spellId, GetScriptId(scriptName)));
mSpellScripts.insert(SpellScriptsMap::value_type(spellInfo->Id, GetScriptId(scriptName)));
++count;
}
while (result->NextRow());
@@ -5001,7 +5001,7 @@ void ObjectMgr::ValidateSpellScripts()
for (SpellScriptsMap::iterator itr = mSpellScripts.begin(); itr != mSpellScripts.end();)
{
SpellEntry const* spellEntry = sSpellStore.LookupEntry(itr->first);
SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(itr->first);
std::vector<std::pair<SpellScriptLoader *, SpellScriptsMap::iterator> > SpellScriptLoaders;
sScriptMgr->CreateSpellScriptLoaders(itr->first, SpellScriptLoaders);
itr = mSpellScripts.upper_bound(itr->first);
@@ -5237,7 +5237,7 @@ void ObjectMgr::LoadInstanceEncounters()
break;
}
case ENCOUNTER_CREDIT_CAST_SPELL:
if (!sSpellStore.LookupEntry(creditEntry))
if (!sSpellMgr->GetSpellInfo(creditEntry))
{
sLog->outErrorDb("Table `instance_encounters` has an invalid spell (entry %u) linked to the encounter %u (%s), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
continue;
@@ -6430,7 +6430,7 @@ inline void CheckGOLinkedTrapId(GameObjectTemplate const* goInfo, uint32 dataN,
inline void CheckGOSpellId(GameObjectTemplate const* goInfo, uint32 dataN, uint32 N)
{
if (sSpellStore.LookupEntry(dataN))
if (sSpellMgr->GetSpellInfo(dataN))
return;
sLog->outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but Spell (Entry %u) not exist.",
@@ -7208,7 +7208,7 @@ void ObjectMgr::LoadNPCSpellClickSpells()
}
uint32 spellid = fields[1].GetUInt32();
SpellEntry const *spellinfo = sSpellStore.LookupEntry(spellid);
SpellInfo const *spellinfo = sSpellMgr->GetSpellInfo(spellid);
if (!spellinfo)
{
sLog->outErrorDb("Table npc_spellclick_spells references unknown spellid %u. Skipping entry.", spellid);
@@ -7218,7 +7218,7 @@ void ObjectMgr::LoadNPCSpellClickSpells()
uint32 auraRequired = fields[6].GetUInt32();
if (auraRequired)
{
SpellEntry const *aurReqInfo = sSpellStore.LookupEntry(auraRequired);
SpellInfo const *aurReqInfo = sSpellMgr->GetSpellInfo(auraRequired);
if (!aurReqInfo)
{
sLog->outErrorDb("Table npc_spellclick_spells references unknown aura required %u. Skipping entry.", auraRequired);
@@ -7229,7 +7229,7 @@ void ObjectMgr::LoadNPCSpellClickSpells()
uint32 auraForbidden = fields[7].GetUInt32();
if (auraForbidden)
{
SpellEntry const *aurForInfo = sSpellStore.LookupEntry(auraForbidden);
SpellInfo const *aurForInfo = sSpellMgr->GetSpellInfo(auraForbidden);
if (!aurForInfo)
{
sLog->outErrorDb("Table npc_spellclick_spells references unknown aura forbidden %u. Skipping entry.", auraForbidden);
@@ -8219,7 +8219,7 @@ void ObjectMgr::AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost,
return;
}
SpellEntry const *spellinfo = sSpellStore.LookupEntry(spell);
SpellInfo const *spellinfo = sSpellMgr->GetSpellInfo(spell);
if (!spellinfo)
{
sLog->outErrorDb("Table `npc_trainer` contains an entry (Entry: %u) for a non-existing spell (Spell: %u), ignoring", entry, spell);
@@ -8248,28 +8248,32 @@ void ObjectMgr::AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost,
trainerSpell.reqLevel = reqLevel;
if (!trainerSpell.reqLevel)
trainerSpell.reqLevel = spellinfo->spellLevel;
trainerSpell.reqLevel = spellinfo->SpellLevel;
// calculate learned spell for profession case when stored cast-spell
trainerSpell.learnedSpell[0] = spell;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellinfo->Effect[i] != SPELL_EFFECT_LEARN_SPELL)
if (spellinfo->Effects[i].Effect != SPELL_EFFECT_LEARN_SPELL)
continue;
if (trainerSpell.learnedSpell[0] == spell)
trainerSpell.learnedSpell[0] = 0;
// player must be able to cast spell on himself
if (spellinfo->EffectImplicitTargetA[i] != 0 && spellinfo->EffectImplicitTargetA[i] != TARGET_UNIT_TARGET_ALLY
&& spellinfo->EffectImplicitTargetA[i] != TARGET_UNIT_TARGET_ANY && spellinfo->EffectImplicitTargetA[i] != TARGET_UNIT_CASTER)
if (spellinfo->Effects[i].TargetA != 0 && spellinfo->Effects[i].TargetA != TARGET_UNIT_TARGET_ALLY
&& spellinfo->Effects[i].TargetA != TARGET_UNIT_TARGET_ANY && spellinfo->Effects[i].TargetA != TARGET_UNIT_CASTER)
{
sLog->outErrorDb("Table `npc_trainer` has spell %u for trainer entry %u with learn effect which has incorrect target type, ignoring learn effect!", spell, entry);
continue;
}
trainerSpell.learnedSpell[i] = spellinfo->EffectTriggerSpell[i];
trainerSpell.learnedSpell[i] = spellinfo->Effects[i].TriggerSpell;
if (trainerSpell.learnedSpell[i] && SpellMgr::IsProfessionSpell(trainerSpell.learnedSpell[i]))
data.trainerType = 2;
if (trainerSpell.learnedSpell[i])
{
SpellInfo const* learnedSpellInfo = sSpellMgr->GetSpellInfo(trainerSpell.learnedSpell[i]);
if (learnedSpellInfo && learnedSpellInfo->IsProfession())
data.trainerType = 2;
}
}
return;
@@ -8925,9 +8929,9 @@ void ObjectMgr::LoadFactionChangeSpells()
uint32 alliance = fields[0].GetUInt32();
uint32 horde = fields[1].GetUInt32();
if (!sSpellStore.LookupEntry(alliance))
if (!sSpellMgr->GetSpellInfo(alliance))
sLog->outErrorDb("Spell %u referenced in `player_factionchange_spells` does not exist, pair skipped!", alliance);
else if (!sSpellStore.LookupEntry(horde))
else if (!sSpellMgr->GetSpellInfo(horde))
sLog->outErrorDb("Spell %u referenced in `player_factionchange_spells` does not exist, pair skipped!", horde);
else
factionchange_spells[alliance] = horde;