|
|
|
@ -169,7 +169,7 @@ function Data:ProcessExternalScanData(scanData, groupItems, scanTime) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if not next(data) then return 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 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
--- Process a table of new market scan data. |
|
|
|
--- 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] 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] 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. |
|
|
|
-- @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. |
|
|
|
-- 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. |
|
|
|
-- NOTE: This will retry itself over and over until it's able to process. |
|
|
|
if TSM.processingData then |
|
|
|
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 |
|
|
|
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 |
|
|
|
-- 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" |
|
|
|
-- 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 there wasn't any "minBuyout" data for that item in the newest data batch. |
|
|
|
if groupItems then |
|
|
|
if not skipMinBuyoutWipe then |
|
|
|
-- A list of items ("group scan") was provided. Wipe data for those items. |
|
|
|
if groupItems then |
|
|
|
for itemString in pairs(groupItems) do |
|
|
|
-- A list of items ("group scan") was provided. Wipe data for those items. |
|
|
|
local itemID = TSMAPI:GetItemID(itemString) |
|
|
|
for itemString in pairs(groupItems) do |
|
|
|
if TSM.data[itemID] then -- If we have existing data for this item. |
|
|
|
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: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) |
|
|
|
TSM:EncodeItemData(itemID) |
|
|
|
end |
|
|
|
end |
|
|
|
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 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|