Mercurial > wow > ouroloot
diff core.lua @ 67:c01875b275ca
Do not use UnitName on other people during RAID_ROSTER_UPDATE, as they may be a weed (thank you Calvieri for unknowingly eating a lifegiving seed and exposing this bug). Be more informative to the user about errors during load. Do not try to run other files if a load-time error happens, as it only generates cascading noise.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Tue, 08 May 2012 02:41:23 +0000 |
parents | 43913e02a1ef |
children | 3bed6d51e077 |
line wrap: on
line diff
--- a/core.lua Fri Apr 27 10:11:56 2012 +0000 +++ b/core.lua Tue May 08 02:41:23 2012 +0000 @@ -245,6 +245,38 @@ addon = LibStub("AceAddon-3.0"):NewAddon(addon, "Ouro Loot", "AceTimer-3.0", "AceComm-3.0", "AceConsole-3.0", "AceEvent-3.0") +-- if given, MSG should be a complete-ish sentence +function addon:load_assert (cond, msg, ...) + if cond then + return cond, msg, ... + end + msg = msg or "load-time assertion failed!" + self.NOLOAD = msg + self:Printf([[|cffff1010ERROR:|r <|cff00ff00%s|r> Ouro Loot cannot finish loading. You will need to type |cff30adff%s|r once these problems are resolved, and try again.]], msg, _G.SLASH_RELOAD1) + SLASH_ACECONSOLE_OUROLOOT1 = nil + SLASH_ACECONSOLE_OUROLOOT2 = nil + _G.error (msg, --[[level=]]2) +end + +-- Seriously? ORLY? +-- YARLY. Go ahead and guess what was involved in tracking this down. If +-- more such effects are added in the future, the "id==xxxxx" will need to +-- change into a probe of a table of known-problematic IDs. +for i = 1, 40 do -- BUFF_MAX_DISPLAY==32, enh + local id = select(11,UnitAura('player', i, 'HELPFUL')) + if id == 88715 then + -- What I really want to do is pause until the thing is clicked off, + -- then continue with the rest of the file. No can do. Could also + -- just set some hooks and then re-OnInit/OnEnable after the aura + -- expires, but that's a hassle. GAH. Punt. + local text = UnitAura('player', i, 'HELPFUL') + text = ([[Cannot initialize while |cff71d5ff|Hspell:88715|h[%s]|h|cff00ff00 is active!]]): + format(text) + addon:load_assert(nil,text) + return -- were this C code running through lint, I'd put NOTREACHED + end +end + ------ Globals local g_loot = nil @@ -453,6 +485,9 @@ ------ Ace3 framework stuff function addon:OnInitialize() + if self.author_debug then + _G.OL = self + end _log = OuroLootSV_log -- VARIABLES_LOADED has fired by this point; test if we're doing something like @@ -507,9 +542,9 @@ -- get item filter table if needed if opts.itemfilter == nil then - opts.itemfilter = addon.default_itemfilter + opts.itemfilter = self.default_itemfilter end - addon.default_itemfilter = nil + self.default_itemfilter = nil self:RegisterChatCommand("ouroloot", "OnSlash") if opts.register_slashloot then @@ -519,7 +554,7 @@ end self.history_all = self.history_all or OuroLootSV_hist or {} - local r = assert(GetRealmName()) + 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] if (not InCombatLockdown()) and OuroLootSV_hist and @@ -599,6 +634,7 @@ _init(self) self.dprint('flow', "version strings:", revision_large, self.status_text) + self.load_assert = nil self.OnInitialize = nil -- free up ALL the things! end @@ -823,9 +859,9 @@ end do - local IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, + local IsInInstance, UnitIsConnected, UnitClass, UnitRace, UnitSex, UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo = - IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, + IsInInstance, UnitIsConnected, UnitClass, UnitRace, UnitSex, UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo local time, difftime = time, difftime local R_ACTIVE, R_OFFLINE, R_LEFT = 1, 2, 3 @@ -863,21 +899,16 @@ redo = false for i = 1, GetNumRaidMembers() do local unit = 'raid'..i - local name = UnitName(unit) + -- We grab a bunch of return values here, but only pay attention to + -- them under specific circumstances. + local name, connected, subgroup, level, class, _ + name, _, subgroup, level, _, class, connected = GetRaidRosterInfo(i) -- No, that's not my typo, it really is "uknownbeing" in Blizzard's code. if name and name ~= UNKNOWN and name ~= UNKNOWNOBJECT and name ~= UKNOWNBEING then if not g_loot.raiders[name] then g_loot.raiders[name] = { needinfo=true } end local r = g_loot.raiders[name] - -- We grab a bunch of return values here, but only pay attention to - -- them under specific circumstances. - local grri_name, connected, subgroup, level, class, _ - grri_name, _, subgroup, level, _, class, connected = GetRaidRosterInfo(i) - if name ~= grri_name then - error("UnitName ("..tostring(name)..") =/= grri_name (".. - tostring(grri_name)..") of same raidindex ("..i..")") - end r.subgroup = subgroup if r.needinfo and UnitIsVisible(unit) then r.needinfo = nil @@ -1500,7 +1531,6 @@ self:RegisterComm(self.identTg, "OnCommReceivedNocache") if self.author_debug then - _G.OL = self _G.Oloot = g_loot end end