aboutsummaryrefslogtreecommitdiff
path: root/src/game/SpellMgr.cpp
diff options
context:
space:
mode:
authorQAston <none@none>2010-01-30 19:25:04 +0100
committerQAston <none@none>2010-01-30 19:25:04 +0100
commita331b67244f00ad9d4e1369f3a519e2877e5d31c (patch)
tree9f6d176681ba8e4d53384a0835513d10ba7bc083 /src/game/SpellMgr.cpp
parent6b9914f0d7e55e3fdce1d9eefcc8bb857f922016 (diff)
*Add error checks at spell_required table loading
*Allow spell_required table to store more than 1 spell learn requirement for a spell *spell_required table data is removed from world.sql and since this commit the data for it should be maintained by db project you're using. --HG-- branch : trunk
Diffstat (limited to 'src/game/SpellMgr.cpp')
-rw-r--r--src/game/SpellMgr.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index e1792787b02..716a7c3a886 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -3221,9 +3221,32 @@ void SpellMgr::LoadSpellRequired()
uint32 spell_id = fields[0].GetUInt32();
uint32 spell_req = fields[1].GetUInt32();
+ // check if chain is made with valid first spell
+ SpellEntry const * spell = sSpellStore.LookupEntry(spell_id);
+ if (!spell)
+ {
+ sLog.outErrorDb("spell_id %u in `spell_required` table is not found in dbcs, skipped", spell_id);
+ continue;
+ }
+ SpellEntry const * req_spell = sSpellStore.LookupEntry(spell_req);
+ if (!req_spell)
+ {
+ sLog.outErrorDb("req_spell %u in `spell_required` table is not found in dbcs, skipped", spell_req);
+ continue;
+ }
+ if (GetFirstSpellInChain(spell_id) == GetFirstSpellInChain(spell_req))
+ {
+ sLog.outErrorDb("req_spell %u and spell_id %u in `spell_required` table are ranks of the same spell, entry not needed, skipped", spell_req, spell_id);
+ continue;
+ }
+ if (IsSpellRequiringSpell(spell_id, spell_req))
+ {
+ sLog.outErrorDb("duplicated entry of req_spell %u and spell_id %u in `spell_required`, skipped", spell_req, spell_id);
+ continue;
+ }
+ mSpellReq.insert (std::pair<uint32, uint32>(spell_id, spell_req));
mSpellsReqSpell.insert (std::pair<uint32, uint32>(spell_req, spell_id));
- mSpellReq[spell_id] = spell_req;
++rows;
} while (result->NextRow());