improved scan performance, some refactoring

This commit is contained in:
Simon Hirsig
2015-10-16 10:28:49 +02:00
parent 87cbb13a97
commit 598861f56f
3 changed files with 19 additions and 19 deletions
+5 -8
View File
@@ -75,18 +75,16 @@ function Aux.buy.SearchButton_onclick()
on_page_update = function(page)
current_page = page
end,
on_start_page = function(ok, page, total_pages)
on_start_page = function(page, total_pages)
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages and ' out of ' .. total_pages or '') .. ' ...')
return ok()
end,
on_read_auction = function(ok, i)
on_read_auction = function(i)
local auction_item = Aux.info.auction_item(i)
if auction_item then
if (auction_item.name == search_query.name or search_query.name == '' or not AuxBuyExactCheckButton:GetChecked()) and tooltip_match(tooltip_patterns, auction_item.tooltip) then
process_auction(auction_item, current_page)
end
end
return ok()
end,
on_complete = function()
entries = entries or {}
@@ -197,11 +195,11 @@ function find_auction(entry, buyout_mode, express_mode)
on_page_update = function(page)
current_page = page
end,
on_read_auction = function(ok, i)
on_read_auction = function(i, ctrl)
local auction_item = Aux.info.auction_item(i)
if not auction_item then
return ok()
return
end
local stack_size = auction_item.charges or auction_item.count
@@ -217,6 +215,7 @@ function find_auction(entry, buyout_mode, express_mode)
local key = Aux.auction_key(auction_item.tooltip, stack_size, auction_amount)
if key == order_key then
ctrl.suspend()
found = true
if express_mode then
@@ -244,8 +243,6 @@ function find_auction(entry, buyout_mode, express_mode)
end
AuxBuyConfirmationActionButton:Enable()
end
else
return ok()
end
end,
on_complete = function()
+12 -7
View File
@@ -66,16 +66,21 @@ function wait_for_complete_results(k)
end
function wait_for_callback(f, args, k)
local ok
local ok = true
if not f then
ok = true
else
tinsert(args, 1, function() ok = true end)
if f then
tinsert(args, {
suspend = function() ok = false end,
resume = function() ok = true end,
})
f(unpack(args))
end
return controller().wait(function() return ok end, k)
if ok then
return k()
else
return controller().wait(function() return ok end, k)
end
end
function scan()
@@ -143,4 +148,4 @@ function submit_query(k)
else
return k()
end
end
end
+2 -4
View File
@@ -341,17 +341,15 @@ function refresh_entries()
subclass = subclass_index,
},
page = 0,
on_start_page = function(k, page, total_pages)
on_start_page = function(page, total_pages)
set_message('Scanning auctions: page ' .. page + 1 .. (total_pages and ' out of ' .. total_pages or '') .. ' ...')
return k()
end,
on_read_auction = function(k, i)
on_read_auction = function(i)
local auction_item = Aux.info.auction_item(i)
if auction_item and auction_item.name == name then
local stack_size = auction_item.charges or auction_item.count
record_auction(auction_item.name, stack_size, auction_item.buyout_price, auction_item.duration, auction_item.owner)
end
return k()
end,
on_abort = function()
auxSellEntries[name] = nil