Mercurial > wow > ouroloot
changeset 107:35b55c6f5551
Cleanups and reminders to myself.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Mon, 06 Aug 2012 13:14:38 -0400 |
parents | 095ee38508e8 |
children | 04ccd12c2a41 |
files | core.lua gui.lua options.lua verbage.lua |
diffstat | 4 files changed, 63 insertions(+), 67 deletions(-) [+] |
line wrap: on
line diff
--- a/core.lua Sun Aug 05 19:08:53 2012 +0000 +++ b/core.lua Mon Aug 06 13:14:38 2012 -0400 @@ -376,22 +376,13 @@ local error = addon.error local assert = addon.assert --- for speeding up local loads, not because I think _G will change -local _G = _G -local type = _G.type -local select = _G.select -local pairs = _G.pairs -local ipairs = _G.ipairs -local tinsert = _G.table.insert -local tremove = _G.table.remove -local tostring = _G.tostring -local tonumber = _G.tonumber -local wipe = _G.table.wipe +local type, select, next, pairs, ipairs, tinsert, tremove, tostring, tonumber, wipe = + type, select, next, pairs, ipairs, table.insert, table.remove, tostring, tonumber, table.wipe local pprint, tabledump = addon.pprint, flib.tabledump -local CopyTable = _G.CopyTable -local GetNumRaidMembers = _G.GetNumGroupMembers or _G.GetNumRaidMembers -local IsInRaid = _G.IsInRaid or (function() return GetNumRaidMembers() > 0 end) +local CopyTable = CopyTable +local GetNumRaidMembers = GetNumGroupMembers or GetNumRaidMembers +local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end) -- En masse forward decls of symbols defined inside local blocks local _register_bossmod, makedate, create_new_cache, _init, _log, _do_loot_metas local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision @@ -423,18 +414,18 @@ do local hypertext_format_str = "|HOuroLoot:%d|h%s[%s]|r|h" local func_map = {} --_G.setmetatable({}, {__mode = 'k'}) - local text_map = {} _G.setmetatable({}, {__mode = 'v'}) - local base = _G.newproxy(true) - _G.getmetatable(base).__tostring = function(ud) return text_map[ud] end + local text_map = setmetatable({}, {__mode = 'v'}) + local base = newproxy(true) + getmetatable(base).__tostring = function(ud) return text_map[ud] end --@debug@ -- auto collecting these tokens is an interesting micro-optimization but not yet - _G.getmetatable(base).__index = { + getmetatable(base).__index = { ['done'] = function (ud) text_map[ud] = nil func_map[ud] = nil end, } - _G.getmetatable(base).__gc = function(ud) + getmetatable(base).__gc = function(ud) print("Collecting hyperlink object <",tostring(ud),">") end --@end-debug@ @@ -450,7 +441,7 @@ -- -- This is largely an excuse to fool around with Lua data constructs. function addon.format_hypertext (text, color, func) - local ret = _G.newproxy(base) + local ret = newproxy(base) local num = #text_map + 1 text_map[ret] = hypertext_format_str:format (num, type(color)=='number' and ITEM_QUALITY_COLORS[color].hex or color, @@ -468,7 +459,7 @@ amusingly, print()'ing the fullstring below as a debugging aid yields another clickable link, yay data reproducability ]] - local strsplit = _G.strsplit + local strsplit = strsplit DEFAULT_CHAT_FRAME:HookScript("OnHyperlinkClick", function(self, link, fullstring, mousebutton) local ltype, arg = strsplit(":",link) if ltype ~= "OuroLoot" then return end @@ -622,7 +613,7 @@ -- this into a weakly-keyed table. mt = { __metatable = 'Should be using setmode.' } - g_uniques = _G.setmetatable (m_reset{}, mt) + g_uniques = setmetatable (m_reset{}, mt) end @@ -648,8 +639,8 @@ ]] do local caches = {} - local cleanup_group = _G.AnimTimerFrame:CreateAnimationGroup() - local time, next = _G.time, _G.next + local cleanup_group = AnimTimerFrame:CreateAnimationGroup() + local time, next = time, next local new, del = flib.new, flib.del cleanup_group:SetLooping("REPEAT") cleanup_group:SetScript("OnLoop", function(cg) @@ -733,16 +724,16 @@ _G.OL = self _G.g_uniques = g_uniques end - _log = _G.OuroLootSV_log + _log = OuroLootSV_log -- VARIABLES_LOADED has fired by this point; test if we're doing something like -- relogging during a raid and already have collected loot data - local OuroLootSV = _G.OuroLootSV + local OuroLootSV = OuroLootSV g_restore_p = OuroLootSV ~= nil self.dprint('flow', "oninit sets restore as", g_restore_p) -- Primarily for plugins, but can be of use to me also... - self.callbacks = _G.LibStub("CallbackHandler-1.0"):New(self) + self.callbacks = LibStub("CallbackHandler-1.0"):New(self) --function self.callbacks:OnUsed (target_aka_self, eventname) end --function self.callbacks:OnUnused (target_aka_self, eventname) end @@ -761,7 +752,7 @@ else virgin = nil end - self.db = _G.LibStub("AceDB-3.0"):New("OuroLootOptsDB", option_defaults , --[[Default=]]true) + self.db = LibStub("AceDB-3.0"):New("OuroLootOptsDB", option_defaults , --[[Default=]]true) self.db.RegisterCallback (self, "OnNewProfile", function() self:Print(new_profile_warning) end) @@ -790,7 +781,7 @@ end self.history_all = self.history_all or _G.OuroLootSV_hist or {} - local r = self:load_assert (_G.GetRealmName(), "how the freak does GetRealmName() fail?") + local r = self:load_assert (GetRealmName(), "how the freak does GetRealmName() fail?") self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r) self.history = self.history_all[r] @@ -960,16 +951,16 @@ ]] -- LOOT_ITEM = "%s receives loot: %s." --> (.+) receives loot: (.+)%. - g_LOOT_ITEM_ss = _G.LOOT_ITEM:gsub('%.$','%%.'):gsub('%%s','(.+)') + g_LOOT_ITEM_ss = LOOT_ITEM:gsub('%.$','%%.'):gsub('%%s','(.+)') -- LOOT_ITEM_MULTIPLE = "%s receives loot: %sx%d." --> (.+) receives loot: (.+)(x%d+)%. - g_LOOT_ITEM_MULTIPLE_sss = _G.LOOT_ITEM_MULTIPLE:gsub('%.$','%%.'):gsub('%%s','(.+)'):gsub('x%%d','(x%%d+)') + g_LOOT_ITEM_MULTIPLE_sss = LOOT_ITEM_MULTIPLE:gsub('%.$','%%.'):gsub('%%s','(.+)'):gsub('x%%d','(x%%d+)') -- LOOT_ITEM_SELF = "You receive loot: %s." --> You receive loot: (.+)%. - g_LOOT_ITEM_SELF_s = _G.LOOT_ITEM_SELF:gsub('%.$','%%.'):gsub('%%s','(.+)') + g_LOOT_ITEM_SELF_s = LOOT_ITEM_SELF:gsub('%.$','%%.'):gsub('%%s','(.+)') -- LOOT_ITEM_SELF_MULTIPLE = "You receive loot: %sx%d." --> You receive loot: (.+)(x%d+)%. - g_LOOT_ITEM_SELF_MULTIPLE_ss = _G.LOOT_ITEM_SELF_MULTIPLE:gsub('%.$','%%.'):gsub('%%s','(.+)'):gsub('x%%d','(x%%d+)') + g_LOOT_ITEM_SELF_MULTIPLE_ss = LOOT_ITEM_SELF_MULTIPLE:gsub('%.$','%%.'):gsub('%%s','(.+)'):gsub('x%%d','(x%%d+)') --[[ Stick something in the Blizzard addons options list, where most users @@ -983,15 +974,15 @@ button:SetWidth(150) button:SetHeight(22) button:SetScript("OnClick", function() - _G.InterfaceOptionsFrameCancel:Click() - _G.HideUIPanel(GameMenuFrame) + InterfaceOptionsFrameCancel:Click() + HideUIPanel(GameMenuFrame) addon:OpenMainDisplayToTab"Options" end) button:SetText('"/ouroloot opt"') button:SetPoint("TOPLEFT",20,-20) _b:SetScript("OnShow",nil) end) - _G.InterfaceOptions_AddCategory(bliz) + InterfaceOptions_AddCategory(bliz) -- Maybe load up g_uniques now? if opts.precache_history_uniques then @@ -1155,7 +1146,7 @@ -- For data safety, we replace any table arguments with read-only proxies -- before passing them to the callbacks. The goal is to prevent accidents, -- not fraud. - local unpack, setmetatable = _G.unpack, _G.setmetatable + local unpack, setmetatable = unpack, setmetatable local mtnewindex = function() --[[local]]error("This table is read-only", 3) end local function make_readonly (t) return setmetatable({}, { @@ -1191,13 +1182,13 @@ _G.OuroLootOptsDB = nil _G.OuroLootSV_hist = nil _G.OuroLootSV_log = nil - _G.ReloadUI() + ReloadUI() end function addon:PLAYER_LOGOUT() self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT) self:UnregisterEvent("PLAYER_ENTERING_WORLD") - local worth_saving = #g_loot > 0 or _G.next(g_loot.raiders) + local worth_saving = #g_loot > 0 or next(g_loot.raiders) if not worth_saving then for text in self:registered_textgen_iter() do worth_saving = worth_saving or g_loot.printed[text] > 0 end end @@ -1415,7 +1406,7 @@ addon:vbroadcast('improv', g_unique_replace.me, existing, replace) end - local random = _G.math.random + local random = math.random local function _many_uniques_handle_it (u, prefix) if u then -- Check and alert for an existing value. @@ -1495,8 +1486,7 @@ end local recent_loot = create_new_cache ('loot', comm_cleanup_ttl+3, prefer_local_loots) - local strsplit, GetItemInfo, GetItemIcon, UnitClass = - _G.strsplit, _G.GetItemInfo, _G.GetItemIcon, _G.UnitClass + local strsplit, GetItemInfo, GetItemIcon, UnitClass = strsplit, GetItemInfo, GetItemIcon, UnitClass -- 'from' only present if this is triggered by a broadcast function _do_loot (self, local_override, recipient, unique, itemid, count, from, extratext) @@ -1747,9 +1737,9 @@ elseif cmd == "debug" then if arg then - self.is_guilded = _G.IsInGuild() + self.is_guilded = IsInGuild() self.debug[arg] = not self.debug[arg] - _G.print(arg,self.debug[arg]) + print(arg,self.debug[arg]) if self.debug[arg] then self.DEBUG_PRINT = true end else self.DEBUG_PRINT = not self.DEBUG_PRINT @@ -1883,11 +1873,11 @@ self.display:Hide() end g_restore_p = nil - _G.OuroLootSV = nil + OuroLootSV = nil self:_reset_timestamps() if verbose_p then - if (_G.OuroLootSV_saved and #_G.OuroLootSV_saved>0) then - self:Print("Current loot data cleared, %d saved sets remaining.", #_G.OuroLootSV_saved) + if (OuroLootSV_saved and #OuroLootSV_saved>0) then + self:Print("Current loot data cleared, %d saved sets remaining.", #OuroLootSV_saved) else self:Print("Current loot data cleared.") end @@ -1909,7 +1899,7 @@ -- 3) VARIABLES_LOADED replaces SV_log pointer with restored version -- 4) logging happens to _log table (now with no other references) -- 5) at logout, nothing new has been entered in the table being saved - local date = _G.date + local date = date function addon:log_with_timestamp (msg) tinsert (_log, date('%m/%d %H:%M:%S ')..msg) end @@ -1939,7 +1929,7 @@ function addon:_set_chatty_change_chatframe (arg, silent_p) local frame if type(arg) == 'number' then - arg = _G.math.min (arg, _G.NUM_CHAT_WINDOWS) + arg = math.min (arg, _G.NUM_CHAT_WINDOWS) frame = _G['ChatFrame'..arg] elseif type(arg) == 'string' then frame = _G[arg] @@ -2017,7 +2007,7 @@ for k in pairs(src) do temp[#temp+1] = k end - _G.table.sort(temp) + table.sort(temp) wipe(dest) for i = 1, #temp do dest[i] = src[temp[i]] @@ -2097,7 +2087,7 @@ elseif not closest_time then fencepost = closest_boss else - fencepost = _G.math.min(closest_time,closest_boss) + fencepost = math.min(closest_time,closest_boss) end end return fencepost @@ -2191,13 +2181,13 @@ local ss = CopyTable(g_loot.raiders) local instance,maxsize = instance_tag() if only_inraid_p then - for name,info in _G.next, ss do + for name,info in next, ss do if info.online == 3 then ss[name] = nil end end end - return ss, maxsize, instance, _G.time() + return ss, maxsize, instance, time() end end @@ -2384,7 +2374,7 @@ -- Adding entries to the loot record, and tracking the corresponding timestamp. do - local rawget, setmetatable = _G.rawget, _G.setmetatable + local rawget, setmetatable = rawget, setmetatable --@debug@ local tos = {} @@ -2500,15 +2490,15 @@ if not done_todays_date then do_todays_date() end - local h, m = _G.GetGameTime() + local h, m = GetGameTime() --local localuptime = math.floor(GetTime()) - local time_t = _G.time() + local time_t = time() e.hour = h e.minute = m e.stamp = time_t --localuptime if e.kind == 'loot' then if (not e.unique) or (#e.unique==0) then - e.unique = e.id .. (e.disposition or e.person) .. _G.date("%Y/%m/%d %H:%M",e.stamp) + e.unique = e.id .. (e.disposition or e.person) .. date("%Y/%m/%d %H:%M",e.stamp) end addon:Fire ('NewLootEntry', e) end @@ -2723,7 +2713,7 @@ function _setup_unique_replace () gur = {} gur.cache = create_new_cache ('improv', 10, fixup_unique_replacements) - gur.me = tonumber(_G.UnitGUID('player'):sub(-7),16) + gur.me = tonumber(UnitGUID('player'):sub(-7),16) gur.replacements = {} gur.new_entry = new_entry gur.get_previous_replacement = get_previous_replacement @@ -2759,7 +2749,7 @@ function() StaticPopup_Show "OUROL_ARGH" end) end StaticPopupDialogs["OUROL_ARGH"].text = horrible_error_text:format(err_msg) - _G.PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "Master") + PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "Master") addon:Print (" ") addon:Print (" ", clicky) addon:Print (" ") @@ -2775,9 +2765,9 @@ ------ Saved texts function addon:check_saved_table(silent_p) - local s = _G.OuroLootSV_saved + local s = OuroLootSV_saved if s and (#s > 0) then return s end - _G.OuroLootSV_saved = nil + OuroLootSV_saved = nil if not silent_p then self:Print("There are no saved loot texts.") end end @@ -2789,8 +2779,8 @@ end function addon:save_saveas(name) - _G.OuroLootSV_saved = _G.OuroLootSV_saved or {} - local SV = _G.OuroLootSV_saved + OuroLootSV_saved = OuroLootSV_saved or {} + local SV = OuroLootSV_saved local n = #SV + 1 local save = { name = name, @@ -2876,7 +2866,7 @@ uniques_bywhen[tstamp] = u when_array[#when_array+1] = tstamp end - _G.table.sort (when_array, compare_timestamps) + table.sort (when_array, compare_timestamps) for i,tstamp in ipairs(when_array) do new_uniques[i] = uniques_bywhen[tstamp] end @@ -2968,7 +2958,7 @@ end for i,e in self:filtered_loot_iter('loot') do if e.unique and e.unique ~= "" then - local hmmm = _G.rawget(g_uniques,e.unique) + local hmmm = rawget(g_uniques,e.unique) if hmmm then hmmm.loot = i elseif e.disposition == 'shard' or e.disposition == 'gvault' then @@ -3274,11 +3264,11 @@ end local from_person_class = e.person_class or from_h.person_class or (g_loot.raiders[from_name] and g_loot.raiders[from_name].class) - or select(2,_G.UnitClass(from_name)) + or select(2,UnitClass(from_name)) e.person = to_name e.person_class = to_h.person_class or (g_loot.raiders[to_name] and g_loot.raiders[to_name].class) - or select(2,_G.UnitClass(to_name)) + or select(2,UnitClass(to_name)) self.hist_clean = nil self.loot_clean = nil
--- a/gui.lua Sun Aug 05 19:08:53 2012 +0000 +++ b/gui.lua Mon Aug 06 13:14:38 2012 -0400 @@ -122,7 +122,7 @@ -- Working around this bug: -- http://forums.wowace.com/showpost.php?p=295202&postcount=31 -do +if false then -- no longer needed? local function fix_frame_level (level, ...) for i = 1, select("#", ...) do local button = select(i, ...)
--- a/options.lua Sun Aug 05 19:08:53 2012 +0000 +++ b/options.lua Mon Aug 06 13:14:38 2012 -0400 @@ -11,6 +11,9 @@ [52195] = true, -- Amberjewel [52722] = true, -- Maelstrom Crystal [71716] = true, -- Soothsayer's Runes +-- [74247] = true, -- Ethereal Shard +-- [74248] = true, -- Sha Crystal + -- could probably remove most of this now -- [29434] = true, -- Badge of Justice -- [40752] = true, -- Emblem of Heroism
--- a/verbage.lua Sun Aug 05 19:08:53 2012 +0000 +++ b/verbage.lua Mon Aug 06 13:14:38 2012 -0400 @@ -9,6 +9,8 @@ "near" another boss entry with nonzero duration, can we just safely assume that's the real entry and delete the zero entry altogether? +- Rework candidate groups into the expiring caches. + - Break more methods out into private routines. - implement ack, then fallback to recording if not ack'd