aboutsummaryrefslogtreecommitdiff
path: root/src/game/Player.cpp
diff options
context:
space:
mode:
authorQAston <none@none>2008-12-14 23:01:02 +0100
committerQAston <none@none>2008-12-14 23:01:02 +0100
commit42d52c1e1782b9f9bbccf37541fe32865c34cfe5 (patch)
tree2ba45b5a2783b6f86a90abb283ba0d44857cb365 /src/game/Player.cpp
parent9948e98703d8d9044a3b8ad6dbd70a16e6181dc0 (diff)
*Use prev_spell data calculated on startup instead of sql column.
*Changed map structure of req spell. *Added precalculated data for next spell in rank and last one. *Removed duplicated rank entries for some spells and used req_spell column instead. *Allow required spell to have required spell. --HG-- branch : trunk
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r--src/game/Player.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 1b1344473de..1be902f72e4 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -2911,12 +2911,12 @@ void Player::learnSpell(uint32 spell_id)
bool learning = addSpell(spell_id,active);
// learn all disabled higher ranks (recursive)
- SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext();
- for(SpellChainMapNext::const_iterator i = nextMap.lower_bound(spell_id); i != nextMap.upper_bound(spell_id); ++i)
+ SpellChainNode const* node = spellmgr.GetSpellChainNode(spell_id);
+ if (node)
{
- PlayerSpellMap::iterator iter = m_spells.find(i->second);
- if (disabled && iter != m_spells.end() && iter->second->disabled)
- learnSpell(i->second);
+ PlayerSpellMap::iterator iter = m_spells.find(node->next);
+ if (disabled && iter != m_spells.end() && iter->second->disabled )
+ learnSpell(node->next);
}
// prevent duplicated entires in spell book
@@ -2938,10 +2938,17 @@ void Player::removeSpell(uint32 spell_id, bool disabled)
return;
// unlearn non talent higher ranks (recursive)
- SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext();
- for(SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spell_id); itr2 != nextMap.upper_bound(spell_id); ++itr2)
- if(HasSpell(itr2->second) && !GetTalentSpellPos(itr2->second))
- removeSpell(itr2->second,disabled);
+ SpellChainNode const* node = spellmgr.GetSpellChainNode(spell_id);
+ if (node)
+ {
+ if(HasSpell(node->next) && !GetTalentSpellPos(node->next))
+ removeSpell(node->next,disabled);
+ }
+ //unlearn spells dependent from recently removed spells
+ SpellRequiredMap const& reqMap = spellmgr.GetSpellRequiredMap();
+ SpellRequiredMap::const_iterator itr2 = reqMap.find(spell_id);
+ for (uint32 i=reqMap.count(spell_id);i>0;i--,itr2++)
+ removeSpell(itr2->second,disabled);
// removing
WorldPacket data(SMSG_REMOVED_SPELL, 4);