Mercurial > wow > ouroloot
comparison core.lua @ 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 | 47b149f9a5d7 |
children | 8345df517488 |
comparison
equal
deleted
inserted
replaced
134:7817367a008e | 135:feca7e0e1f89 |
---|---|
111 OuroLootSV_hist = nil | 111 OuroLootSV_hist = nil |
112 OuroLootSV_log = {} | 112 OuroLootSV_log = {} |
113 | 113 |
114 | 114 |
115 ------ Constants | 115 ------ Constants |
116 local RAID_ROSTER_UPDATE_EVENT = 'GROUP_ROSTER_UPDATE' | |
117 --(select(4,GetBuildInfo()) >= 50000) and 'GROUP_ROSTER_UPDATE' or 'RAID_ROSTER_UPDATE' | |
118 local option_defaults = { profile = { | 116 local option_defaults = { profile = { |
119 --['datarev'] = 20, -- cheating, this isn't actually an option | 117 --['datarev'] = 20, -- cheating, this isn't actually an option |
120 ['popup_on_join'] = true, | 118 ['popup_on_join'] = true, |
121 ['register_slash_synonyms'] = false, | 119 ['register_slash_synonyms'] = false, |
122 ['slash_synonyms'] = '/ol,/oloot', | 120 ['slash_synonyms'] = '/ol,/oloot', |
390 local type, select, next, pairs, ipairs, tinsert, tremove, tostring, tonumber, wipe = | 388 local type, select, next, pairs, ipairs, tinsert, tremove, tostring, tonumber, wipe = |
391 type, select, next, pairs, ipairs, table.insert, table.remove, tostring, tonumber, table.wipe | 389 type, select, next, pairs, ipairs, table.insert, table.remove, tostring, tonumber, table.wipe |
392 | 390 |
393 local pprint, tabledump = addon.pprint, flib.tabledump | 391 local pprint, tabledump = addon.pprint, flib.tabledump |
394 local CopyTable = CopyTable | 392 local CopyTable = CopyTable |
395 local GetNumRaidMembers = GetNumGroupMembers or GetNumRaidMembers | 393 local GetNumGroupMembers = GetNumGroupMembers |
396 local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end) | 394 local IsInRaid = IsInRaid |
397 -- En masse forward decls of symbols defined inside local blocks | 395 -- En masse forward decls of symbols defined inside local blocks |
398 local _register_bossmod, makedate, create_new_cache, _init, _log, _do_loot_metas | 396 local _register_bossmod, makedate, create_new_cache, _init, _log, _do_loot_metas |
399 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision | 397 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision |
400 local _notify_about_change, _LFR_suppressing, _add_loot_disposition | 398 local _notify_about_change, _LFR_suppressing, _add_loot_disposition |
401 | 399 |
872 self.OnInitialize = nil -- free up ALL the things! | 870 self.OnInitialize = nil -- free up ALL the things! |
873 end | 871 end |
874 | 872 |
875 function addon:OnEnable() | 873 function addon:OnEnable() |
876 self:RegisterEvent("PLAYER_LOGOUT") | 874 self:RegisterEvent("PLAYER_LOGOUT") |
877 self:RegisterEvent(RAID_ROSTER_UPDATE_EVENT,"RAID_ROSTER_UPDATE") | 875 self:RegisterEvent("GROUP_ROSTER_UPDATE") |
878 | 876 |
879 -- This Print cribbed from Talented. I like the way jerry thinks: the | 877 -- This Print cribbed from Talented. I like the way jerry thinks: the |
880 -- first string argument can be a format spec for the remainder of the | 878 -- first string argument can be a format spec for the remainder of the |
881 -- arguments. AceConsole:Printf isn't used because we can't specify a | 879 -- arguments. AceConsole:Printf isn't used because we can't specify a |
882 -- prefix without jumping through ridonkulous hoops. | 880 -- prefix without jumping through ridonkulous hoops. |
1293 _G.OuroLootSV_hist = nil | 1291 _G.OuroLootSV_hist = nil |
1294 _G.OuroLootSV_log = nil | 1292 _G.OuroLootSV_log = nil |
1295 ReloadUI() | 1293 ReloadUI() |
1296 end | 1294 end |
1297 function addon:PLAYER_LOGOUT() | 1295 function addon:PLAYER_LOGOUT() |
1298 self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT) | 1296 -- Can these still fire at the very last instant? |
1297 self:UnregisterEvent("GROUP_ROSTER_UPDATE") | |
1299 self:UnregisterEvent("PLAYER_ENTERING_WORLD") | 1298 self:UnregisterEvent("PLAYER_ENTERING_WORLD") |
1300 | 1299 |
1301 local worth_saving = #g_loot > 0 or next(g_loot.raiders) | 1300 local worth_saving = #g_loot > 0 or next(g_loot.raiders) |
1302 if not worth_saving then for text in self:registered_textgen_iter() do | 1301 if not worth_saving then for text in self:registered_textgen_iter() do |
1303 worth_saving = worth_saving or g_loot.printed[text] > 0 | 1302 worth_saving = worth_saving or g_loot.printed[text] > 0 |
1335 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo = | 1334 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo = |
1336 IsInInstance, UnitIsConnected, UnitClass, UnitRace, UnitSex, | 1335 IsInInstance, UnitIsConnected, UnitClass, UnitRace, UnitSex, |
1337 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo | 1336 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo |
1338 local time, difftime = time, difftime | 1337 local time, difftime = time, difftime |
1339 local R_ACTIVE, R_OFFLINE, R_LEFT = 'online', 'offline', 'no_longer' | 1338 local R_ACTIVE, R_OFFLINE, R_LEFT = 'online', 'offline', 'no_longer' |
1339 local was_in_raid | |
1340 | 1340 |
1341 local lastevent, now = 0, 0 | 1341 local lastevent, now = 0, 0 |
1342 local redo_count = 0 | 1342 local redo_count = 0 |
1343 local redo, timer_handle, my_realm | 1343 local redo, timer_handle, my_realm |
1344 | 1344 |
1369 | 1369 |
1370 if redo then | 1370 if redo then |
1371 redo_count = redo_count + 1 | 1371 redo_count = redo_count + 1 |
1372 end | 1372 end |
1373 redo = false | 1373 redo = false |
1374 for i = 1, GetNumRaidMembers() do | 1374 for i = 1, GetNumGroupMembers() do |
1375 local unit = 'raid'..i | 1375 local unit = 'raid'..i |
1376 -- We grab a bunch of return values here, but only pay attention to | 1376 -- We grab a bunch of return values here, but only pay attention to |
1377 -- them under specific circumstances. Try to use as many of these | 1377 -- them under specific circumstances. Try to use as many of these |
1378 -- values as possible rather than multiple Unit* calls. | 1378 -- values as possible rather than multiple Unit* calls. |
1379 local fname, connected, subgroup, level, class, _ | 1379 local fname, connected, subgroup, level, class, _ |
1414 redo = redo or r.needinfo | 1414 redo = redo or r.needinfo |
1415 end | 1415 end |
1416 end | 1416 end |
1417 if redo then -- XXX test redo_count here and eventually give up? | 1417 if redo then -- XXX test redo_count here and eventually give up? |
1418 if not timer_handle then | 1418 if not timer_handle then |
1419 timer_handle = self:ScheduleRepeatingTimer("RAID_ROSTER_UPDATE", 60) | 1419 timer_handle = self:ScheduleRepeatingTimer("GROUP_ROSTER_UPDATE", 60) |
1420 end | 1420 end |
1421 else | 1421 else |
1422 redo_count = 0 | 1422 redo_count = 0 |
1423 if timer_handle then | 1423 if timer_handle then |
1424 self:CancelTimer(timer_handle) | 1424 self:CancelTimer(timer_handle) |
1425 timer_handle = nil | 1425 timer_handle = nil |
1426 end | 1426 end |
1427 end | 1427 end |
1428 end | 1428 end |
1429 | 1429 |
1430 function addon:RAID_ROSTER_UPDATE (event) | 1430 function addon:GROUP_ROSTER_UPDATE (event) |
1431 if GetNumRaidMembers() == 0 then | 1431 if not IsInRaid() then |
1432 -- Leaving a raid group. | 1432 if was_in_raid then |
1433 -- Because of PLAYER_ENTERING_WORLD, this code also executes on load | 1433 -- Leaving a raid group. |
1434 -- screens while soloing and in regular groups. Take care. | 1434 self.dprint('flow', "no longer in raid group") |
1435 self.dprint('flow', "GetNumRaidMembers == 0") | 1435 was_in_raid = false |
1436 if self.enabled and not self.debug.notraid then | 1436 if self.enabled and not self.debug.notraid then |
1437 self.dprint('flow', "enabled, leaving raid") | 1437 self.dprint('flow', "enabled, leaving raid") |
1438 self.popped = nil | 1438 self.popped = nil |
1439 self:Deactivate() | 1439 self:Deactivate() |
1440 self:CheckRoster(--[[leaving raid]]true) | 1440 self:CheckRoster(--[[leaving raid]]true) |
1441 end | 1441 end |
1442 _LFR_suppressing = nil | 1442 _LFR_suppressing = nil |
1443 end | |
1444 -- Flow for 5-player groups goes right to here. | |
1443 return | 1445 return |
1444 end | 1446 end |
1445 | 1447 |
1446 local inside,whatkind = IsInInstance() | 1448 local inside,whatkind = IsInInstance() |
1447 if inside and (whatkind == "pvp" or whatkind == "arena") then | 1449 if inside and (whatkind == "pvp" or whatkind == "arena") then |
1448 self.dprint('flow', "got RRU event but in pvp zone, bailing") | 1450 self.dprint('flow', "got RRU event but in pvp zone, bailing") |
1449 return | 1451 return |
1450 end | 1452 end |
1451 | 1453 |
1452 local docheck = self.enabled | 1454 local docheck = self.enabled |
1453 if event == "Activate" then | 1455 if event == "GROUP_ROSTER_UPDATE" then |
1454 -- dispatched from Activate | |
1455 if opts.history_suppress_LFR | |
1456 and GetLFGMode(LE_LFG_CATEGORY_RF) | |
1457 then | |
1458 _LFR_suppressing = true | |
1459 end | |
1460 my_realm = self.history.realm | |
1461 _register_bossmod(self) | |
1462 self:RegisterEvent("CHAT_MSG_LOOT") | |
1463 docheck = true | |
1464 elseif event == RAID_ROSTER_UPDATE_EVENT then | |
1465 -- hot code path, be careful | 1456 -- hot code path, be careful |
1466 | 1457 |
1467 -- event registration from onload, joined a raid, maybe show popup | 1458 -- event registration from onload, joined a raid, maybe show popup |
1468 self.dprint('flow', "RRU check:", self.popped, opts.popup_on_join) | 1459 self.dprint('flow', "RRU check:", self.popped, opts.popup_on_join) |
1469 if (not self.popped) and opts.popup_on_join then | 1460 if (not self.popped) and opts.popup_on_join then |
1470 self.popped = StaticPopup_Show "OUROL_REMIND" | 1461 self.popped = StaticPopup_Show "OUROL_REMIND" |
1471 self.popped.data = self | 1462 self.popped.data = self |
1472 return | 1463 return |
1473 end | 1464 end |
1474 end | 1465 elseif event == "Activate" then |
1466 -- dispatched from Activate | |
1467 if opts.history_suppress_LFR | |
1468 and GetLFGMode(LE_LFG_CATEGORY_RF) | |
1469 then | |
1470 _LFR_suppressing = true | |
1471 end | |
1472 my_realm = self.history.realm | |
1473 _register_bossmod(self) | |
1474 self:RegisterEvent("CHAT_MSG_LOOT") | |
1475 was_in_raid = true | |
1476 docheck = true | |
1477 end | |
1478 | |
1475 -- Throttle the checks fired by common events. | 1479 -- Throttle the checks fired by common events. |
1476 if docheck and not InCombatLockdown() then | 1480 if docheck and not InCombatLockdown() then |
1477 now = time() | 1481 now = time() |
1478 if difftime(now,lastevent) > 45 then | 1482 if difftime(now,lastevent) > 45 then |
1479 lastevent = now | 1483 lastevent = now |
1942 | 1946 |
1943 ------ On/off | 1947 ------ On/off |
1944 -- Both of these need to be (effectively) idempotent. | 1948 -- Both of these need to be (effectively) idempotent. |
1945 function addon:Activate (opt_threshold, opt_bcast_only) | 1949 function addon:Activate (opt_threshold, opt_bcast_only) |
1946 self.dprint('flow', ":Activate is running") | 1950 self.dprint('flow', ":Activate is running") |
1947 self:RegisterEvent(RAID_ROSTER_UPDATE_EVENT,"RAID_ROSTER_UPDATE") | 1951 self:RegisterEvent("GROUP_ROSTER_UPDATE") |
1948 self:RegisterEvent("PLAYER_ENTERING_WORLD", | 1952 self:RegisterEvent("PLAYER_ENTERING_WORLD", |
1949 function() self:ScheduleTimer("RAID_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end) | 1953 function() self:ScheduleTimer("GROUP_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end) |
1950 self.popped = true | 1954 self.popped = true |
1951 if self.DO_ITEMID_FIX then | 1955 if self.DO_ITEMID_FIX then |
1952 self.DO_ITEMID_FIX = nil | 1956 self.DO_ITEMID_FIX = nil |
1953 self:do_item_cache_fixup(--[[force_silent=]]not self.author_debug) | 1957 self:do_item_cache_fixup(--[[force_silent=]]not self.author_debug) |
1954 self.loot_clean = nil | 1958 self.loot_clean = nil |
1955 end | 1959 end |
1956 if IsInRaid() then | 1960 if IsInRaid() then |
1957 self.dprint('flow', ">:Activate calling RRU") | 1961 self.dprint('flow', ">:Activate calling RRU") |
1958 self:RAID_ROSTER_UPDATE("Activate") | 1962 self:GROUP_ROSTER_UPDATE("Activate") |
1959 elseif self.debug.notraid then | 1963 elseif self.debug.notraid then |
1960 self.dprint('flow', ">:(notraid) Activate registering loot and bossmods") | 1964 self.dprint('flow', ">:(notraid) Activate registering loot and bossmods") |
1961 self:RegisterEvent("CHAT_MSG_LOOT") | 1965 self:RegisterEvent("CHAT_MSG_LOOT") |
1962 _register_bossmod(self) | 1966 _register_bossmod(self) |
1963 elseif g_restore_p then | 1967 elseif g_restore_p then |
1996 -- Note: running '/ouroloot off' will also avoid the popup reminder when | 2000 -- Note: running '/ouroloot off' will also avoid the popup reminder when |
1997 -- joining a raid, but will not change the saved option setting. | 2001 -- joining a raid, but will not change the saved option setting. |
1998 function addon:Deactivate() | 2002 function addon:Deactivate() |
1999 self.enabled = false | 2003 self.enabled = false |
2000 self.rebroadcast = false | 2004 self.rebroadcast = false |
2001 self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT) | 2005 self:UnregisterEvent("GROUP_ROSTER_UPDATE") |
2002 self:UnregisterEvent("PLAYER_ENTERING_WORLD") | 2006 self:UnregisterEvent("PLAYER_ENTERING_WORLD") |
2003 self:UnregisterEvent("CHAT_MSG_LOOT") | 2007 self:UnregisterEvent("CHAT_MSG_LOOT") |
2004 _LFR_suppressing = nil | 2008 _LFR_suppressing = nil |
2005 -- Passing .raiders directly doesn't work with a proxy (again, WTB Lua | 2009 -- Passing .raiders directly doesn't work with a proxy (again, WTB Lua |
2006 -- 5.2 and its __pairs iterators). Give it the same structure as a boss | 2010 -- 5.2 and its __pairs iterators). Give it the same structure as a boss |