diff text_tabs.lua @ 56:fcc0d0ff5832

- instance_tag() also returns max instance size as a plain number, adjust call sites - clean up .raiders table, add some new fields, use copies of this instead of a single string - make sure datarev field is properly updated when it's already present - avoid multiple GetRaidRosterInfo loops scattered throughout the addon, instead just traverse the .raiders list, regularly updated - make the 'loot' and 'boss' broadcasts versioned. Handle receiving older. - new format for plaintext attendance output
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 13 Apr 2012 04:28:46 +0000
parents ac57a4342812
children 45d2b153c2df
line wrap: on
line diff
--- a/text_tabs.lua	Sat Apr 07 05:40:20 2012 +0000
+++ b/text_tabs.lua	Fri Apr 13 04:28:46 2012 +0000
@@ -137,12 +137,50 @@
 addon:register_text_generator ("forum", [[Forum Markup]], [[BBcode ready for Ouroboros forums]], forum, forum_specials)
 
 
+local ingroups, outgroups = {}, {}
+local function do_attendance (raidertable, max_group_number)
+	local tins, wipe, tsort, tconcat =
+		table.insert, table.wipe, table.sort, table.concat
+
+	-- Assumption:  everybody is packed into the first N groups.
+	if raidertable then for name,info in pairs(raidertable) do
+		if info.online ~= 3 then   -- 3 == left the raid
+			if info.subgroup <= max_group_number then
+				tins (ingroups, name)
+			else
+				tins (outgroups, name)
+			end
+		end
+	end end
+	if #ingroups > 0 then
+		tsort(ingroups)
+	else
+		ingroups[1] = [[Nobody recorded as inside the instance.]]
+	end
+	if #outgroups > 0 then
+		tsort(outgroups)
+	else
+		outgroups[1] = [[Nobody recorded as outside the instance.]]
+	end
+	local i,o = tconcat(ingroups,", "), tconcat(outgroups,", ")
+	wipe(ingroups)
+	wipe(outgroups)
+	return i,o
+end
+
+local saved_g_loot_pointer
 local function att (_, loot, last_printed, _, cache)
+	saved_g_loot_pointer = loot
 	for i = last_printed+1, #loot do
 		local e = loot[i]
 
 		if e.kind == 'boss' and e.reason == 'kill' then
-			cache[#cache+1] = ("\n%s -- %s\n%s"):format(e.instance, e.bossname, e.raiderlist or '<none recorded>')
+			-- This could, concievably, be different on a per-boss basis
+			-- (e.g., "we're dropping to 10-man for the PvP boss")
+			local i,o = do_attendance (e.raidersnap, e.maxsize / MEMBERS_PER_RAID_GROUP)
+
+			cache[#cache+1] = ("\n%s -- %s\n[+] %s\n[-] %s\n"):format(e.instance,
+				e.bossname, i, o)
 
 		elseif e.kind == 'time' then
 			cache[#cache+1] = e.startday.text
@@ -157,13 +195,11 @@
 		[[Take attendance now (will continue to take attendance on each boss kill).]])
 	w:SetFullWidth(true)
 	w:SetCallback("OnClick", function(_w)
-		local raiders = {}
-		for i = 1, GetNumRaidMembers() do
-			table.insert(raiders, (GetRaidRosterInfo(i)))
-		end
-		table.sort(raiders)
+		local instance, maxsize = addon.instance_tag()
+		local i,o = do_attendance (saved_g_loot_pointer.raiders, maxsize / MEMBERS_PER_RAID_GROUP)
 		local h, m = GetGameTime()
-		local additional = ("Attendance at %.2d:%.2d:\n%s"):format(h,m,table.concat(raiders, ", "))
+
+		local additional = ("Attendance for %s at %.2d:%.2d:\n[+] %s\n[-] %s"):format(instance, h, m, i, o)
 		editbox:SetText(editbox:GetText() .. '\n' .. additional)
 	end)
 	container:AddChild(w)