From 5b15cd5dd24722b9caa72623c6453242238ee389 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 15 Jun 2010 16:52:02 +0400 Subject: [PATCH] [10063] Cleanup recent added code. --- src/game/Player.cpp | 24 +++++++++++++++--------- src/game/Player.h | 3 ++- src/game/Unit.cpp | 9 ++------- src/shared/revision_nr.h | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index c231e7d8d..23379ca6a 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -21209,15 +21209,23 @@ void Player::UpdateAchievementCriteria( AchievementCriteriaTypes type, uint32 mi GetAchievementMgr().UpdateAchievementCriteria(type, miscvalue1,miscvalue2,unit,time); } -PlayerTalent const* Player::GetTalentById(int32 talentId) const +PlayerTalent const* Player::GetKnownTalentById(int32 talentId) const { PlayerTalentMap::const_iterator itr = m_talents[m_activeSpec].find(talentId); - if (itr != m_talents[m_activeSpec].end()) + if (itr != m_talents[m_activeSpec].end() && itr->second.state != PLAYERSPELL_REMOVED) return &itr->second; else return NULL; } +SpellEntry const* Player::GetKnownTalentRankById(int32 talentId) const +{ + if (PlayerTalent const* talent = GetKnownTalentById(talentId)) + return sSpellStore.LookupEntry(talent->m_talentEntry->RankID[talent->currentRank]); + else + return NULL; +} + void Player::LearnTalent(uint32 talentId, uint32 talentRank) { uint32 CurTalentPoints = GetFreeTalentPoints(); @@ -21244,9 +21252,8 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) // find current max talent rank uint32 curtalent_maxrank = 0; - PlayerTalentMap::iterator itr = m_talents[m_activeSpec].find(talentId); - if (itr != m_talents[m_activeSpec].end() && itr->second.state != PLAYERSPELL_REMOVED) - curtalent_maxrank = itr->second.currentRank + 1; + if (PlayerTalent const* talent = GetKnownTalentById(talentId)) + curtalent_maxrank = talent->currentRank + 1; // we already have same or higher talent rank learned if(curtalent_maxrank >= (talentRank + 1)) @@ -21882,17 +21889,16 @@ void Player::ActivateSpec(uint8 specNum) // learn talent spells if they not in new spec (old spec copy) // and if they have different rank - PlayerTalentMap::iterator specIter = m_talents[m_activeSpec].find(tempIter->first); - if (specIter != m_talents[m_activeSpec].end() && specIter->second.state != PLAYERSPELL_REMOVED) + if (PlayerTalent const* cur_talent = GetKnownTalentById(tempIter->first)) { - if ((*specIter).second.currentRank != talent.currentRank) + if (cur_talent->currentRank != talent.currentRank) learnSpell(talentSpellId, false); } else learnSpell(talentSpellId, false); // sync states - original state is changed in addSpell that learnSpell calls - specIter = m_talents[m_activeSpec].find(tempIter->first); + PlayerTalentMap::iterator specIter = m_talents[m_activeSpec].find(tempIter->first); if (specIter != m_talents[m_activeSpec].end()) (*specIter).second.state = talent.state; else diff --git a/src/game/Player.h b/src/game/Player.h index a58357b2d..8a03ecc97 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1664,7 +1664,8 @@ class MANGOS_DLL_SPEC Player : public Unit SpellCooldowns const& GetSpellCooldownMap() const { return m_spellCooldowns; } - PlayerTalent const* GetTalentById(int32 talentId) const; + PlayerTalent const* GetKnownTalentById(int32 talentId) const; + SpellEntry const* GetKnownTalentRankById(int32 talentId) const; void AddSpellMod(SpellModifier* mod, bool apply); bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell = NULL); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 4138ca6cd..4bd300cbf 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8931,13 +8931,8 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const *spellProto, int32 total, int3 // Impurity if (GetTypeId() == TYPEID_PLAYER && spellProto->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT) { - PlayerTalent const* talent = ((Player*)this)->GetTalentById(2005); - if (talent && talent->state != PLAYERSPELL_REMOVED) - { - SpellEntry const* spell = sSpellStore.LookupEntry(talent->m_talentEntry->RankID[talent->currentRank]); - if (spell) - ap_bonus += ((spell->CalculateSimpleValue(EFFECT_INDEX_0) * ap_bonus) / 100.0f); - } + if (SpellEntry const* spell = ((Player*)this)->GetKnownTalentRankById(2005)) + ap_bonus += ((spell->CalculateSimpleValue(EFFECT_INDEX_0) * ap_bonus) / 100.0f); } total += int32(ap_bonus * (GetTotalAttackPowerValue(BASE_ATTACK) + ap_benefit)); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 790ea9529..41f589ff8 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 "10062" + #define REVISION_NR "10063" #endif // __REVISION_NR_H__