Skip to content

Commit b3c6114

Browse files
committed
Skip UI path rebuilds for jewel tooltip specs
Tooltip comparison specs only need calc state, but radius jewel comparisons were still rebuilding passive tree UI paths for every temporary spec. Skip that path rebuild while preserving socket distance recomputation for Split Personality-style jewel scaling.
1 parent 37b9f93 commit b3c6114

3 files changed

Lines changed: 69 additions & 6 deletions

File tree

spec/System/TestRadiusJewelStatDiff_spec.lua

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ local function newPlainJewel()
201201
"Implicits: 0\n")
202202
end
203203

204+
local function newSplitPersonality()
205+
return new("Item", "Rarity: UNIQUE\n" ..
206+
"Split Personality\n" ..
207+
"Crimson Jewel\n" ..
208+
"Implicits: 0\n" ..
209+
"+5 to Strength\n" ..
210+
"This Jewel's Socket has 25% increased effect per Allocated Passive Skill between it and your Class' starting location\n")
211+
end
212+
204213
-- Helper: minimal Impossible Escape item. Uses "Radius: Small" and targets
205214
-- a specific keystone. The parser populates both impossibleEscapeKeystone
206215
-- and impossibleEscapeKeystones from the "in Radius of X" mod.
@@ -695,4 +704,50 @@ describe("TestRadiusJewelStatDiff", function()
695704
end
696705
end)
697706

707+
it("AddItemTooltip skips UI path rebuilds for temporary radius jewel specs", function()
708+
local spec, sockets = setupAllocatedSockets(2)
709+
710+
local radiusItem = newThreadOfHope()
711+
local radiusSlot = equipJewelInSocket(radiusItem, sockets[1])
712+
local splitItem = newSplitPersonality()
713+
equipJewelInSocket(splitItem, sockets[2])
714+
spec:BuildAllDependsAndPaths()
715+
runCallback("OnFrame")
716+
717+
assert.is_true((spec.nodes[sockets[2].id].distanceToClassStart or 0) > 0,
718+
"Split Personality socket should have a class-start distance in the base spec")
719+
720+
local originalSlotOnlyTooltips = main.slotOnlyTooltips
721+
main.slotOnlyTooltips = true
722+
local specClass = getmetatable(spec)
723+
local originalBuildPathFromNode = specClass.BuildPathFromNode
724+
local originalSetNodeDistanceToClassStart = specClass.SetNodeDistanceToClassStart
725+
local buildPathCalls = 0
726+
local distanceCalls = 0
727+
specClass.BuildPathFromNode = function(self, ...)
728+
buildPathCalls = buildPathCalls + 1
729+
return originalBuildPathFromNode(self, ...)
730+
end
731+
specClass.SetNodeDistanceToClassStart = function(self, ...)
732+
distanceCalls = distanceCalls + 1
733+
return originalSetNodeDistanceToClassStart(self, ...)
734+
end
735+
736+
local ok, err = pcall(function()
737+
local tooltip = new("Tooltip")
738+
build.itemsTab:AddItemTooltip(tooltip, radiusItem, radiusSlot)
739+
end)
740+
specClass.BuildPathFromNode = originalBuildPathFromNode
741+
specClass.SetNodeDistanceToClassStart = originalSetNodeDistanceToClassStart
742+
main.slotOnlyTooltips = originalSlotOnlyTooltips
743+
if not ok then
744+
error(err)
745+
end
746+
747+
assert.are.equals(0, buildPathCalls,
748+
"temporary tooltip specs should not rebuild UI node paths")
749+
assert.is_true(distanceCalls > 0,
750+
"temporary tooltip specs should still refresh jewel socket distances used by calc")
751+
end)
752+
698753
end)

src/Classes/ItemsTab.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,7 +3834,7 @@ local function cloneSpecForJewelComparison(spec)
38343834
local nodeCopy = setmetatable({ }, getmetatable(node))
38353835
for key, value in pairs(node) do
38363836
if key ~= "linked" and key ~= "depends" and key ~= "intuitiveLeapLikesAffecting"
3837-
and key ~= "path" and key ~= "power" then
3837+
and key ~= "path" and key ~= "pathDist" and key ~= "distanceToClassStart" and key ~= "power" then
38383838
nodeCopy[key] = value
38393839
end
38403840
end
@@ -3914,7 +3914,8 @@ local function buildSpecForJewelComparison(itemsTab, compareSlot, replacementIte
39143914
end
39153915

39163916
local ok, err = xpcall(function()
3917-
spec:BuildAllDependsAndPaths()
3917+
-- Tooltip comparison specs only need calc state; node paths are UI data.
3918+
spec:BuildAllDependsAndPaths(true)
39183919
end, debug.traceback)
39193920
if tempItemId then
39203921
itemsTab.items[tempItemId] = nil

src/Classes/PassiveSpec.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ function PassiveSpecClass:NodesInIntuitiveLeapLikeRadius(node)
10881088
end
10891089

10901090
-- Rebuilds dependencies and paths for all nodes
1091-
function PassiveSpecClass:BuildAllDependsAndPaths()
1091+
function PassiveSpecClass:BuildAllDependsAndPaths(skipNodePathRebuild)
10921092
-- This table will keep track of which nodes have been visited during each path-finding attempt
10931093
local visited = { }
10941094
local attributes = { "Dexterity", "Intelligence", "Strength" }
@@ -1546,15 +1546,22 @@ function PassiveSpecClass:BuildAllDependsAndPaths()
15461546

15471547
-- Reset and rebuild all node paths
15481548
for id, node in pairs(self.nodes) do
1549-
node.pathDist = (node.alloc and #node.intuitiveLeapLikesAffecting == 0) and 0 or 1000
1550-
node.path = nil
1549+
if skipNodePathRebuild then
1550+
node.pathDist = nil
1551+
node.path = nil
1552+
else
1553+
node.pathDist = (node.alloc and #node.intuitiveLeapLikesAffecting == 0) and 0 or 1000
1554+
node.path = nil
1555+
end
15511556
if node.isJewelSocket or node.expansionJewel then
15521557
node.distanceToClassStart = 0
15531558
end
15541559
end
15551560
for id, node in pairs(self.allocNodes) do
15561561
if #node.intuitiveLeapLikesAffecting == 0 or node.connectedToStart then
1557-
self:BuildPathFromNode(node)
1562+
if not skipNodePathRebuild then
1563+
self:BuildPathFromNode(node)
1564+
end
15581565
if node.isJewelSocket or node.expansionJewel then
15591566
self:SetNodeDistanceToClassStart(node)
15601567
end

0 commit comments

Comments
 (0)