Mercurial > wow > ouroloot
changeset 135:feca7e0e1f89
Remove MoP transition code, be smarter about detecting groups.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Fri, 31 Aug 2012 23:15:40 -0400 |
parents | 7817367a008e |
children | 434073f312e1 |
files | core.lua options.lua |
diffstat | 2 files changed, 40 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/core.lua Wed Aug 29 22:22:00 2012 -0400 +++ b/core.lua Fri Aug 31 23:15:40 2012 -0400 @@ -113,8 +113,6 @@ ------ Constants -local RAID_ROSTER_UPDATE_EVENT = 'GROUP_ROSTER_UPDATE' - --(select(4,GetBuildInfo()) >= 50000) and 'GROUP_ROSTER_UPDATE' or 'RAID_ROSTER_UPDATE' local option_defaults = { profile = { --['datarev'] = 20, -- cheating, this isn't actually an option ['popup_on_join'] = true, @@ -392,8 +390,8 @@ local pprint, tabledump = addon.pprint, flib.tabledump local CopyTable = CopyTable -local GetNumRaidMembers = GetNumGroupMembers or GetNumRaidMembers -local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end) +local GetNumGroupMembers = GetNumGroupMembers +local IsInRaid = IsInRaid -- 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 @@ -874,7 +872,7 @@ function addon:OnEnable() self:RegisterEvent("PLAYER_LOGOUT") - self:RegisterEvent(RAID_ROSTER_UPDATE_EVENT,"RAID_ROSTER_UPDATE") + self:RegisterEvent("GROUP_ROSTER_UPDATE") -- This Print cribbed from Talented. I like the way jerry thinks: the -- first string argument can be a format spec for the remainder of the @@ -1295,7 +1293,8 @@ ReloadUI() end function addon:PLAYER_LOGOUT() - self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT) + -- Can these still fire at the very last instant? + self:UnregisterEvent("GROUP_ROSTER_UPDATE") self:UnregisterEvent("PLAYER_ENTERING_WORLD") local worth_saving = #g_loot > 0 or next(g_loot.raiders) @@ -1337,6 +1336,7 @@ UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo local time, difftime = time, difftime local R_ACTIVE, R_OFFLINE, R_LEFT = 'online', 'offline', 'no_longer' + local was_in_raid local lastevent, now = 0, 0 local redo_count = 0 @@ -1371,7 +1371,7 @@ redo_count = redo_count + 1 end redo = false - for i = 1, GetNumRaidMembers() do + for i = 1, GetNumGroupMembers() do local unit = 'raid'..i -- We grab a bunch of return values here, but only pay attention to -- them under specific circumstances. Try to use as many of these @@ -1416,7 +1416,7 @@ end if redo then -- XXX test redo_count here and eventually give up? if not timer_handle then - timer_handle = self:ScheduleRepeatingTimer("RAID_ROSTER_UPDATE", 60) + timer_handle = self:ScheduleRepeatingTimer("GROUP_ROSTER_UPDATE", 60) end else redo_count = 0 @@ -1427,19 +1427,21 @@ end end - function addon:RAID_ROSTER_UPDATE (event) - if GetNumRaidMembers() == 0 then - -- Leaving a raid group. - -- Because of PLAYER_ENTERING_WORLD, this code also executes on load - -- screens while soloing and in regular groups. Take care. - self.dprint('flow', "GetNumRaidMembers == 0") - if self.enabled and not self.debug.notraid then - self.dprint('flow', "enabled, leaving raid") - self.popped = nil - self:Deactivate() - self:CheckRoster(--[[leaving raid]]true) + function addon:GROUP_ROSTER_UPDATE (event) + if not IsInRaid() then + if was_in_raid then + -- Leaving a raid group. + self.dprint('flow', "no longer in raid group") + was_in_raid = false + if self.enabled and not self.debug.notraid then + self.dprint('flow', "enabled, leaving raid") + self.popped = nil + self:Deactivate() + self:CheckRoster(--[[leaving raid]]true) + end + _LFR_suppressing = nil end - _LFR_suppressing = nil + -- Flow for 5-player groups goes right to here. return end @@ -1450,7 +1452,17 @@ end local docheck = self.enabled - if event == "Activate" then + if event == "GROUP_ROSTER_UPDATE" then + -- hot code path, be careful + + -- event registration from onload, joined a raid, maybe show popup + self.dprint('flow', "RRU check:", self.popped, opts.popup_on_join) + if (not self.popped) and opts.popup_on_join then + self.popped = StaticPopup_Show "OUROL_REMIND" + self.popped.data = self + return + end + elseif event == "Activate" then -- dispatched from Activate if opts.history_suppress_LFR and GetLFGMode(LE_LFG_CATEGORY_RF) @@ -1460,18 +1472,10 @@ my_realm = self.history.realm _register_bossmod(self) self:RegisterEvent("CHAT_MSG_LOOT") + was_in_raid = true docheck = true - elseif event == RAID_ROSTER_UPDATE_EVENT then - -- hot code path, be careful - - -- event registration from onload, joined a raid, maybe show popup - self.dprint('flow', "RRU check:", self.popped, opts.popup_on_join) - if (not self.popped) and opts.popup_on_join then - self.popped = StaticPopup_Show "OUROL_REMIND" - self.popped.data = self - return - end end + -- Throttle the checks fired by common events. if docheck and not InCombatLockdown() then now = time() @@ -1944,9 +1948,9 @@ -- Both of these need to be (effectively) idempotent. function addon:Activate (opt_threshold, opt_bcast_only) self.dprint('flow', ":Activate is running") - self:RegisterEvent(RAID_ROSTER_UPDATE_EVENT,"RAID_ROSTER_UPDATE") + self:RegisterEvent("GROUP_ROSTER_UPDATE") self:RegisterEvent("PLAYER_ENTERING_WORLD", - function() self:ScheduleTimer("RAID_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end) + function() self:ScheduleTimer("GROUP_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end) self.popped = true if self.DO_ITEMID_FIX then self.DO_ITEMID_FIX = nil @@ -1955,7 +1959,7 @@ end if IsInRaid() then self.dprint('flow', ">:Activate calling RRU") - self:RAID_ROSTER_UPDATE("Activate") + self:GROUP_ROSTER_UPDATE("Activate") elseif self.debug.notraid then self.dprint('flow', ">:(notraid) Activate registering loot and bossmods") self:RegisterEvent("CHAT_MSG_LOOT") @@ -1998,7 +2002,7 @@ function addon:Deactivate() self.enabled = false self.rebroadcast = false - self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT) + self:UnregisterEvent("GROUP_ROSTER_UPDATE") self:UnregisterEvent("PLAYER_ENTERING_WORLD") self:UnregisterEvent("CHAT_MSG_LOOT") _LFR_suppressing = nil
--- a/options.lua Wed Aug 29 22:22:00 2012 -0400 +++ b/options.lua Fri Aug 31 23:15:40 2012 -0400 @@ -560,7 +560,7 @@ w:SetType("checkbox") w:SetLabel(d) if d == "notraid" then - w:SetDescription[[Tick this before enabling to make the addon work outside of raid groups]] + w:SetDescription[[Tick this before manually enabling to make the addon work outside of raid groups]] else if d == "alsolog" then w:SetDescription[[Also log all debug messages to disk. See print_log.lua in the addon folder for later viewing.]]