*Dual spec switching and talent resetting rewrites, comment out some redundant code, and remove spells learned from talents properly. Closes #326

--HG--
branch : trunk
This commit is contained in:
maximius
2009-11-20 16:09:20 -08:00
parent 5db87f8102
commit b9a0663126
+37 -23
View File
@@ -3769,11 +3769,12 @@ bool Player::resetTalents(bool no_cost)
} }
} }
for (uint32 i = 0; i < sTalentStore.GetNumRows(); i++) for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i)
{ {
TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); TalentEntry const *talentInfo = sTalentStore.LookupEntry(i);
if (!talentInfo) continue; if (!talentInfo)
continue;
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
@@ -3786,7 +3787,6 @@ bool Player::resetTalents(bool no_cost)
if ((getClassMask() & talentTabInfo->ClassMask) == 0) if ((getClassMask() & talentTabInfo->ClassMask) == 0)
continue; continue;
// Re-use pre-dual talent way of resetting talents, to ensure talents aren't being stored in spell storage.
for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank) for (uint8 rank = 0; rank < MAX_TALENT_RANK; ++rank)
{ {
for (PlayerSpellMap::iterator itr = GetSpellMap().begin(); itr != GetSpellMap().end();) for (PlayerSpellMap::iterator itr = GetSpellMap().begin(); itr != GetSpellMap().end();)
@@ -3818,11 +3818,15 @@ bool Player::resetTalents(bool no_cost)
} }
} }
/*
// This is redundant, no talent-related spells should remain at all after the previous loop, and
// besides, this loop doesn't even properly remove spells that are learned when you acquire a talent.
for (PlayerTalentMap::iterator itr2 = m_talents[m_activeSpec]->begin(); itr2 != m_talents[m_activeSpec]->end(); ++itr2) for (PlayerTalentMap::iterator itr2 = m_talents[m_activeSpec]->begin(); itr2 != m_talents[m_activeSpec]->end(); ++itr2)
{ {
removeSpell(itr2->first, !IsPassiveSpell(itr2->first), false); removeSpell(itr2->first, !IsPassiveSpell(itr2->first), false);
itr2->second->state = PLAYERSPELL_REMOVED; itr2->second->state = PLAYERSPELL_REMOVED;
} }
*/
} }
SetFreeTalentPoints(talentPointsForLevel); SetFreeTalentPoints(talentPointsForLevel);
@@ -21999,34 +22003,41 @@ void Player::ActivateSpec(uint8 spec)
ClearAllReactives(); ClearAllReactives();
UnsummonAllTotems(); UnsummonAllTotems();
RemoveAllControlled(); RemoveAllControlled();
RemoveAllAurasOnDeath(); /*RemoveAllAurasOnDeath();
if (GetPet()) if (GetPet())
GetPet()->RemoveAllAurasOnDeath(); GetPet()->RemoveAllAurasOnDeath();*/
//RemoveAllAuras(this->GetGUID(), NULL, false, true); // removes too many auras //RemoveAllAuras(this->GetGUID(), NULL, false, true); // removes too many auras
//ExitVehicle(); // should be impossible to switch specs from inside a vehicle.. //ExitVehicle(); // should be impossible to switch specs from inside a vehicle..
uint32 const* talentTabIds = GetTalentTabPages(getClass()); // Remove all talents and talent-learned spells under this spec.
for (PlayerTalentMap::iterator itr = m_talents[m_activeSpec]->begin(); itr != m_talents[m_activeSpec]->end(); ++itr)
for (uint8 i = 0; i < 3; ++i) for (PlayerSpellMap::iterator itr2 = GetSpellMap().begin(); itr2 != GetSpellMap().end();)
{ {
uint32 talentTabId = talentTabIds[i]; if (itr2->second->state == PLAYERSPELL_REMOVED || itr2->second->disabled)
for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
{ {
TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId); ++itr2;
if (!talentInfo)
continue; continue;
// skip another tab talents
if (talentInfo->TalentTab != talentTabId)
continue;
// remove all talent ranks, starting at highest rank
for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank)
if (talentInfo->RankID[rank] != 0 && HasTalent(talentInfo->RankID[rank], m_activeSpec))
removeSpell(talentInfo->RankID[rank], true);
} }
// remove learned spells (all ranks)
uint32 itrFirstId = spellmgr.GetFirstSpellInChain(itr2->first);
// unlearn if first rank is talent or learned by talent
if (itrFirstId == itr->first)
{
removeSpell(itr2->first, !IsPassiveSpell(itr2->first), false);
itr2 = GetSpellMap().begin();
continue;
}
else if (spellmgr.IsSpellLearnToSpell(itr->first, itrFirstId))
{
removeSpell(itr2->first, !IsPassiveSpell(itr2->first));
itr2 = GetSpellMap().begin();
continue;
}
else
++itr2;
} }
// set glyphs // set glyphs
@@ -22039,6 +22050,9 @@ void Player::ActivateSpec(uint8 spec)
SetActiveSpec(spec); SetActiveSpec(spec);
uint32 spentTalents = 0; uint32 spentTalents = 0;
// find class talent tabs (all players have 3 talent tabs)
uint32 const *talentTabIds = GetTalentTabPages(getClass());
for (uint8 i = 0; i < 3; ++i) for (uint8 i = 0; i < 3; ++i)
{ {
uint32 talentTabId = talentTabIds[i]; uint32 talentTabId = talentTabIds[i];
@@ -22090,7 +22104,7 @@ void Player::ActivateSpec(uint8 spec)
Powers pw = getPowerType(); Powers pw = getPowerType();
if (pw != POWER_MANA) if (pw != POWER_MANA)
SetPower(POWER_MANA, 0); // what on earth is this for?! SetPower(POWER_MANA, 0); // Mana must be 0 even if it isn't the active power type.
SetPower(pw, 0); SetPower(pw, 0);
} }