From 978e8f59d831dc18885b8048f00290f46bbcc855 Mon Sep 17 00:00:00 2001 From: Mickael Cagnion Date: Tue, 24 Nov 2026 21:04:54 +0100 Subject: [PATCH 1/3] Remember the Trader link count for each slot The Query Options popup restores the previous max price, max level and empty socket count, but "# of Links" came back empty on every search. Remember it per slot: the links filter is exact, so a 6-link body armour value carried over to a helmet search would match nothing. --- spec/System/TestTradeQueryGenerator_spec.lua | 25 ++++++++++++++++++++ src/Classes/TradeQueryGenerator.lua | 5 ++++ 2 files changed, 30 insertions(+) diff --git a/spec/System/TestTradeQueryGenerator_spec.lua b/spec/System/TestTradeQueryGenerator_spec.lua index 4f3c035b5eb..dfa09656411 100644 --- a/spec/System/TestTradeQueryGenerator_spec.lua +++ b/spec/System/TestTradeQueryGenerator_spec.lua @@ -58,6 +58,31 @@ describe("TradeQueryGenerator", function() end) end) + describe("Query options", function() + it("remembers the link count for the next search of the same slot", function() + local queryGen = new("TradeQueryGenerator"):TradeQueryGenerator({ itemsTab = { items = { } } }) + queryGen.StartQuery = function() end + local slot = { slotName = "Body Armour" } + local context = { + slotTbl = { slotName = "Body Armour", alreadyCorrupted = false }, + controls = { tradeTypeSelection = { selIndex = 1 } }, + } + queryGen:RequestQuery(slot, context, { }, function() end) + main.popups[1].controls.links:SetText("6") + main.popups[1].controls.generateQuery:Click() + + queryGen:RequestQuery(slot, context, { }, function() end) + assert.are.equal("6", main.popups[1].controls.links.buf) + main:ClosePopup() + + queryGen:RequestQuery({ slotName = "Helmet" }, { + slotTbl = { slotName = "Helmet", alreadyCorrupted = false }, + }, { }, function() end) + assert.are.equal("", main.popups[1].controls.links.buf) + main:ClosePopup() + end) + end) + describe("WeightedRatioOutputs", function() local maxStatIncrease diff --git a/src/Classes/TradeQueryGenerator.lua b/src/Classes/TradeQueryGenerator.lua index 097a2e7f948..54692289166 100644 --- a/src/Classes/TradeQueryGenerator.lua +++ b/src/Classes/TradeQueryGenerator.lua @@ -158,6 +158,8 @@ function TradeQueryGeneratorClass:TradeQueryGenerator(queryTab) self.lastMaxPrice = nil self.lastMaxPriceTypeIndex = nil self.lastMaxLevel = nil + -- Remembered per slot: a 6-link body armour search must not leave 6 links on a helmet search. + self.lastLinksBySlot = { } return self end @@ -1329,6 +1331,8 @@ Remove: %s will be removed from the search results.]], term, term, term) if not slot.slotName:find("Belt") and not slot.slotName:find("Ring") and not slot.slotName:find("Amulet") then controls.links = new("EditControl"):EditControl({"TOPLEFT",lastItemAnchor,"BOTTOMLEFT"}, {0, 5, 70, 18}, nil, nil, "%D") + local lastLinks = self.lastLinksBySlot[slot.slotName] + controls.links.buf = lastLinks and tostring(lastLinks) or "" controls.linksLabel = new("LabelControl"):LabelControl({"RIGHT",controls.links,"LEFT"}, {-5, 0, 0, 16}, "^7# of Links:") updateLastAnchor(controls.links) end @@ -1409,6 +1413,7 @@ Remove: %s will be removed from the search results.]], term, term, term) end if controls.links and controls.links.buf then options.links = tonumber(controls.links.buf) + self.lastLinksBySlot[slot.slotName] = options.links end if controls.includeAllWEMods then options.includeAllWEMods = controls.includeAllWEMods.state From 80a21da1e7c11dc34f5fd06b9573beb3b025d5ec Mon Sep 17 00:00:00 2001 From: Mickael Cagnion Date: Tue, 24 Nov 2026 21:04:54 +0100 Subject: [PATCH 2/3] Remember cleared Trader link filters --- spec/System/TestTradeQueryGenerator_spec.lua | 43 ++++++++++++-------- src/Classes/TradeQueryGenerator.lua | 4 +- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/spec/System/TestTradeQueryGenerator_spec.lua b/spec/System/TestTradeQueryGenerator_spec.lua index dfa09656411..f1bb2f2308a 100644 --- a/spec/System/TestTradeQueryGenerator_spec.lua +++ b/spec/System/TestTradeQueryGenerator_spec.lua @@ -59,27 +59,34 @@ describe("TradeQueryGenerator", function() end) describe("Query options", function() - it("remembers the link count for the next search of the same slot", function() + it("uses remembered links in the next filter for the same slot", function() local queryGen = new("TradeQueryGenerator"):TradeQueryGenerator({ itemsTab = { items = { } } }) - queryGen.StartQuery = function() end - local slot = { slotName = "Body Armour" } - local context = { - slotTbl = { slotName = "Body Armour", alreadyCorrupted = false }, - controls = { tradeTypeSelection = { selIndex = 1 } }, - } - queryGen:RequestQuery(slot, context, { }, function() end) - main.popups[1].controls.links:SetText("6") - main.popups[1].controls.generateQuery:Click() - queryGen:RequestQuery(slot, context, { }, function() end) - assert.are.equal("6", main.popups[1].controls.links.buf) - main:ClosePopup() + local function runQuery(slotName, links) + local requestedOptions + queryGen.StartQuery = function(_, _, options) + requestedOptions = options + end + local context = { + slotTbl = { slotName = slotName, alreadyCorrupted = false }, + controls = { tradeTypeSelection = { selIndex = 1 } }, + } + queryGen:RequestQuery({ slotName = slotName }, context, { }, function() end) + if links ~= nil then + main.popups[1].controls.links:SetText(links) + end + main.popups[1].controls.generateQuery:Click() + return requestedOptions.links + end - queryGen:RequestQuery({ slotName = "Helmet" }, { - slotTbl = { slotName = "Helmet", alreadyCorrupted = false }, - }, { }, function() end) - assert.are.equal("", main.popups[1].controls.links.buf) - main:ClosePopup() + assert.are.equal(6, runQuery("Body Armour", "6")) + assert.are.equal(6, runQuery("Body Armour")) + assert.is_nil(runQuery("Helmet")) + assert.is_nil(runQuery("Body Armour", "")) + assert.is_nil(runQuery("Body Armour")) + assert.are.equal(6, runQuery("Body Armour", "6")) + assert.are.equal(0, runQuery("Body Armour", "0")) + assert.is_nil(runQuery("Body Armour")) end) end) diff --git a/src/Classes/TradeQueryGenerator.lua b/src/Classes/TradeQueryGenerator.lua index 54692289166..0d7a65ce6d3 100644 --- a/src/Classes/TradeQueryGenerator.lua +++ b/src/Classes/TradeQueryGenerator.lua @@ -1411,9 +1411,9 @@ Remove: %s will be removed from the search results.]], term, term, term) options.sockets = tonumber(controls.sockets.buf) self.lastSockets = options.sockets end - if controls.links and controls.links.buf then + if controls.links then options.links = tonumber(controls.links.buf) - self.lastLinksBySlot[slot.slotName] = options.links + self.lastLinksBySlot[slot.slotName] = options.links and options.links > 0 and options.links or nil end if controls.includeAllWEMods then options.includeAllWEMods = controls.includeAllWEMods.state From c9d5313899a3c146a84f88fec9fef9b1ec008eda Mon Sep 17 00:00:00 2001 From: Mickael Cagnion Date: Tue, 24 Nov 2026 21:41:57 +0100 Subject: [PATCH 3/3] Remove redundant Trader links comment --- src/Classes/TradeQueryGenerator.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Classes/TradeQueryGenerator.lua b/src/Classes/TradeQueryGenerator.lua index 0d7a65ce6d3..29c6a3afea6 100644 --- a/src/Classes/TradeQueryGenerator.lua +++ b/src/Classes/TradeQueryGenerator.lua @@ -158,7 +158,6 @@ function TradeQueryGeneratorClass:TradeQueryGenerator(queryTab) self.lastMaxPrice = nil self.lastMaxPriceTypeIndex = nil self.lastMaxLevel = nil - -- Remembered per slot: a 6-link body armour search must not leave 6 links on a helmet search. self.lastLinksBySlot = { } return self end