From 7412513cec3cde23a1b89e83f817354882f38650 Mon Sep 17 00:00:00 2001 From: Mickael Cagnion Date: Tue, 6 Oct 2026 21:57:24 +0200 Subject: [PATCH] Fix identical gem groups merging on character import When an item has unlinked sockets holding the same gems, ImportSocketedItems matched each link group against the socket groups already in the build, including those it had just added for the same item. Every group after the first was treated as a reimport of that group, so three unlinked Raise Spectre became one socket group. A socket group matched or added for the current item is no longer a candidate, so each link group keeps its own socket group, on a fresh import and when reimporting without deleting skills. --- spec/System/TestImportReimport_spec.lua | 22 ++++++++++++++++++++++ src/Classes/ImportTab.lua | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/spec/System/TestImportReimport_spec.lua b/spec/System/TestImportReimport_spec.lua index 9ae82d037c0..dbb2ab004f1 100644 --- a/spec/System/TestImportReimport_spec.lua +++ b/spec/System/TestImportReimport_spec.lua @@ -253,4 +253,26 @@ Blight 20/0 1 table.insert(build.itemsTab.itemSetOrderList, itemSet.id) assertReimportPreservesSkillSubstate("Weapon 1", "Driftwood Wand", "Weapon", "Animate Weapon", "skillMinionItemSet", itemSet.id) end) + + it("keeps one socket group per unlinked socket holding the same gem when reimporting without deleting skills", function() + -- One matching group, as left by an import that merged the unlinked sockets + build.skillsTab:PasteSocketGroup([[ +Slot: Weapon 1 +Raise Spectre 20/0 1 +]]) + runCallback("OnFrame") + + local wand = makeImportItem("Driftwood Wand", "Weapon", { + makeSocketedGemEntry(0, false, "Raise Spectre", 20), + makeSocketedGemEntry(1, false, "Raise Spectre", 20), + makeSocketedGemEntry(2, false, "Raise Spectre", 20), + }) + for index, socket in ipairs(wand.sockets) do + socket.group = index - 1 + end + build.importTab:ImportItemsAndSkills(buildImportPayload({ wand }), false, false, true) + runCallback("OnFrame") + + assert.are.equal(3, #build.skillsTab.socketGroupList) + end) end) diff --git a/src/Classes/ImportTab.lua b/src/Classes/ImportTab.lua index a44f91bc0aa..2ff7ddd4138 100644 --- a/src/Classes/ImportTab.lua +++ b/src/Classes/ImportTab.lua @@ -1865,11 +1865,13 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName) end -- Import the socket groups + -- A socket group matched or added for this item is not matched again, so unlinked sockets holding the same gems stay separate groups + local claimedGroups = { } for _, itemSocketGroup in pairs(itemSocketGroupList) do -- Check if this socket group matches an existing one local repGroup for index, socketGroup in pairs(self.build.skillsTab.socketGroupList) do - if #socketGroup.gemList == #itemSocketGroup.gemList and (not socketGroup.slot or socketGroup.slot == slotName) then + if not claimedGroups[socketGroup] and #socketGroup.gemList == #itemSocketGroup.gemList and (not socketGroup.slot or socketGroup.slot == slotName) then local match = true for gemIndex, gem in pairs(socketGroup.gemList) do if gem.nameSpec:lower() ~= itemSocketGroup.gemList[gemIndex].nameSpec:lower() then @@ -1893,6 +1895,7 @@ function ImportTabClass:ImportSocketedItems(item, socketedItems, slotName) else t_insert(self.build.skillsTab.socketGroupList, itemSocketGroup) end + claimedGroups[repGroup or itemSocketGroup] = true self.build.skillsTab:ProcessSocketGroup(itemSocketGroup) end end