diff options
author | QAston <none@none> | 2010-01-30 19:25:04 +0100 |
---|---|---|
committer | QAston <none@none> | 2010-01-30 19:25:04 +0100 |
commit | a331b67244f00ad9d4e1369f3a519e2877e5d31c (patch) | |
tree | 9f6d176681ba8e4d53384a0835513d10ba7bc083 /src/game/SpellMgr.h | |
parent | 6b9914f0d7e55e3fdce1d9eefcc8bb857f922016 (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.h')
-rw-r--r-- | src/game/SpellMgr.h | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 550f9d7bf37..6034a9d10ce 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -762,10 +762,13 @@ struct SpellChainNode typedef UNORDERED_MAP<uint32, SpellChainNode> SpellChainMap; -// spell_id req_spell -typedef UNORDERED_MAP<uint32, uint32> SpellRequiredMap; +// spell_id req_spell +typedef std::multimap<uint32, uint32> SpellRequiredMap; +typedef std::pair<SpellRequiredMap::const_iterator,SpellRequiredMap::const_iterator> SpellRequiredMapBounds; +// req_spell spell_id typedef std::multimap<uint32, uint32> SpellsRequiringSpellMap; +typedef std::pair<SpellsRequiringSpellMap::const_iterator,SpellsRequiringSpellMap::const_iterator> SpellsRequiringSpellMapBounds; // Spell learning properties (accessed using SpellMgr functions) struct SpellLearnSkillNode @@ -966,15 +969,6 @@ class SpellMgr return &itr->second; } - uint32 GetSpellRequired(uint32 spell_id) const - { - SpellRequiredMap::const_iterator itr = mSpellReq.find(spell_id); - if(itr == mSpellReq.end()) - return NULL; - - return itr->second; - } - uint32 GetFirstSpellInChain(uint32 spell_id) const { if(SpellChainNode const* node = GetSpellChainNode(spell_id)) @@ -1009,7 +1003,25 @@ class SpellMgr return 0; } - SpellsRequiringSpellMap const& GetSpellsRequiringSpell() const { return mSpellsReqSpell; } + SpellRequiredMapBounds GetSpellsRequiredForSpellBounds(uint32 spell_id) const + { + return SpellRequiredMapBounds(mSpellReq.lower_bound(spell_id),mSpellReq.upper_bound(spell_id)); + } + + SpellsRequiringSpellMapBounds GetSpellsRequiringSpellBounds(uint32 spell_id) const + { + return SpellsRequiringSpellMapBounds(mSpellsReqSpell.lower_bound(spell_id),mSpellsReqSpell.upper_bound(spell_id)); + } + bool IsSpellRequiringSpell(uint32 spellid, uint32 req_spellid) const + { + SpellsRequiringSpellMapBounds spellsRequiringSpell = GetSpellsRequiringSpellBounds(req_spellid); + for (SpellsRequiringSpellMap::const_iterator itr = spellsRequiringSpell.first; itr != spellsRequiringSpell.second; ++itr) + { + if (itr->second == spellid) + return true; + } + return false; + } uint8 GetSpellRank(uint32 spell_id) const { |