From 3487973c0e9802990e91ba52d38f59a4999ee45b Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Fri, 13 Aug 2021 17:47:16 +0200 Subject: [PATCH] fix(Core/Professions): properly unlearn skill dependent spells (#7290) - Closes #7165 --- src/server/game/Entities/Player/Player.cpp | 13 +++++++------ src/server/game/Entities/Player/Player.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 27eabf23c..d55c0cd04 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -3178,7 +3178,7 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const (!form && spellInfo->HasAttribute(SPELL_ATTR2_ALLOW_WHILE_NOT_SHAPESHIFTED))); } -void Player::learnSpell(uint32 spellId) +void Player::learnSpell(uint32 spellId, bool temporary) { // Xinef: don't allow to learn active spell once more if (HasActiveSpell(spellId)) @@ -3189,7 +3189,7 @@ void Player::learnSpell(uint32 spellId) uint32 firstRankSpellId = sSpellMgr->GetFirstSpellInChain(spellId); bool thisSpec = GetTalentSpellCost(firstRankSpellId) > 0 || sSpellMgr->IsAdditionalTalentSpell(firstRankSpellId); - bool added = addSpell(spellId, thisSpec ? GetActiveSpecMask() : SPEC_MASK_ALL, true); + bool added = addSpell(spellId, thisSpec ? GetActiveSpecMask() : SPEC_MASK_ALL, true, temporary); if (added) { sScriptMgr->OnPlayerLearnSpell(this, spellId); @@ -3206,7 +3206,7 @@ void Player::learnSpell(uint32 spellId) // pussywizard: next ranks must not be in current spec (otherwise no need to learn already learnt) PlayerSpellMap::iterator itr = m_spells.find(nextSpell); if (itr != m_spells.end() && itr->second->State != PLAYERSPELL_REMOVED && !itr->second->IsInSpec(m_activeSpec)) - learnSpell(nextSpell); + learnSpell(nextSpell, temporary); } // xinef: if we learn new spell, check all spells requiring this spell, if we have such a spell, and it is not in current spec - learn it @@ -3215,7 +3215,7 @@ void Player::learnSpell(uint32 spellId) { PlayerSpellMap::iterator itr2 = m_spells.find(itr->second); if (itr2 != m_spells.end() && itr2->second->State != PLAYERSPELL_REMOVED && !itr2->second->IsInSpec(m_activeSpec)) - learnSpell(itr2->first); + learnSpell(itr2->first, temporary); } } @@ -11019,7 +11019,7 @@ void Player::LearnCustomSpells() GetName().c_str(), GetGUID().ToString().c_str(), uint32(getClass()), uint32(getRace()), tspell); if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add { - addSpell(tspell, true, true); + addSpell(tspell, SPEC_MASK_ALL, true); } else // but send in normal spell in game learn case { @@ -11218,13 +11218,14 @@ void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value) continue; } } + if (!IsInWorld()) { addSpell(pAbility->Spell, SPEC_MASK_ALL, true, true, false); } else { - learnSpell(pAbility->Spell); + learnSpell(pAbility->Spell, true); } } } diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index c54308588..dfd8c076b 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1574,7 +1574,7 @@ public: void SendLearnPacket(uint32 spellId, bool learn); bool addSpell(uint32 spellId, uint8 addSpecMask, bool updateActive, bool temporary = false, bool learnFromSkill = false); bool _addSpell(uint32 spellId, uint8 addSpecMask, bool temporary, bool learnFromSkill = false); - void learnSpell(uint32 spellId); + void learnSpell(uint32 spellId, bool temporary = false); void removeSpell(uint32 spellId, uint8 removeSpecMask, bool onlyTemporary); void resetSpells(); void LearnCustomSpells();