refactoring
This commit is contained in:
+1
-1
@@ -93,6 +93,6 @@ function public.when(p, k, ...) temp=arg
|
||||
if p() then
|
||||
return k(unpack(arg))
|
||||
else
|
||||
return wait(when, p, L(k, unpack(arg)))
|
||||
return wait(when, p, k, unpack(arg))
|
||||
end
|
||||
end
|
||||
|
||||
+1
-5
@@ -181,8 +181,7 @@ function scan_wdb(item_id)
|
||||
end
|
||||
|
||||
if item_id <= MAX_ITEM_ID then
|
||||
local t0 = GetTime()
|
||||
thread(when, function() return GetTime() - t0 > .1 end, scan_wdb, item_id)
|
||||
thread(wait, 10, scan_wdb, item_id)
|
||||
else
|
||||
sort(_G.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
|
||||
end
|
||||
@@ -190,16 +189,13 @@ end
|
||||
|
||||
function public.populate_wdb(item_id)
|
||||
item_id = item_id or MIN_ITEM_ID
|
||||
|
||||
if item_id > MAX_ITEM_ID then
|
||||
log 'Cache populated.'
|
||||
return
|
||||
end
|
||||
|
||||
if not GetItemInfo('item:'..item_id) then
|
||||
log('Fetching item '..item_id..'.')
|
||||
AuxTooltip:SetHyperlink('item:'..item_id)
|
||||
end
|
||||
|
||||
thread(populate_wdb, item_id + 1)
|
||||
end
|
||||
+2
-2
@@ -9,7 +9,7 @@ do
|
||||
for old_state in present(scan_states[params.type]) do
|
||||
abort(old_state.id)
|
||||
end
|
||||
local thread_id = thread(L(wait_for_callback, params.on_scan_start, scan))
|
||||
local thread_id = thread(wait_for_callback, params.on_scan_start, scan)
|
||||
scan_states[params.type] = {
|
||||
id = thread_id,
|
||||
params = params,
|
||||
@@ -155,7 +155,7 @@ function scan_page(i)
|
||||
local send_signal, signal_received = signal()
|
||||
when(signal_received, recurse)
|
||||
place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, L(send_signal, true))
|
||||
return thread(when, later(GetTime(), 10), L(send_signal, false))
|
||||
return thread(when, later(GetTime(), 10), send_signal, false)
|
||||
elseif not query.validator or query.validator(auction_info) then
|
||||
return wait_for_callback(state.params.on_auction, auction_info, function(removed)
|
||||
if removed then
|
||||
|
||||
@@ -172,7 +172,7 @@ function start_real_time_scan(query, search, continuation)
|
||||
if search.auto_buy then
|
||||
ctrl.suspend()
|
||||
place_bid('list', auction_record.index, auction_record.buyout_price, L(ctrl.resume, true))
|
||||
thread(when, later(GetTime(), 10), L(ctrl.resume, false))
|
||||
thread(when, later(GetTime(), 10), ctrl.resume, false)
|
||||
else
|
||||
tinsert(new_records, auction_record)
|
||||
end
|
||||
@@ -268,7 +268,7 @@ function start_search(queries, continuation)
|
||||
if search.auto_buy then
|
||||
ctrl.suspend()
|
||||
place_bid('list', auction_record.index, auction_record.buyout_price, L(ctrl.resume, true))
|
||||
thread(when, later(GetTime(), 10), L(ctrl.resume, false))
|
||||
thread(when, later(GetTime(), 10), ctrl.resume, false)
|
||||
elseif getn(search.records) < 1000 then
|
||||
tinsert(search.records, auction_record)
|
||||
if getn(search.records) == 1000 then
|
||||
|
||||
Reference in New Issue
Block a user