Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions spec/System/TestItemMods_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1103,4 +1103,22 @@ describe("TetsItemMods", function()
assert.is_not_nil(sentinel)
assert.are.equals(1, countSupport(sentinel, "SupportMinionDamage"))
end)
-- #10310
it("an item's own ExtraSupport for a support gem does not disable that support elsewhere", function()
addItem("Supporting Gloves\nSpiked Gloves\nGrants Level 20 Sunder")
build.skillsTab:PasteSocketGroup("Slot: Gloves\nFist of War 20/0 1\n")
runCallback("OnFrame")

local sunder = findActiveSkill("Sunder")
assert.is_not_nil(sunder)
assert.is_true(hasSupport(sunder, "SupportFistofWar"))

addItem("Breaking Body Armour\nSimple Robe\nSkills from Equipped Body Armour are Supported by Level 20 Fist of War")
build.skillsTab:PasteSocketGroup("Slot: Body Armour\nHeavy Strike 20/0 1\n")
runCallback("OnFrame")

sunder = findActiveSkill("Sunder")
assert.is_not_nil(sunder)
assert.is_true(hasSupport(sunder, "SupportFistofWar"))
end)
end)
13 changes: 12 additions & 1 deletion src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,12 @@ function calcs.initEnv(build, mode, override, specEnv)
local supportLists = { }
local groupCfgList = { }
local processedSockets = {}
-- granted effects normally refer to the global tables in data.skills,
-- which means that modifying them will do so permanently until the
-- client is restarted. this avoids that by mapping from the original
-- table to a modified table.
---@type table<table, table>
local fromItemReplacements = {}
-- Process support gems adding them to applicable support lists
for index, group in ipairs(build.skillsTab.socketGroupList) do
local slot = group.slot and build.itemsTab.slots[group.slot]
Expand Down Expand Up @@ -1634,7 +1640,12 @@ function calcs.initEnv(build, mode, override, specEnv)
grantedEffect = env.data.skills["Support"..value.skillId]
end
if value and grantedEffect then -- Only item ExtraSupport gems should be flagged as fromItem. Imbued gems do not pass this check
grantedEffect.fromItem = true
if not fromItemReplacements[grantedEffect] then
local taggedGrantedEffect = copyTable(grantedEffect, true)
taggedGrantedEffect.fromItem = true
fromItemReplacements[grantedEffect] = taggedGrantedEffect

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Fireball and a level 15 Added Cold Damage gem socketed together in Bitterdream, this change applies Added Cold Damage twice. In this reproduction, enabling the gem raises average damage from 1413.86 to 1945.02 and mana cost from 41 to 49; before this change, enabling it changes neither value.

The copied support definition is no longer recognized as the same support by addBestSupport, so both copies enter the calculation.

AI-assisted review disclosure: This finding was identified during a review using OpenAI Codex and confirmed with a focused reproduction.

end
grantedEffect = fromItemReplacements[grantedEffect]
end
if grantedEffect then
for _, targetList in ipairs(targetListList) do
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ function specCopy(env)
end

-- Wipe all keys from the table and return it, or return a new table if no table
-- provided. This is useful to avoid alllocations in hot paths if a table can be reused. Using LuaJIT's `table.clear()` is another alternative to this, but this performs similarly on small tables, or tables which are often already empty.
-- provided. This is useful to avoid allocations in hot paths if a table can be reused. Using LuaJIT's `table.clear()` is another alternative to this, but this performs similarly on small tables, or tables which are often already empty.
---@param tbl table?
---@return table tbl
function wipeTable(tbl)
Expand Down
Loading