storage export perf fix
This commit is contained in:
@@ -18,6 +18,9 @@ function ExportTask:cycle(context)
|
|||||||
|
|
||||||
for node in context.storage:filterActive('machine', filter) do
|
for node in context.storage:filterActive('machine', filter) do
|
||||||
tasks:add(function()
|
tasks:add(function()
|
||||||
|
|
||||||
|
local slots
|
||||||
|
|
||||||
for _, entry in pairs(node.exports) do
|
for _, entry in pairs(node.exports) do
|
||||||
|
|
||||||
if not entry.filter then
|
if not entry.filter then
|
||||||
@@ -66,13 +69,42 @@ function ExportTask:cycle(context)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function exportItems()
|
local function exportItems()
|
||||||
|
local function isPossible(key)
|
||||||
|
local filterItem = itemDB:get(key)
|
||||||
|
|
||||||
|
if not node.adapter.__size then
|
||||||
|
node.adapter.__size = node.adapter.size()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- note that this does not guarantee a match - as
|
||||||
|
-- we don't have full meta of item in slot
|
||||||
|
for i = 1, node.adapter.__size do
|
||||||
|
local slot = slots[i]
|
||||||
|
if (not slot or slot.name == filterItem.name and
|
||||||
|
(entry.ignoreDamage or slot.damage == filterItem.damage) and
|
||||||
|
slot.count < filterItem.maxCount) then
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for key in pairs(entry.filter) do
|
for key in pairs(entry.filter) do
|
||||||
local items = Milo:getMatches(itemDB:splitKey(key), entry)
|
if not slots then
|
||||||
for _,item in pairs(items) do
|
slots = node.adapter.list()
|
||||||
if context.storage:export(node, nil, item.count, item) == 0 then
|
end
|
||||||
-- TODO: really shouldn't break here as there may be room in other slots
|
if isPossible(key) then
|
||||||
-- leaving for now for performance reasons
|
local items = Milo:getMatches(itemDB:splitKey(key), entry)
|
||||||
break
|
for _,item in pairs(items) do
|
||||||
|
if context.storage:export(node, nil, item.count, item) == 0 then
|
||||||
|
-- TODO: really shouldn't break here as there may be room in other slots
|
||||||
|
-- leaving for now for performance reasons
|
||||||
|
|
||||||
|
break
|
||||||
|
else
|
||||||
|
-- refresh the slots
|
||||||
|
slots = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user