From 7ef844f912f8fca8215c5b136131a81b7f2af367 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Sat, 22 Jun 2024 22:51:33 -0700 Subject: [PATCH] fix: unknown talent errors in tww --- .../Core/Conditions/Categories/Talents.lua | 100 +++++++++++------- .../Conditions/Categories/Talents_config.lua | 45 ++------ 2 files changed, 70 insertions(+), 75 deletions(-) diff --git a/Components/Core/Conditions/Categories/Talents.lua b/Components/Core/Conditions/Categories/Talents.lua index fe6f285a..f8aba6aa 100644 --- a/Components/Core/Conditions/Categories/Talents.lua +++ b/Components/Core/Conditions/Categories/Talents.lua @@ -389,12 +389,63 @@ ConditionCategory:RegisterCondition(8.1, "TREEROLE2", { end, }) - CNDT.Env.TalentMap = {} CNDT.Env.PvpTalentMap = {} if C_ClassTalents then -- Dragonflight + function CNDT:GetTalentRanksBySpellID() + local map = {} + + -- A "config" is a loadout - either the current one (maybe unsaved), or a saved one. + -- NOTE: C_ClassTalents.GetActiveConfigID returns a generic config for the curent class spec, + -- not the actual currently selected loadout (which is only returned by ) + local configID = C_ClassTalents.GetActiveConfigID() + if configID then + -- will be nil on fresh characters + local configInfo = C_Traits.GetConfigInfo(configID) + + -- I have no idea why the concept of trees exists. + -- It seems that every class has a single tree, regardless of spec. + for _, treeID in pairs(configInfo.treeIDs) do + + -- Nodes are circles/square in the talent tree. + for _, nodeID in pairs(C_Traits.GetTreeNodes(treeID)) do + local nodeInfo = C_Traits.GetNodeInfo(configID, nodeID) + + -- Entries are the choices in each node. + -- Choice nodes have two, otherwise there's only one. + for _, entryID in pairs(nodeInfo.entryIDs) do + local entryInfo = C_Traits.GetEntryInfo(configID, entryID) + + if not entryInfo.definitionID then + -- No idea what causes this. Reported on discord as happening on TWW beta. + -- Doesn't happen on TWW PTR. + print("Missing definitionID for configId", configID, "entryId", entryID) + else + -- Definition seems a useless layer between entry and spellID. + -- Blizzard's in-game API help about them is currently completely wrong + -- about what fields it has. Currently the only field I see is spellID. + local definitionInfo = C_Traits.GetDefinitionInfo(entryInfo.definitionID) + local spellID = definitionInfo.spellID + + if spellID then + -- The ranks are stored on the node, but we + -- have to make sure that we're looking at the ranks for the + -- currently selected entry for the talent. + local ranks = nodeInfo.activeEntry and nodeInfo.activeEntry.entryID == entryID and nodeInfo.ranksPurchased or 0 + + map[spellID] = ranks + end + end + end + end + end + end + + return map + end + function CNDT:PLAYER_TALENT_UPDATE() wipe(Env.TalentMap) @@ -424,45 +475,14 @@ if C_ClassTalents then TMW:Fire("TMW_TALENT_LOADOUT_NAME_UPDATE", loadoutName) end - -- A "config" is a loadout - either the current one (maybe unsaved), or a saved one. - -- NOTE: C_ClassTalents.GetActiveConfigID returns a generic config for the curent class spec, - -- not the actual currently selected loadout (which is only returned by ) - local configID = C_ClassTalents.GetActiveConfigID() - if configID then - -- will be nil on fresh characters - local configInfo = C_Traits.GetConfigInfo(configID) - - -- I have no idea why the concept of trees exists. - -- It seems that every class has a single tree, regardless of spec. - for _, treeID in pairs(configInfo.treeIDs) do - - -- Nodes are circles/square in the talent tree. - for _, nodeID in pairs(C_Traits.GetTreeNodes(treeID)) do - local nodeInfo = C_Traits.GetNodeInfo(configID, nodeID) + local ranksbySpellId = CNDT:GetTalentRanksBySpellID() + for spellID, ranks in pairs(ranksbySpellId) do + local name = GetSpellName(spellID) - -- Entries are the choices in each node. - -- Choice nodes have two, otherwise there's only one. - for _, entryID in pairs(nodeInfo.entryIDs) do - local entryInfo = C_Traits.GetEntryInfo(configID, entryID) - -- Definition seems a useless layer between entry and spellID. - -- Blizzard's in-game API help about them is currently completely wrong - -- about what fields it has. Currently the only field I see is spellID. - local definitionInfo = C_Traits.GetDefinitionInfo(entryInfo.definitionID) - local spellID = definitionInfo.spellID - local name, _, tex = GetSpellInfo(spellID) - - -- The ranks are stored on the node, but we - -- have to make sure that we're looking at the ranks for the - -- currently selected entry for the talent. - local ranks = nodeInfo.activeEntry and nodeInfo.activeEntry.entryID == entryID and nodeInfo.ranksPurchased or 0 - - local lower = name and strlowerCache[name] - if lower then - Env.TalentMap[lower] = ranks - Env.TalentMap[spellID] = ranks - end - end - end + local lower = name and strlowerCache[name] + if lower then + Env.TalentMap[lower] = ranks + Env.TalentMap[spellID] = ranks end end @@ -825,7 +845,7 @@ if IsInJailersTower then if not data then return end local spellId = data.spellId - local count = data.count + local count = data.applications if count == 0 then count = 1 end diff --git a/Components/Core/Conditions/Categories/Talents_config.lua b/Components/Core/Conditions/Categories/Talents_config.lua index ea379dbd..31512147 100644 --- a/Components/Core/Conditions/Categories/Talents_config.lua +++ b/Components/Core/Conditions/Categories/Talents_config.lua @@ -20,6 +20,7 @@ local print = TMW.print local SUG = TMW.SUG local strlowerCache = TMW.strlowerCache local GetSpellInfo = TMW.GetSpellInfo +local GetSpellName = TMW.GetSpellName local _, pclass = UnitClass("Player") @@ -43,39 +44,13 @@ function Module:Table_Get() wipe(self.table) if C_ClassTalents then - -- A "config" is a loadout - either the current one (maybe unsaved), or a saved one. - local configID = C_ClassTalents.GetActiveConfigID() - local configInfo = C_Traits.GetConfigInfo(configID) - - -- I have no idea why the concept of trees exists. - -- It seems that every class has a single tree, regardless of spec. - for _, treeID in pairs(configInfo.treeIDs) do - - -- Nodes are circles/square in the talent tree. - for _, nodeID in pairs(C_Traits.GetTreeNodes(treeID)) do - local nodeInfo = C_Traits.GetNodeInfo(configID, nodeID) - - -- Entries are the choices in each node. - -- Choice nodes have two, otherwise there's only one. - for _, entryID in pairs(nodeInfo.entryIDs) do - local entryInfo = C_Traits.GetEntryInfo(configID, entryID) - -- Definition seems a useless layer between entry and spellID. - -- Blizzard's in-game API help about them is currently completely wrong - -- about what fields it has. Currently the only field I see is spellID. - local definitionInfo = C_Traits.GetDefinitionInfo(entryInfo.definitionID) - local spellID = definitionInfo.spellID - local name, _, tex = GetSpellInfo(spellID) - - -- The ranks are stored on the node, but we - -- have to make sure that we're looking at the ranks for the - -- currently selected entry for the talent. - local ranks = nodeInfo.activeEntry and nodeInfo.activeEntry.entryID == entryID and nodeInfo.ranksPurchased or 0 - - local lower = name and strlowerCache[name] - if lower then - self.table[spellID] = lower - end - end + local ranksbySpellId = TMW.CNDT:GetTalentRanksBySpellID() + for spellID, ranks in pairs(ranksbySpellId) do + local name = GetSpellName(spellID) + + local lower = name and strlowerCache[name] + if lower then + self.table[spellID] = lower end end elseif GetNumTalentTabs then @@ -108,7 +83,7 @@ function Module:Table_Get() end function Module:Entry_AddToList_1(f, id) if C_ClassTalents then - local name = GetSpellInfo(id) + local name = GetSpellName(id) f.Name:SetText(name) f.insert = name @@ -351,7 +326,7 @@ if GetGlyphSocketInfo then for id, class in pairs(Glyphs) do if class == pclassId then - local name = GetSpellInfo(id) + local name = GetSpellName(id) name = strlowerCache[name] self.table[id] = name end