Skip to content

Commit

Permalink
Fix mage talent exports being broken
Browse files Browse the repository at this point in the history
There's a "talent" at index 21 that doesn't exist, but GetNumTalents()
considers there to be 22 talents, because there's a valid index after it
at 22.

Fixes #17.
  • Loading branch information
Tharre committed Jun 9, 2024
1 parent 50e445e commit 1d64415
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions ExportStructures/Misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ end
---@return string
function Env.CreateTalentString()
local GetTalentRank = Env.GetTalentRankOrdered
local GetNumTalents = Env.GetNumTalentsFixed
local tabs = {}
for tab = 1, GetNumTalentTabs() do
local talents = {}
Expand Down
20 changes: 14 additions & 6 deletions extras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ do
temp[tab] = {}
local products = {}
for i = 1, GetNumTalents(tab) do
local name, _, tier, column = GetTalentInfo(tab, i)
local product = (tier - 1) * 4 + column
temp[tab][product] = i
table.insert(products, product)
local name, _, tier, column, _, _, _, avail, _ = GetTalentInfo(tab, i)
if avail then -- sometimes indices are empty ...
local product = (tier - 1) * 4 + column
temp[tab][product] = i
table.insert(products, product)
end
end

table.sort(products)

orderedTalentCache[tab] = {}
local j = 1
for _, product in ipairs(products) do
orderedTalentCache[tab][j] = temp[tab][product]
j = j + 1
if product then
orderedTalentCache[tab][j] = temp[tab][product]
j = j + 1
end
end
end
f:UnregisterEvent("SPELLS_CHANGED")
Expand All @@ -41,6 +45,10 @@ function Env.GetTalentRankOrdered(tab, num)
return select(5, GetTalentInfo(tab, orderedTalentCache[tab][num]))
end

function Env.GetNumTalentsFixed(tab)
return #orderedTalentCache[tab]
end

-- table extension contains
function table.contains(table, element)
for _, value in pairs(table) do
Expand Down

0 comments on commit 1d64415

Please sign in to comment.