big refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-21 14:29:01 +02:00
parent 2b9a63fe8c
commit 590347a1e5
23 changed files with 236 additions and 263 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
aux.module 'util'
local temp, recycle, getn = g.temp, g.recycle, g.getn
local temp, recycle, getn = temp, recycle, _g.getn
function public.copy(t)
local copy = {}
@@ -9,7 +9,7 @@ function public.copy(t)
return copy
end
public.join = g.table.concat
public.join = _g.table.concat
function public.replicate(count, value)
if count > 0 then return value, replicate(count - 1, value) end
+9 -26
View File
@@ -292,7 +292,7 @@ function public.parse_query_string(str)
if input_type ~= '' then
if not parts[i + 1] or not parse_parameter(input_type, parts[i + 1]) then
if parts[i] == 'item' then
return nil, 'Invalid item name', g.aux_auctionable_items
return nil, 'Invalid item name', _g.aux_auctionable_items
elseif type(input_type) == 'table' then
return nil, 'Invalid choice for '..parts[i], input_type
else
@@ -349,18 +349,15 @@ function public.query(query_string)
blizzard_query = blizzard_query(components),
validator = validator(components),
prettified = prettified_query_string(components),
}, m.suggestions(components)
}, _m.suggestions(components)
end
function public.queries(query_string)
local parts = split(query_string, ';')
local queries = {}
for _, str in parts do
str = trim(str)
local query, _, error = query(str)
if not query then
log('Invalid filter:', error)
return
@@ -368,31 +365,21 @@ function public.queries(query_string)
tinsert(queries, query)
end
end
return queries
end
function suggestions(components)
local suggestions = {}
if components.blizzard.name and size(components.blizzard) == 1 then
tinsert(suggestions, 'exact')
end
if components.blizzard.name and size(components.blizzard) == 1 then tinsert(suggestions, 'exact') end
tinsert(suggestions, 'and')
tinsert(suggestions, 'or')
tinsert(suggestions, 'not')
tinsert(suggestions, 'tt')
tinsert(suggestions, 'and'); tinsert(suggestions, 'or'); tinsert(suggestions, 'not'); tinsert(suggestions, 'tt')
for key in filters do
tinsert(suggestions, key)
end
for key in filters do tinsert(suggestions, key) end
-- classes
if not components.blizzard.class then
for _, class in {GetAuctionItemClasses()} do
tinsert(suggestions, class)
end
for _, class in {GetAuctionItemClasses()} do tinsert(suggestions, class) end
end
-- subclasses
@@ -410,20 +397,16 @@ function suggestions(components)
end
-- usable
if not components.blizzard.usable then
tinsert(suggestions, 'usable')
end
if not components.blizzard.usable then tinsert(suggestions, 'usable') end
-- rarities
if not components.blizzard.quality then
for i=0,4 do
tinsert(suggestions, getglobal('ITEM_QUALITY'..i..'_DESC'))
end
for i=0,4 do tinsert(suggestions, getglobal('ITEM_QUALITY'..i..'_DESC')) end
end
-- item names
if size(components.blizzard) + getn(components.post) == 1 and components.blizzard.name == '' then
for _, name in g.aux_auctionable_items do
for _, name in _g.aux_auctionable_items do
tinsert(suggestions, name..'/exact')
end
end
+3 -3
View File
@@ -121,8 +121,8 @@ function public.auction(index, query_type)
link = link,
itemstring = item_info.itemstring,
item_key = item_id..':'..suffix_id,
search_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), g.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')}, ':'),
sniping_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, g.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'),
search_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), _g.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')}, ':'),
sniping_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _g.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'),
name = name,
texture = texture,
@@ -166,7 +166,7 @@ function public.bid_update(auction_record)
auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity
auction_record.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity
auction_record.high_bidder = 1
auction_record.search_signature = table.concat({auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, g.aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':')
auction_record.search_signature = table.concat({auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, _g.aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':')
end
function public.set_tooltip(itemstring, owner, anchor)
+3 -3
View File
@@ -1,6 +1,6 @@
aux.module 'persistence'
g.aux_datasets = {}
_g.aux_datasets = {}
do
local realm, faction
@@ -17,8 +17,8 @@ end
function public.load_dataset()
local dataset_key = dataset_key
g.aux_datasets[dataset_key] = g.aux_datasets[dataset_key] or {}
return g.aux_datasets[dataset_key]
_g.aux_datasets[dataset_key] = _g.aux_datasets[dataset_key] or {}
return _g.aux_datasets[dataset_key]
end
function public.read(schema, str)