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