From 12bf0486067e024be943cf1c394b194bd7dcd602 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 29 Aug 2016 20:57:05 +0200 Subject: [PATCH] refactoring --- control.lua | 2 +- core/cache.lua | 6 +----- core/scan.lua | 4 ++-- tabs/search/results.lua | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/control.lua b/control.lua index a7ac89d..44119e9 100644 --- a/control.lua +++ b/control.lua @@ -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 diff --git a/core/cache.lua b/core/cache.lua index 49ea53e..9edac02 100644 --- a/core/cache.lua +++ b/core/cache.lua @@ -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 \ No newline at end of file diff --git a/core/scan.lua b/core/scan.lua index 7f8a360..ad2465d 100644 --- a/core/scan.lua +++ b/core/scan.lua @@ -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 diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 19d8ee0..534ce37 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -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