Skip to content

Commit

Permalink
Add tooltip:NumLines() to both RatingBuster and StatLogic cache checks (
Browse files Browse the repository at this point in the history
Fixes #32, fixes #35, fixes #46)
  • Loading branch information
raethkcj committed Aug 6, 2021
1 parent 68bd13c commit 52d31b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion RatingBuster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2767,9 +2767,11 @@ function RatingBuster:StatSummary(tooltip, name, link)
else
id = StatLogic:GetDiffID(link, profileDB.sumIgnoreEnchant, profileDB.sumIgnoreGems, red, yellow, blue, meta)
end

local numLines = tooltip:NumLines()

-- Check Cache
if cache[id] then
if cache[id] and cache[id].numLines == numLines then
if table.maxn(cache[id]) == 0 then return end
-- Write Tooltip
if profileDB.sumBlankLine then
Expand Down Expand Up @@ -2929,6 +2931,7 @@ function RatingBuster:StatSummary(tooltip, name, link)
------------------------
-- Build Output Table --
local output = {}
output.numLines = numLines
for _, t in ipairs(summary) do
local n, s, d1, d2, ispercent = t.name, t.sum, t.diff1, t.diff2, t.ispercent
local right, left
Expand Down
10 changes: 7 additions & 3 deletions libs/StatLogic-1.0/StatLogic-1.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4144,15 +4144,21 @@ function StatLogic:GetSum(item, table)
table = table or new()
setmetatable(table, statTableMetatable)

tip:ClearLines() -- this is required or SetX won't work the second time its called
tip:SetHyperlink(link)

local numLines = tip:NumLines()

-- Get data from cache if available
if cache[link] then
if cache[link] and cache[link].numLines == numLines then
copyTable(table, cache[link])
return table
end

-- Set metadata
table.itemType = itemType
table.link = link
table.numLines = numLines

-- Don't scan Relics because they don't have general stats
if itemType == "INVTYPE_RELIC" then
Expand All @@ -4161,8 +4167,6 @@ function StatLogic:GetSum(item, table)
end

-- Start parsing
tip:ClearLines() -- this is required or SetX won't work the second time its called
tip:SetHyperlink(link)
print(link)
for i = 2, tip:NumLines() do
local text = tip[i]:GetText()
Expand Down

0 comments on commit 52d31b3

Please sign in to comment.