Skip to content

Commit

Permalink
fix: unknown talent errors in tww
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Jun 23, 2024
1 parent 93abdcc commit 7ef844f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 75 deletions.
100 changes: 60 additions & 40 deletions Components/Core/Conditions/Categories/Talents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
45 changes: 10 additions & 35 deletions Components/Core/Conditions/Categories/Talents_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7ef844f

Please sign in to comment.