From a331b67244f00ad9d4e1369f3a519e2877e5d31c Mon Sep 17 00:00:00 2001 From: QAston Date: Sat, 30 Jan 2010 19:25:04 +0100 Subject: *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 --- src/game/SpellMgr.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/game/SpellMgr.cpp') 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(spell_id, spell_req)); mSpellsReqSpell.insert (std::pair(spell_req, spell_id)); - mSpellReq[spell_id] = spell_req; ++rows; } while (result->NextRow()); -- cgit v1.2.3