mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Spells: restore loading talent ranks
This commit is contained in:
@@ -2746,8 +2746,6 @@ bool Player::AddTalent(TalentEntry const* talent, uint16 rank, uint8 talentGroup
|
||||
auto itr = talentMap.find(talent->ID);
|
||||
if (itr != talentMap.end())
|
||||
{
|
||||
|
||||
|
||||
itr->second.State = PLAYERSPELL_UNCHANGED;
|
||||
itr->second.Rank = static_cast<uint8>(rank);
|
||||
}
|
||||
@@ -2758,7 +2756,7 @@ bool Player::AddTalent(TalentEntry const* talent, uint16 rank, uint8 talentGroup
|
||||
if (GetActiveTalentGroup() != talentGroupId)
|
||||
return true;
|
||||
|
||||
LearnSpell(spellInfo->Id, true);
|
||||
LearnSpell(spellInfo->Id, false);
|
||||
if (talent->OverridesSpellID)
|
||||
AddOverrideSpell(talent->OverridesSpellID, talent->SpellID);
|
||||
|
||||
|
||||
@@ -809,8 +809,69 @@ void SpellMgr::UnloadSpellInfoChains()
|
||||
mSpellChains.clear();
|
||||
}
|
||||
|
||||
void SpellMgr::LoadSpellTalentRanks()
|
||||
{
|
||||
// cleanup core data before reload - remove reference to ChainNode from SpellInfo
|
||||
UnloadSpellInfoChains();
|
||||
|
||||
for (TalentEntry const* talentInfo : sTalentStore)
|
||||
{
|
||||
SpellInfo const* lastSpell = nullptr;
|
||||
for (uint8 rank = talentInfo->SpellRank.size() - 1; rank > 0; --rank)
|
||||
{
|
||||
if (talentInfo->SpellRank[rank])
|
||||
{
|
||||
lastSpell = GetSpellInfo(talentInfo->SpellRank[rank], DIFFICULTY_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!lastSpell)
|
||||
continue;
|
||||
|
||||
SpellInfo const* firstSpell = GetSpellInfo(talentInfo->SpellRank[0], DIFFICULTY_NONE);
|
||||
if (!firstSpell)
|
||||
{
|
||||
TC_LOG_ERROR("spells", "SpellMgr::LoadSpellTalentRanks: First Rank Spell {} for TalentEntry {} does not exist.", talentInfo->SpellRank[0], talentInfo->ID);
|
||||
continue;
|
||||
}
|
||||
|
||||
SpellInfo const* prevSpell = nullptr;
|
||||
for (uint8 rank = 0; rank < talentInfo->SpellRank.size(); ++rank)
|
||||
{
|
||||
uint32 spellId = talentInfo->SpellRank[rank];
|
||||
if (!spellId)
|
||||
break;
|
||||
|
||||
SpellInfo const* currentSpell = GetSpellInfo(spellId, DIFFICULTY_NONE);
|
||||
if (!currentSpell)
|
||||
{
|
||||
TC_LOG_ERROR("spells", "SpellMgr::LoadSpellTalentRanks: Spell {} (Rank: {}) for TalentEntry {} does not exist.", spellId, rank + 1, talentInfo->ID);
|
||||
break;
|
||||
}
|
||||
|
||||
SpellChainNode node;
|
||||
node.first = firstSpell;
|
||||
node.last = lastSpell;
|
||||
node.rank = rank + 1;
|
||||
|
||||
node.prev = prevSpell;
|
||||
node.next = node.rank < MAX_TALENT_RANK ? GetSpellInfo(talentInfo->SpellRank[node.rank], DIFFICULTY_NONE) : nullptr;
|
||||
|
||||
mSpellChains[spellId] = node;
|
||||
for (SpellInfo const& difficultyInfo : _GetSpellInfo(spellId))
|
||||
const_cast<SpellInfo&>(difficultyInfo).ChainEntry = &mSpellChains[spellId];
|
||||
|
||||
prevSpell = currentSpell;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SpellMgr::LoadSpellRanks()
|
||||
{
|
||||
// cleanup data and load spell ranks for talents from dbc
|
||||
LoadSpellTalentRanks();
|
||||
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
std::map<uint32 /*spell*/, uint32 /*next*/> chains;
|
||||
|
||||
@@ -768,6 +768,7 @@ class TC_GAME_API SpellMgr
|
||||
|
||||
// Loading data at server startup
|
||||
void UnloadSpellInfoChains();
|
||||
void LoadSpellTalentRanks();
|
||||
void LoadSpellRanks();
|
||||
void LoadSpellRequired();
|
||||
void LoadSpellLearnSkills();
|
||||
|
||||
Reference in New Issue
Block a user