From 939ef7612d3d34ca1d9d7aeba5e9eef5cb6bb702 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 25 Jan 2009 16:19:10 +0300 Subject: [PATCH] [7173] Some fixes for resent spell learn/unlearn system changes. * Fixed profession unlearn using skill unlearn button in skill list * Update action bar to spell low rank at unlearn spell only for .unlearn command. This will avoid show unexpected "Learned spell" chat message for low rank at unlearing high rank and at all ranks unlearning. --- src/game/Level3.cpp | 2 +- src/game/Player.cpp | 34 ++++++++++++++++++---------------- src/game/Player.h | 2 +- src/shared/revision_nr.h | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index a24461cfa..1063d6be4 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -955,7 +955,7 @@ bool ChatHandler::HandleUnLearnCommand(const char* args) spell_id = spellmgr.GetFirstSpellInChain (spell_id); if (target->HasSpell(spell_id)) - target->removeSpell(spell_id); + target->removeSpell(spell_id,false,!allRanks); else SendSysMessage(LANG_FORGET_SPELL); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index f2c0c4fd3..ae58e8b7c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2696,10 +2696,6 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen if(!rankSpellId || rankSpellId==spell_id) continue; - // skip unknown ranks - if(!HasSpell(rankSpellId)) - continue; - removeSpell(rankSpellId); } } @@ -2943,7 +2939,7 @@ void Player::learnSpell(uint32 spell_id, bool dependent) GetSession()->SendPacket(&data); } -void Player::removeSpell(uint32 spell_id, bool disabled) +void Player::removeSpell(uint32 spell_id, bool disabled, bool update_action_bar_for_low_rank) { PlayerSpellMap::iterator itr = m_spells.find(spell_id); if (itr == m_spells.end()) @@ -3079,13 +3075,13 @@ void Player::removeSpell(uint32 spell_id, bool disabled) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); - // if talent then lesser rank also talen and need learn + // if talent then lesser rank also talent and need learn if(talentCosts) learnSpell (prev_id,false); - // if ranked non-stackable spell: need activate lesser rank and update dendence state + // if ranked non-stackable spell: need activate lesser rank and update dendence state else if(cur_active && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0) { - // need manually update dependence state (learn spell ignore like attempts) + // need manually update dependence state (learn spell ignore like attempts) PlayerSpellMap::iterator prev_itr = m_spells.find(prev_id); if (prev_itr != m_spells.end()) { @@ -3101,12 +3097,15 @@ void Player::removeSpell(uint32 spell_id, bool disabled) { if(addSpell(prev_id,true,false,prev_itr->second->dependent,prev_itr->second->disabled)) { - // downgrade spell ranks in spellbook and action bar - WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); - data << uint16(spell_id); - data << uint16(prev_id); - GetSession()->SendPacket( &data ); - prev_activate = true; + if(update_action_bar_for_low_rank) + { + // downgrade spell ranks in spellbook and action bar + WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); + data << uint16(spell_id); + data << uint16(prev_id); + GetSession()->SendPacket( &data ); + prev_activate = true; + } } } } @@ -5107,8 +5106,11 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),0); SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); - // remove spells that depend on this skill when removing the skill - learnSkillRewardedSpells(id, 0); + // remove all spells that related to this skill + for (uint32 j=0; jskillId==id) + removeSpell(spellmgr.GetFirstSpellInChain(pAbility->spellId)); } } else if(currVal) //add diff --git a/src/game/Player.h b/src/game/Player.h index f7c42337e..d6ec3e289 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1486,7 +1486,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SendInitialSpells(); 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); + void removeSpell(uint32 spell_id, bool disabled = false, bool update_action_bar_for_low_rank = false); void resetSpells(); void learnDefaultSpells(); void learnQuestRewardedSpells(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 82e51efbf..8ac3891dc 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7172" + #define REVISION_NR "7173" #endif // __REVISION_NR_H__