diff --git a/TradeSkillMaster_AuctionDB/Modules/data.lua b/TradeSkillMaster_AuctionDB/Modules/data.lua index 3a975cc..1c660d0 100644 --- a/TradeSkillMaster_AuctionDB/Modules/data.lua +++ b/TradeSkillMaster_AuctionDB/Modules/data.lua @@ -169,7 +169,7 @@ function Data:ProcessExternalScanData(scanData, groupItems, scanTime) end if not next(data) then return end - Data:ProcessData(data, groupSet, nil, scanTime or time()) + Data:ProcessData(data, groupSet, nil, scanTime or time(), true) end --- Process a table of new market scan data. @@ -177,11 +177,12 @@ end -- @param[opt] groupItems Affects how the minBuyout data is wiped. Use nil for regular behavior. -- @param[opt] verifyNewAlgorithm Boolean 'true' if you want to benchmark and verify the new market value algorithm. -- @param[opt] scanTime Unix time to use for lastScan values. -function Data:ProcessData(scanData, groupItems, verifyNewAlgorithm, scanTime) +-- @param[opt] skipMinBuyoutWipe If true, do not wipe minBuyout data before processing. +function Data:ProcessData(scanData, groupItems, verifyNewAlgorithm, scanTime, skipMinBuyoutWipe) -- If we're currently processing data, retry in 0.2 seconds. -- NOTE: This will retry itself over and over until it's able to process. if TSM.processingData then - return TSMAPI:CreateTimeDelay(0.2, function() Data:ProcessData(scanData, groupItems, verifyNewAlgorithm, scanTime) end) + return TSMAPI:CreateTimeDelay(0.2, function() Data:ProcessData(scanData, groupItems, verifyNewAlgorithm, scanTime, skipMinBuyoutWipe) end) end @@ -191,24 +192,26 @@ function Data:ProcessData(scanData, groupItems, verifyNewAlgorithm, scanTime) -- NOTE: It's no problem if we leave some items empty with "nil" minBuyout -- values. That's how TSM is supposed to work, with items having an empty "minBuyout" -- if there wasn't any "minBuyout" data for that item in the newest data batch. - 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. + 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. + TSM:DecodeItemData(itemID) + TSM.data[itemID].minBuyout = nil -- Erase its stored minBuyout value. + TSM:EncodeItemData(itemID) + end + end + else + -- Wipe data for all items in memory, regardless of whether they're actually + -- included in the incoming scan data or not... + for itemID, data in pairs(TSM.data) do TSM:DecodeItemData(itemID) - TSM.data[itemID].minBuyout = nil -- Erase its stored minBuyout value. + data.minBuyout = nil -- Directly updates TSM.data[itemID] via reference. TSM:EncodeItemData(itemID) end end - else - -- Wipe data for all items in memory, regardless of whether they're actually - -- included in the incoming scan data or not... - for itemID, data in pairs(TSM.data) do - TSM:DecodeItemData(itemID) - data.minBuyout = nil -- Directly updates TSM.data[itemID] via reference. - TSM:EncodeItemData(itemID) - end end