[10063] Cleanup recent added code.

This commit is contained in:
VladimirMangos 2010-06-15 16:52:02 +04:00
parent c781dbbada
commit 5b15cd5dd2
4 changed files with 20 additions and 18 deletions

View file

@ -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

View file

@ -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);

View file

@ -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));

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10062"
#define REVISION_NR "10063"
#endif // __REVISION_NR_H__