From 2e4092c0af0eb284c1afd6454729643e6fc06391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen?= Date: Mon, 16 Feb 2026 20:47:36 +0100 Subject: [PATCH] fixes rart --- TradeSkillMaster/Core/Prices.lua | 6 ++++ .../Modules/Scanning.lua | 2 +- TradeSkillMaster_AuctionDB/Modules/data.lua | 10 +++--- .../modules/PostScan.lua | 36 +++++++++++++------ .../Modules/CraftingGUI.lua | 9 +++-- 5 files changed, 43 insertions(+), 20 deletions(-) diff --git a/TradeSkillMaster/Core/Prices.lua b/TradeSkillMaster/Core/Prices.lua index 0587fa7..8c2ea01 100644 --- a/TradeSkillMaster/Core/Prices.lua +++ b/TradeSkillMaster/Core/Prices.lua @@ -350,6 +350,10 @@ local function ParsePriceString(str, badPriceSource) TSM_PRICE_TEMP.lastPrint = time() TSM_PRICE_TEMP.loopError(origStr) end + TSM_PRICE_TEMP.num = TSM_PRICE_TEMP.num - 1 + if isTop then + TSM_PRICE_TEMP.num = nil + end return end local function isNAN(num) @@ -515,7 +519,9 @@ function TSMAPI:ParseCustomPrice(priceString, badPriceSource) end local function safeFunc(itemString) + local prevNum = TSM_PRICE_TEMP.num local success, value = pcall(func, itemString) + TSM_PRICE_TEMP.num = prevNum if success then return value end diff --git a/TradeSkillMaster_AuctionDB/Modules/Scanning.lua b/TradeSkillMaster_AuctionDB/Modules/Scanning.lua index a6f3dde..ed186da 100644 --- a/TradeSkillMaster_AuctionDB/Modules/Scanning.lua +++ b/TradeSkillMaster_AuctionDB/Modules/Scanning.lua @@ -348,7 +348,7 @@ function Scan:ProcessScanData(scanData) -- Mark the collected auction data as a new "complete scan" with today's date, -- but only if this was a normal "Full Scan" (not just a "TSM item group" scan). - if Scan.isScanning ~= "group" then + if Scan.isScanning ~= "Group" then TSM.db.realm.lastCompleteScan = time() end diff --git a/TradeSkillMaster_AuctionDB/Modules/data.lua b/TradeSkillMaster_AuctionDB/Modules/data.lua index 4085556..fce61d9 100644 --- a/TradeSkillMaster_AuctionDB/Modules/data.lua +++ b/TradeSkillMaster_AuctionDB/Modules/data.lua @@ -197,12 +197,12 @@ function Data:ProcessData(scanData, groupItems, verifyNewAlgorithm, scanTime, sk -- if there wasn't any "minBuyout" data for that item in the newest data batch. if not skipMinBuyoutWipe then if groupItems then - -- A list of items ("group scan") was provided. Wipe data for those items. - for itemString in pairs(groupItems) do - local itemID = TSMAPI:GetItemID(itemString) - if TSM.data[itemID] then -- If we have existing data for this item. + -- For group scans, only wipe items that are present in the incoming + -- payload. This avoids clearing data for timed out / missing queries. + for itemID in pairs(scanData) do + if TSM.data[itemID] then TSM:DecodeItemData(itemID) - TSM.data[itemID].minBuyout = nil -- Erase its stored minBuyout value. + TSM.data[itemID].minBuyout = nil TSM:EncodeItemData(itemID) end end diff --git a/TradeSkillMaster_Auctioning/modules/PostScan.lua b/TradeSkillMaster_Auctioning/modules/PostScan.lua index 35297db..72fe34b 100644 --- a/TradeSkillMaster_Auctioning/modules/PostScan.lua +++ b/TradeSkillMaster_Auctioning/modules/PostScan.lua @@ -156,15 +156,19 @@ function Post:ProcessItem(itemString) if toPost then local bid bid, buyout, reason = Post:GetPostPrice(itemString, operation) - local postTime = (operation.duration == 48 and 3) or (operation.duration == 24 and 2) or 1 - - for i = 1, #toPost do - local stackSize, numStacks = unpack(toPost[i]) - - -- Increase the bid/buyout based on how many items we're posting - local stackBid, stackBuyout = floor(bid * stackSize), floor(buyout * stackSize) - Post:QueueItemToPost(itemString, numStacks, stackSize, stackBid, stackBuyout, postTime, operation) - tinsert(data, { numStacks = numStacks, stackSize = stackSize, buyout = buyout, postTime = postTime }) + if not bid or not buyout then + toPost = nil + reason = reason or "invalid" + else + local postTime = (operation.duration == 48 and 3) or (operation.duration == 24 and 2) or 1 + for i = 1, #toPost do + local stackSize, numStacks = unpack(toPost[i]) + + -- Increase the bid/buyout based on how many items we're posting + local stackBid, stackBuyout = floor(bid * stackSize), floor(buyout * stackSize) + Post:QueueItemToPost(itemString, numStacks, stackSize, stackBid, stackBuyout, postTime, operation) + tinsert(data, { numStacks = numStacks, stackSize = stackSize, buyout = buyout, postTime = postTime }) + end end end @@ -203,6 +207,9 @@ function Post:ShouldPost(itemString, operation, numInBags) end local prices = TSM.Util:GetItemPrices(operation, itemString) + if not prices.minPrice or not prices.maxPrice or not prices.normalPrice or not prices.undercut then + return nil, "invalid", numInBags + end if buyout and buyout <= prices.minPrice then -- lowest is below min price if not prices.resetPrice then @@ -253,11 +260,14 @@ function Post:GetPostPrice(itemString, operation) local lowestBuyout, lowestBid, lowestOwner, isWhitelist, isPlayer = TSM.Scan:GetLowestAuction(itemString, operation) local bid, buyout, info local prices = TSM.Util:GetItemPrices(operation, itemString) + if not prices.minPrice or not prices.maxPrice or not prices.normalPrice or not prices.undercut then + return nil, nil, "invalid" + end if not lowestOwner then -- No other auctions up, default to normalPrice info = "postingNormal" buyout = prices.normalPrice - elseif prices.resetPrice and lowestBuyout <= prices.minPrice then + elseif prices.resetPrice and lowestBuyout and lowestBuyout <= prices.minPrice then -- item is below min price and a priceReset is set if operation.priceReset == "minPrice" then info = "postingResetMin" @@ -270,10 +280,14 @@ function Post:GetPostPrice(itemString, operation) error("Unknown 'below minimum' price setting.") end buyout = prices.resetPrice - elseif isPlayer or (isWhitelist and lowestBuyout - prices.undercut <= prices.maxPrice) then + elseif isPlayer or (isWhitelist and lowestBuyout and lowestBuyout - prices.undercut <= prices.maxPrice) then -- Either we already have one up or someone on the whitelist does bid, buyout = min(lowestBid, lowestBuyout), lowestBuyout info = isPlayer and "postingPlayer" or "postingWhitelist" + elseif not lowestBuyout then + -- We have an owner record but no valid buyout; treat as no reliable floor. + info = "postingNormal" + buyout = prices.normalPrice else -- we've been undercut and we are going to undercut back buyout = lowestBuyout - prices.undercut diff --git a/TradeSkillMaster_Crafting/Modules/CraftingGUI.lua b/TradeSkillMaster_Crafting/Modules/CraftingGUI.lua index 7261d54..05ab5cd 100644 --- a/TradeSkillMaster_Crafting/Modules/CraftingGUI.lua +++ b/TradeSkillMaster_Crafting/Modules/CraftingGUI.lua @@ -579,11 +579,14 @@ function GUI:CreateQueueFrame(parent) GameTooltip:AddLine(TSM.db.realm.crafts[data.spellID].name .. " (x" .. data.numQueued .. ")") local cost = TSM.Cost:GetCraftPrices(data.spellID) - if data.profit then + local profitPercText, profitPercTextM = "---", "---" + if data.profit and cost and cost > 0 then local profitPercent = data.profit / cost * 100 - local profitPercText = format("%s%.0f%%|r", color, profitPercent) + profitPercText = format("%s%.0f%%|r", color, profitPercent) local profitPercentM = data.profit / cost * data.numQueued * 100 - local profitPercTextM = format("%s%.0f%%|r", color, profitPercentM) + profitPercTextM = format("%s%.0f%%|r", color, profitPercentM) + end + if data.profit then if data.profit>0 then if moneyCoinsTooltip then GameTooltip:AddLine("Profit: " .. (TSMAPI:FormatTextMoneyIcon(data.profit, color) or "---") .. " (" .. (profitPercText or "---") .. ")")