diff options
author | Ovahlord <dreadkiller@gmx.de> | 2023-11-20 20:29:59 +0100 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2023-11-20 20:30:13 +0100 |
commit | 7f86ffac2d1a18e35802e3a818f3e4a1441dfbb4 (patch) | |
tree | 84a1aac9a0f5d28774babf18fc2178e60317380b /src | |
parent | 1195d7c190582f0b95f0afef7660cd108fcbd8c3 (diff) |
Core/Spells: restore loading talent ranks
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 61 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.h | 1 |
3 files changed, 63 insertions, 3 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 88cb94e4aba..ad3f5185550 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -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); diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 20ab87f8188..a91d73be4e1 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -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; diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index b547c154c79..cff70dd58d4 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -768,6 +768,7 @@ class TC_GAME_API SpellMgr // Loading data at server startup void UnloadSpellInfoChains(); + void LoadSpellTalentRanks(); void LoadSpellRanks(); void LoadSpellRequired(); void LoadSpellLearnSkills(); |