Mercurial > wow > ouroloot
comparison 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 |
comparison
equal
deleted
inserted
replaced
66:43913e02a1ef | 67:c01875b275ca |
---|---|
243 end | 243 end |
244 | 244 |
245 addon = LibStub("AceAddon-3.0"):NewAddon(addon, "Ouro Loot", | 245 addon = LibStub("AceAddon-3.0"):NewAddon(addon, "Ouro Loot", |
246 "AceTimer-3.0", "AceComm-3.0", "AceConsole-3.0", "AceEvent-3.0") | 246 "AceTimer-3.0", "AceComm-3.0", "AceConsole-3.0", "AceEvent-3.0") |
247 | 247 |
248 -- if given, MSG should be a complete-ish sentence | |
249 function addon:load_assert (cond, msg, ...) | |
250 if cond then | |
251 return cond, msg, ... | |
252 end | |
253 msg = msg or "load-time assertion failed!" | |
254 self.NOLOAD = msg | |
255 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) | |
256 SLASH_ACECONSOLE_OUROLOOT1 = nil | |
257 SLASH_ACECONSOLE_OUROLOOT2 = nil | |
258 _G.error (msg, --[[level=]]2) | |
259 end | |
260 | |
261 -- Seriously? ORLY? | |
262 -- YARLY. Go ahead and guess what was involved in tracking this down. If | |
263 -- more such effects are added in the future, the "id==xxxxx" will need to | |
264 -- change into a probe of a table of known-problematic IDs. | |
265 for i = 1, 40 do -- BUFF_MAX_DISPLAY==32, enh | |
266 local id = select(11,UnitAura('player', i, 'HELPFUL')) | |
267 if id == 88715 then | |
268 -- What I really want to do is pause until the thing is clicked off, | |
269 -- then continue with the rest of the file. No can do. Could also | |
270 -- just set some hooks and then re-OnInit/OnEnable after the aura | |
271 -- expires, but that's a hassle. GAH. Punt. | |
272 local text = UnitAura('player', i, 'HELPFUL') | |
273 text = ([[Cannot initialize while |cff71d5ff|Hspell:88715|h[%s]|h|cff00ff00 is active!]]): | |
274 format(text) | |
275 addon:load_assert(nil,text) | |
276 return -- were this C code running through lint, I'd put NOTREACHED | |
277 end | |
278 end | |
279 | |
248 | 280 |
249 ------ Globals | 281 ------ Globals |
250 local g_loot = nil | 282 local g_loot = nil |
251 local g_restore_p = nil | 283 local g_restore_p = nil |
252 local g_wafer_thin = nil -- for prompting for additional rebroadcasters | 284 local g_wafer_thin = nil -- for prompting for additional rebroadcasters |
451 end | 483 end |
452 | 484 |
453 | 485 |
454 ------ Ace3 framework stuff | 486 ------ Ace3 framework stuff |
455 function addon:OnInitialize() | 487 function addon:OnInitialize() |
488 if self.author_debug then | |
489 _G.OL = self | |
490 end | |
456 _log = OuroLootSV_log | 491 _log = OuroLootSV_log |
457 | 492 |
458 -- VARIABLES_LOADED has fired by this point; test if we're doing something like | 493 -- VARIABLES_LOADED has fired by this point; test if we're doing something like |
459 -- relogging during a raid and already have collected loot data | 494 -- relogging during a raid and already have collected loot data |
460 g_restore_p = OuroLootSV ~= nil | 495 g_restore_p = OuroLootSV ~= nil |
505 end | 540 end |
506 end | 541 end |
507 | 542 |
508 -- get item filter table if needed | 543 -- get item filter table if needed |
509 if opts.itemfilter == nil then | 544 if opts.itemfilter == nil then |
510 opts.itemfilter = addon.default_itemfilter | 545 opts.itemfilter = self.default_itemfilter |
511 end | 546 end |
512 addon.default_itemfilter = nil | 547 self.default_itemfilter = nil |
513 | 548 |
514 self:RegisterChatCommand("ouroloot", "OnSlash") | 549 self:RegisterChatCommand("ouroloot", "OnSlash") |
515 if opts.register_slashloot then | 550 if opts.register_slashloot then |
516 -- NOTA BENE: do not use /loot in the LoadOn list, ChatTypeInfo gets confused | 551 -- NOTA BENE: do not use /loot in the LoadOn list, ChatTypeInfo gets confused |
517 -- maybe try to detect if this command is already in use... | 552 -- maybe try to detect if this command is already in use... |
518 SLASH_ACECONSOLE_OUROLOOT2 = "/loot" | 553 SLASH_ACECONSOLE_OUROLOOT2 = "/loot" |
519 end | 554 end |
520 | 555 |
521 self.history_all = self.history_all or OuroLootSV_hist or {} | 556 self.history_all = self.history_all or OuroLootSV_hist or {} |
522 local r = assert(GetRealmName()) | 557 local r = self:load_assert (GetRealmName(), "how the freak does GetRealmName() fail?") |
523 self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r) | 558 self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r) |
524 self.history = self.history_all[r] | 559 self.history = self.history_all[r] |
525 if (not InCombatLockdown()) and OuroLootSV_hist and | 560 if (not InCombatLockdown()) and OuroLootSV_hist and |
526 (OuroLootSV_hist.HISTFORMAT == nil) -- restored data but it's older | 561 (OuroLootSV_hist.HISTFORMAT == nil) -- restored data but it's older |
527 then | 562 then |
597 if dirty then self:Print("Saved data has been massaged into shape.") end | 632 if dirty then self:Print("Saved data has been massaged into shape.") end |
598 end | 633 end |
599 | 634 |
600 _init(self) | 635 _init(self) |
601 self.dprint('flow', "version strings:", revision_large, self.status_text) | 636 self.dprint('flow', "version strings:", revision_large, self.status_text) |
637 self.load_assert = nil | |
602 self.OnInitialize = nil -- free up ALL the things! | 638 self.OnInitialize = nil -- free up ALL the things! |
603 end | 639 end |
604 | 640 |
605 function addon:OnEnable() | 641 function addon:OnEnable() |
606 self:RegisterEvent("PLAYER_LOGOUT") | 642 self:RegisterEvent("PLAYER_LOGOUT") |
821 end | 857 end |
822 OuroLootSV_log = #OuroLootSV_log > 0 and OuroLootSV_log or nil | 858 OuroLootSV_log = #OuroLootSV_log > 0 and OuroLootSV_log or nil |
823 end | 859 end |
824 | 860 |
825 do | 861 do |
826 local IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, | 862 local IsInInstance, UnitIsConnected, UnitClass, UnitRace, UnitSex, |
827 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo = | 863 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo = |
828 IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, | 864 IsInInstance, UnitIsConnected, UnitClass, UnitRace, UnitSex, |
829 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo | 865 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo |
830 local time, difftime = time, difftime | 866 local time, difftime = time, difftime |
831 local R_ACTIVE, R_OFFLINE, R_LEFT = 1, 2, 3 | 867 local R_ACTIVE, R_OFFLINE, R_LEFT = 1, 2, 3 |
832 | 868 |
833 local lastevent, now = 0, 0 | 869 local lastevent, now = 0, 0 |
861 redo_count = redo_count + 1 | 897 redo_count = redo_count + 1 |
862 end | 898 end |
863 redo = false | 899 redo = false |
864 for i = 1, GetNumRaidMembers() do | 900 for i = 1, GetNumRaidMembers() do |
865 local unit = 'raid'..i | 901 local unit = 'raid'..i |
866 local name = UnitName(unit) | 902 -- We grab a bunch of return values here, but only pay attention to |
903 -- them under specific circumstances. | |
904 local name, connected, subgroup, level, class, _ | |
905 name, _, subgroup, level, _, class, connected = GetRaidRosterInfo(i) | |
867 -- No, that's not my typo, it really is "uknownbeing" in Blizzard's code. | 906 -- No, that's not my typo, it really is "uknownbeing" in Blizzard's code. |
868 if name and name ~= UNKNOWN and name ~= UNKNOWNOBJECT and name ~= UKNOWNBEING then | 907 if name and name ~= UNKNOWN and name ~= UNKNOWNOBJECT and name ~= UKNOWNBEING then |
869 if not g_loot.raiders[name] then | 908 if not g_loot.raiders[name] then |
870 g_loot.raiders[name] = { needinfo=true } | 909 g_loot.raiders[name] = { needinfo=true } |
871 end | 910 end |
872 local r = g_loot.raiders[name] | 911 local r = g_loot.raiders[name] |
873 -- We grab a bunch of return values here, but only pay attention to | |
874 -- them under specific circumstances. | |
875 local grri_name, connected, subgroup, level, class, _ | |
876 grri_name, _, subgroup, level, _, class, connected = GetRaidRosterInfo(i) | |
877 if name ~= grri_name then | |
878 error("UnitName ("..tostring(name)..") =/= grri_name (".. | |
879 tostring(grri_name)..") of same raidindex ("..i..")") | |
880 end | |
881 r.subgroup = subgroup | 912 r.subgroup = subgroup |
882 if r.needinfo and UnitIsVisible(unit) then | 913 if r.needinfo and UnitIsVisible(unit) then |
883 r.needinfo = nil | 914 r.needinfo = nil |
884 r.class = class --select(2,UnitClass(unit)) | 915 r.class = class --select(2,UnitClass(unit)) |
885 r.race = select(2,UnitRace(unit)) | 916 r.race = select(2,UnitRace(unit)) |
1498 self.status_text = ("%s communicating as ident %s commrev %s"):format(self.revision,self.ident,self.commrev) | 1529 self.status_text = ("%s communicating as ident %s commrev %s"):format(self.revision,self.ident,self.commrev) |
1499 self:RegisterComm(self.ident) | 1530 self:RegisterComm(self.ident) |
1500 self:RegisterComm(self.identTg, "OnCommReceivedNocache") | 1531 self:RegisterComm(self.identTg, "OnCommReceivedNocache") |
1501 | 1532 |
1502 if self.author_debug then | 1533 if self.author_debug then |
1503 _G.OL = self | |
1504 _G.Oloot = g_loot | 1534 _G.Oloot = g_loot |
1505 end | 1535 end |
1506 end | 1536 end |
1507 | 1537 |
1508 -- Raid roster snapshots | 1538 -- Raid roster snapshots |