comparison core.lua @ 61:99ab21f0755f

Fix major breakage in attendance snapshotting.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 19 Apr 2012 00:52:37 +0000
parents 59718ec80610
children d5fe3482db67
comparison
equal deleted inserted replaced
60:45d2b153c2df 61:99ab21f0755f
1 local nametag, addon = ... 1 local nametag, addon = ...
2 2
3 --[==[ 3 --[==[
4 g_loot's numeric indices are loot entries (including titles, separators, 4 g_loot's numeric indices are loot entries (including titles, separators,
5 etc); its named indices are: 5 etc); its named indices are:
6 - forum saved text from forum markup window, default nil 6 - forum saved text from forum markup window, default nil
7 - attend saved text from raid attendence window, default nil 7 - attend saved text from raid attendence window, default nil
8 - printed.FOO last loot index formatted into text window FOO, default 0 8 - printed.FOO last loot index formatted into text window FOO, default 0
9 - raiders accumulating raid roster data as we see raid members; indexed 9 - raiders accumulating raid roster data as we see raid members; indexed
10 by player name with subtable fields: 10 by player name with subtable fields:
11 - class capitalized English codename ("WARRIOR", "DEATHKNIGHT", etc) 11 - class capitalized English codename ("WARRIOR", "DEATHKNIGHT", etc)
12 - subgroup 1-8 12 - subgroup 1-8
13 - race English codename ("BloodElf", etc) 13 - race English codename ("BloodElf", etc)
14 - sex 1 = unknown/error, 2 = male, 3 = female 14 - sex 1 = unknown/error, 2 = male, 3 = female
15 - level can be 0 if player was offline at the time 15 - level can be 0 if player was offline at the time
16 - guild guild name, or missing if unguilded 16 - guild guild name, or missing if unguilded
17 - online 1 = online, 2 = offline, 3 = no longer in raid 17 - online 1 = online, 2 = offline, 3 = no longer in raid
18 [both of these next two fields use time_t values:] 18 [both of these next two fields use time_t values:]
19 - join time player joined the raid (or first time we've seen them) 19 - join time player joined the raid (or first time we've seen them)
20 - leave time player left the raid (or time we've left the raid) 20 - leave time player left the raid (or time we've left the raid, if
21 'online' is not 3)
21 22
22 Common g_loot entry indices: 23 Common g_loot entry indices:
23 - kind time/boss/loot 24 - kind time/boss/loot
24 - hour 0-23, on the *physical instance server*, not the realm server 25 - hour 0-23, on the *physical instance server*, not the realm server
25 - minute 0-59, ditto 26 - minute 0-59, ditto
26 - stamp time_t on the local computer 27 - stamp time_t on the local computer
27 - cols graphical display data; cleared when logging out 28 - cols graphical display data; cleared when logging out
28 29
29 Time specific g_loot indices: 30 Time specific g_loot indices:
30 - startday table with month/day/year/text fields from makedate() 31 - startday table with month/day/year/text fields from makedate()
31 text is always "dd Month yyyy" 32 text is always "dd Month yyyy"
32 33
33 Boss specific g_loot indices: 34 Boss specific g_loot indices:
34 - bossname name of boss/encounter; 35 - bossname name of boss/encounter;
35 may be changed if "snarky boss names" option is enabled 36 may be changed if "snarky boss names" option is enabled
36 - reason wipe/kill ("pull" does not generate an entry) 37 - reason wipe/kill ("pull" does not generate an entry)
37 - instance name of instance, including size and difficulty 38 - instance name of instance, including size and difficulty
38 - maxsize 5/10/25, presumably also 15 and 40 could show up; can be 39 - maxsize max raid size: 5/10/25, presumably also 15 and 40 could show
39 0 if we're outside an instance and the player inside has 40 up; can be 0 if we're outside an instance and the player
40 an older version 41 inside has an older version
41 - duration in seconds; may be missing (only present if local) 42 - duration in seconds; may be missing (only present if local)
42 - raidersnap copy of g_loot.raiders at the time of the boss event 43 - raidersnap copy of g_loot.raiders at the time of the boss event
43 44
44 Loot specific g_loot indices: 45 Loot specific g_loot indices:
45 - person recipient 46 - person recipient
46 - person_class class of recipient if available; may be missing; 47 - person_class class of recipient if available; may be missing;
47 will be classID-style (e.g., DEATHKNIGHT) 48 will be classID-style (e.g., DEATHKNIGHT)
48 - itemname not including square brackets 49 - itemname not including square brackets
49 - id itemID as number 50 - id itemID as number
50 - itemlink full clickable link 51 - itemlink full clickable link
51 - itexture icon path (e.g., Interface\Icons\INV_Misc_Rune_01) 52 - itexture icon path (e.g., Interface\Icons\INV_Misc_Rune_01)
52 - quality ITEM_QUALITY_* number 53 - quality ITEM_QUALITY_* number
53 - disposition offspec/gvault/shard; missing otherwise; can be set from 54 - disposition offspec/gvault/shard; missing otherwise; can be set from
54 the extratext field 55 the extratext field
55 - count e.g., "x3"; missing otherwise; can be set/removed from 56 - count e.g., "x3"; missing otherwise; can be set/removed from
56 extratext; triggers only for a stack of items, not "the boss 57 extratext; triggers only for a stack of items, not "the boss
57 dropped double axes today" 58 dropped double axes today"
58 - is_heroic true if item is heroic; missing otherwise 59 - is_heroic true if item is heroic; missing otherwise
59 - cache_miss if GetItemInfo failed; SHOULD be missing (changes other fields) 60 - cache_miss if GetItemInfo failed; SHOULD be missing (changes other fields)
60 - bcast_from if rebroadcast from another player; missing otherwise 61 - bcast_from if rebroadcast from another player; missing otherwise
61 - extratext text in Note column, including disposition and rebroadcasting 62 - extratext text in Note column, including disposition and rebroadcasting
62 - extratext_byhand true if text edited by player directly; missing otherwise 63 - extratext_byhand true if text edited by player directly; missing otherwise
63 64
64 65
65 Functions arranged like this, with these lables (for jumping to). As a 66 Functions arranged like this, with these lables (for jumping to). As a
66 rule, member functions with UpperCamelCase names are called directly by 67 rule, member functions with UpperCamelCase names are called directly by
67 user-facing code, ones with lowercase names are "one step removed", and 68 user-facing code, ones with lowercase names are "one step removed", and
266 -- (e.g., 87), due to the tagging system versus subversion file revs. This 267 -- (e.g., 87), due to the tagging system versus subversion file revs. This
267 -- is good, as local dev code will never trigger a false positive update 268 -- is good, as local dev code will never trigger a false positive update
268 -- warning for other users. The downside is that additional decimal places 269 -- warning for other users. The downside is that additional decimal places
269 -- in the Version field for bugfixes (e.g., "2.16.4.1") imposes a high-water 270 -- in the Version field for bugfixes (e.g., "2.16.4.1") imposes a high-water
270 -- mark, as subsequent shorter strings ("2.16.5", "2.17") will never be larger. 271 -- mark, as subsequent shorter strings ("2.16.5", "2.17") will never be larger.
272 -- Will need to redo this so it's not quite so dumb.
271 do 273 do
272 local r = 0 274 local r = 0
273 for d in addon.revision:gmatch("%d+") do 275 for d in addon.revision:gmatch("%d+") do
274 r = 1000*r + d 276 r = 1000*r + d
275 end 277 end
340 end 342 end
341 end 343 end
342 344
343 -- Returns an instance name or abbreviation, followed by the raid size 345 -- Returns an instance name or abbreviation, followed by the raid size
344 local function instance_tag() 346 local function instance_tag()
347 -- possibly redo this with the new GetRaidDifficulty function
345 local name, typeof, diffcode, diffstr, _, perbossheroic, isdynamic = GetInstanceInfo() 348 local name, typeof, diffcode, diffstr, _, perbossheroic, isdynamic = GetInstanceInfo()
346 local t, r 349 local t, r
347 name = addon.instance_abbrev[name] or name 350 name = addon.instance_abbrev[name] or name
348 if typeof == "none" then return name, MAX_RAID_MEMBERS end 351 if typeof == "none" then return name, MAX_RAID_MEMBERS end
349 -- diffstr is "5 Player", "10 Player (Heroic)", etc. ugh. 352 -- diffstr is "5 Player", "10 Player (Heroic)", etc. ugh.
552 for name,r in pairs(OuroLootSV.raiders) do 555 for name,r in pairs(OuroLootSV.raiders) do
553 r.subgroup = 0 556 r.subgroup = 0
554 end 557 end
555 stored_datarev = 16 558 stored_datarev = 16
556 end 559 end
560 if stored_datarev == 16 then
561 self:Print("Transitioning saved data format to 17..."); dirty = true
562 for i,e in ipairs(OuroLootSV) do
563 if e.kind == 'boss' then -- brown paper bag bugs
564 e.raidersnap = e.raidersnap or {}
565 e.maxsize = e.maxsize or 0
566 end
567 end
568 stored_datarev = 17
569 end
557 if dirty then self:Print("Saved data has been massaged into shape.") end 570 if dirty then self:Print("Saved data has been massaged into shape.") end
558 end 571 end
559 572
560 _init(self) 573 _init(self)
561 self.dprint('flow', "version strings:", revision_large, self.status_text) 574 self.dprint('flow', "version strings:", revision_large, self.status_text)
809 local r = g_loot.raiders[name] 822 local r = g_loot.raiders[name]
810 -- We grab a bunch of return values here, but only pay attention to 823 -- We grab a bunch of return values here, but only pay attention to
811 -- them under specific circumstances. 824 -- them under specific circumstances.
812 local grri_name, connected, subgroup, level, class, _ 825 local grri_name, connected, subgroup, level, class, _
813 grri_name, _, subgroup, level, _, class, connected = GetRaidRosterInfo(i) 826 grri_name, _, subgroup, level, _, class, connected = GetRaidRosterInfo(i)
814 assert(name==grri_name, "UnitName =/= grri_name of same raidindex") 827 if name ~= grri_name then
828 error("UnitName ("..tostring(name)..") =/= grri_name ("..
829 tostring(grri_name)..") of same raidindex ("..i..")")
830 end
815 r.subgroup = subgroup 831 r.subgroup = subgroup
816 if r.needinfo and UnitIsVisible(unit) then 832 if r.needinfo and UnitIsVisible(unit) then
817 r.needinfo = nil 833 r.needinfo = nil
818 r.class = class --select(2,UnitClass(unit)) 834 r.class = class --select(2,UnitClass(unit))
819 r.race = select(2,UnitRace(unit)) 835 r.race = select(2,UnitRace(unit))
899 local function maybe_trash_kill_entry() 915 local function maybe_trash_kill_entry()
900 -- this is set on various boss interactions, so we've got a kill/wipe 916 -- this is set on various boss interactions, so we've got a kill/wipe
901 -- entry already 917 -- entry already
902 if addon.latest_instance then return end 918 if addon.latest_instance then return end
903 addon.latest_instance = instance_tag() 919 addon.latest_instance = instance_tag()
920 local ss, max = addon:snapshot_raid()
904 addon:_mark_boss_kill (addon._addLootEntry{ 921 addon:_mark_boss_kill (addon._addLootEntry{
905 kind='boss',reason='kill',bossname=[[trash]],instance=addon.latest_instance,duration=0 922 kind='boss', reason='kill', bossname=[[trash]],
923 instance=addon.latest_instance, duration=0,
924 raidersnap=ss, maxsize=max
906 }) 925 })
907 end 926 end
908 927
909 -- Recent loot cache 928 -- Recent loot cache
910 local candidates = {} 929 local candidates = {}
1431 _G.OL = self 1450 _G.OL = self
1432 _G.Oloot = g_loot 1451 _G.Oloot = g_loot
1433 end 1452 end
1434 end 1453 end
1435 1454
1455 -- Raid roster snapshots
1456 do
1457 function addon:snapshot_raid (only_inraid_p)
1458 local ss = CopyTable(g_loot.raiders)
1459 local instance,maxsize = instance_tag()
1460 if only_inraid_p then
1461 for name,info in next, ss do
1462 if info.online == 3 then
1463 ss[name] = nil
1464 end
1465 end
1466 end
1467 return ss, maxsize, instance, time()
1468 end
1469 end
1470
1436 -- Tie-in with Deadly Boss Mods (or other such addons) 1471 -- Tie-in with Deadly Boss Mods (or other such addons)
1437 do 1472 do
1438 local candidates = {} 1473 local candidates = {}
1439 local location 1474 local location
1440 local function fixup_durations (cache) 1475 local function fixup_durations (cache)
1508 kind = 'boss', 1543 kind = 'boss',
1509 bossname = bossname, 1544 bossname = bossname,
1510 reason = reason, 1545 reason = reason,
1511 instance = intag, 1546 instance = intag,
1512 duration = duration, -- deliberately may be nil 1547 duration = duration, -- deliberately may be nil
1513 raidersnap = CopyTable(g_loot.raiders), 1548 raidersnap = self:snapshot_raid(),
1514 maxsize = maxsize, 1549 maxsize = maxsize,
1515 } 1550 }
1516 tinsert(candidates,c) 1551 tinsert(candidates,c)
1517 end 1552 end
1518 break 1553 break