aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/Player.cpp38
-rw-r--r--src/game/Player.h2
2 files changed, 38 insertions, 2 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index eaf5d9ecb02..41ad8b23982 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -19387,7 +19387,7 @@ void Player::ApplyEquipCooldown( Item * pItem )
}
}
-void Player::resetSpells()
+void Player::resetSpells(bool myClassOnly)
{
// not need after this call
if(HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
@@ -19397,8 +19397,44 @@ void Player::resetSpells()
// and we can't use original map for safe iterative with visit each spell at loop end
PlayerSpellMap smap = GetSpellMap();
+ if(myClassOnly){
+ ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(m_session->GetPlayer()->getClass());
+ if(!clsEntry)
+ return;
+ uint32 family = clsEntry->spellfamily;
+ }
+
for(PlayerSpellMap::const_iterator iter = smap.begin();iter != smap.end(); ++iter)
+ {
+ if(myClassOnly)
+ {
+ SpellEntry const *spellInfo = sSpellStore.LookupEntry(iter->first);
+ if(!spellInfo)
+ continue;
+
+ // skip server-side/triggered spells
+ if(spellInfo->spellLevel == 0)
+ continue;
+
+ // skip wrong class/race skills
+ if(!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id))
+ continue;
+
+ // skip other spell families
+ if( spellInfo->SpellFamilyName != family)
+ continue;
+
+ // skip spells with first rank learned as talent (and all talents then also)
+ uint32 first_rank = spellmgr.GetFirstSpellInChain(spellInfo->Id);
+ if(GetTalentSpellCost(first_rank) > 0)
+ continue;
+
+ // skip broken spells
+ if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false))
+ continue;
+ }
removeSpell(iter->first,false,false); // only iter->first can be accessed, object by iter->second can be deleted already
+ }
learnDefaultSpells();
learnQuestRewardedSpells();
diff --git a/src/game/Player.h b/src/game/Player.h
index 95debc07b55..75a9953a77f 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1454,7 +1454,7 @@ class MANGOS_DLL_SPEC Player : public Unit
bool addSpell(uint32 spell_id, bool active, bool learning, bool dependent, bool disabled);
void learnSpell(uint32 spell_id, bool dependent);
void removeSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true);
- void resetSpells();
+ void resetSpells(bool myClassOnly = false);
void learnDefaultSpells();
void learnQuestRewardedSpells();
void learnQuestRewardedSpells(Quest const* quest);