savedvariables refactoring

This commit is contained in:
Manuel Simon Hirsig
2017-03-18 12:24:20 +01:00
parent 57543230f3
commit 1829ce6374
10 changed files with 89 additions and 86 deletions
+4 -4
View File
@@ -126,8 +126,8 @@ function M.auction(index, query_type)
'link', link,
'itemstring', item_info.itemstring,
'item_key', item_id .. ':' .. suffix_id,
'search_signature', join(temp-A(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), aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')), ':'),
'search_signature', join(temp-A(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), aux_ignore_owner and (cache.is_player(owner) and 0 or 1) or (owner or '?')), ':'),
'sniping_signature', join(temp-A(item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (cache.is_player(owner) and 0 or 1) or (owner or '?')), ':'),
'name', name,
'texture', texture,
@@ -166,12 +166,12 @@ end
function M.bid_update(auction_record)
auction_record.high_bid = auction_record.bid_price
auction_record.blizzard_bid = auction_record.bid_price
auction_record.min_increment = min_bid_increment(auction_record.bid_price)
auction_record.min_increment = max(1, floor(auction_record.bid_price / 100) * 5)
auction_record.bid_price = auction_record.bid_price + auction_record.min_increment
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 = join(temp-A(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, aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
auction_record.search_signature = join(temp-A(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, aux_ignore_owner and (cache.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')), ':')
end
function M.set_tooltip(itemstring, owner, anchor)
+31 -10
View File
@@ -3,17 +3,38 @@ module 'aux.util.persistence'
include 'T'
include 'aux'
_G.aux_datasets = {}
_G.aux = {
player = {},
faction = {},
realm = {},
account = {},
}
do
local dataset
function M.get_dataset()
if not dataset then
local dataset_key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player')
dataset = aux_datasets[dataset_key] or T
aux_datasets[dataset_key] = dataset
end
return dataset
local cache = {account=aux.account}
function LOAD2()
do
local key = format('%s|%s', GetCVar'realmName', UnitName'player')
aux.player[key] = aux.player[key] or {}
cache.player = aux.player[key]
end
do
local key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player')
aux.faction[key] = aux.faction[key] or {}
cache.faction = aux.faction[key]
end
do
local key = GetCVar'realmName'
aux.realm[key] = aux.realm[key] or {}
cache.realm = aux.realm[key]
end
end
for scope in temp-S('player', 'faction', 'realm', 'account') do
local scope = scope
M[scope] = function(k)
cache[scope][k] = cache[scope][k]
return cache[scope][k]
end
end