Mercurial > wow > ouroloot
comparison core.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 | 81d5449621f8 |
comparison
equal
deleted
inserted
replaced
55:ac57a4342812 | 56:fcc0d0ff5832 |
---|---|
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 | |
10 by player name with subtable fields: | |
11 - class capitalized English codename ("WARRIOR", "DEATHKNIGHT", etc) | |
12 - subgroup 1-8 | |
13 - race English codename ("BloodElf", etc) | |
14 - sex 1 = unknown/error, 2 = male, 3 = female | |
15 - level can be 0 if player was offline at the time | |
16 - guild guild name, or missing if unguilded | |
17 - online 1 = online, 2 = offline, 3 = no longer in raid | |
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) | |
20 - leave time player left the raid (or time we've left the raid) | |
9 | 21 |
10 Common g_loot entry indices: | 22 Common g_loot entry indices: |
11 - kind time/boss/loot | 23 - kind time/boss/loot |
12 - hour 0-23, on the *physical instance server*, not the realm server | 24 - hour 0-23, on the *physical instance server*, not the realm server |
13 - minute 0-59, ditto | 25 - minute 0-59, ditto |
17 Time specific g_loot indices: | 29 Time specific g_loot indices: |
18 - startday table with month/day/year/text fields from makedate() | 30 - startday table with month/day/year/text fields from makedate() |
19 | 31 |
20 Boss specific g_loot indices: | 32 Boss specific g_loot indices: |
21 - bossname name of boss/encounter; | 33 - bossname name of boss/encounter; |
22 - may be changed if "snarky boss names" option is enabled | 34 may be changed if "snarky boss names" option is enabled |
23 - reason wipe/kill ("pull" does not generate an entry) | 35 - reason wipe/kill ("pull" does not generate an entry) |
24 - instance name of instance, including size and difficulty | 36 - instance name of instance, including size and difficulty |
25 - duration in seconds; may be missing | 37 - maxsize 5/10/25, presumably also 15 and 40 could show up; can be |
26 - raiderlist "Able, Baker, Charlie"; may be missing | 38 0 if we're outside an instance and the player inside has |
39 an older version | |
40 - duration in seconds; may be missing (only present if local) | |
41 - raidersnap copy of g_loot.raiders at the time of the boss event | |
27 | 42 |
28 Loot specific g_loot indices: | 43 Loot specific g_loot indices: |
29 - person recipient | 44 - person recipient |
30 - person_class class of recipient if available; may be missing; | 45 - person_class class of recipient if available; may be missing; |
31 - will be classID-style (e.g., DEATHKNIGHT) | 46 will be classID-style (e.g., DEATHKNIGHT) |
32 - itemname not including square brackets | 47 - itemname not including square brackets |
33 - id itemID as number | 48 - id itemID as number |
34 - itemlink full clickable link | 49 - itemlink full clickable link |
35 - itexture icon path (e.g., Interface\Icons\INV_Misc_Rune_01) | 50 - itexture icon path (e.g., Interface\Icons\INV_Misc_Rune_01) |
36 - quality ITEM_QUALITY_* number | 51 - quality ITEM_QUALITY_* number |
37 - disposition offspec/gvault/shard; missing otherwise; can be set from | 52 - disposition offspec/gvault/shard; missing otherwise; can be set from |
38 - the extratext field | 53 the extratext field |
39 - count e.g., "x3"; missing otherwise; can be set/removed from | 54 - count e.g., "x3"; missing otherwise; can be set/removed from |
40 - extratext; triggers only for a stack of items, not "the boss | 55 extratext; triggers only for a stack of items, not "the boss |
41 - dropped double axes today" | 56 dropped double axes today" |
42 - is_heroic true if item is heroic; missing otherwise | 57 - is_heroic true if item is heroic; missing otherwise |
43 - cache_miss if GetItemInfo failed; SHOULD be missing (changes other fields) | 58 - cache_miss if GetItemInfo failed; SHOULD be missing (changes other fields) |
44 - bcast_from if rebroadcast from another player; missing otherwise | 59 - bcast_from if rebroadcast from another player; missing otherwise |
45 - extratext text in Note column, including disposition and rebroadcasting | 60 - extratext text in Note column, including disposition and rebroadcasting |
46 - extratext_byhand true if text edited by player directly; missing otherwise | 61 - extratext_byhand true if text edited by player directly; missing otherwise |
86 OuroLootSV_log = {} | 101 OuroLootSV_log = {} |
87 | 102 |
88 | 103 |
89 ------ Constants | 104 ------ Constants |
90 local option_defaults = { | 105 local option_defaults = { |
91 ['datarev'] = 15, -- cheating, this isn't actually an option | 106 ['datarev'] = 16, -- cheating, this isn't actually an option |
92 ['popup_on_join'] = true, | 107 ['popup_on_join'] = true, |
93 ['register_slashloot'] = true, | 108 ['register_slashloot'] = true, |
94 ['scroll_to_bottom'] = true, | 109 ['scroll_to_bottom'] = true, |
95 ['chatty_on_kill'] = false, | 110 ['chatty_on_kill'] = false, |
96 ['no_tracking_wipes'] = false, | 111 ['no_tracking_wipes'] = false, |
136 addon.author_debug = flib.author_debug | 151 addon.author_debug = flib.author_debug |
137 | 152 |
138 -- Play cute games with namespaces here just to save typing. WTB Lua 5.2 PST. | 153 -- Play cute games with namespaces here just to save typing. WTB Lua 5.2 PST. |
139 do local _G = _G setfenv (1, addon) | 154 do local _G = _G setfenv (1, addon) |
140 | 155 |
141 commrev = 15 -- number | 156 commrev = '16' |
142 revision = _G.GetAddOnMetadata(nametag,"Version") or "?" -- "x.yy.z", etc | 157 revision = _G.GetAddOnMetadata(nametag,"Version") or "?" -- "x.yy.z", etc |
143 ident = "OuroLoot2" | 158 ident = "OuroLoot2" |
144 identTg = "OuroLoot2Tg" | 159 identTg = "OuroLoot2Tg" |
145 status_text = nil | 160 status_text = nil |
146 | 161 |
231 local g_wafer_thin = nil -- for prompting for additional rebroadcasters | 246 local g_wafer_thin = nil -- for prompting for additional rebroadcasters |
232 local g_today = nil -- "today" entry in g_loot | 247 local g_today = nil -- "today" entry in g_loot |
233 local g_boss_signpost = nil | 248 local g_boss_signpost = nil |
234 local opts = nil | 249 local opts = nil |
235 | 250 |
236 local pairs, ipairs, tinsert, tremove, tonumber, wipe = | 251 local pairs, ipairs, tinsert, tremove, tostring, tonumber, wipe = |
237 pairs, ipairs, table.insert, table.remove, tonumber, table.wipe | 252 pairs, ipairs, table.insert, table.remove, tostring, tonumber, table.wipe |
238 local pprint, tabledump = addon.pprint, flib.tabledump | 253 local pprint, tabledump = addon.pprint, flib.tabledump |
239 local GetNumRaidMembers = GetNumRaidMembers | 254 local CopyTable, GetNumRaidMembers = CopyTable, GetNumRaidMembers |
240 -- En masse forward decls of symbols defined inside local blocks | 255 -- En masse forward decls of symbols defined inside local blocks |
241 local _register_bossmod, makedate, create_new_cache, _init, _log | 256 local _register_bossmod, makedate, create_new_cache, _init, _log |
242 | 257 |
243 -- Try to extract numbers from the .toc "Version" and munge them into an | 258 -- Try to extract numbers from the .toc "Version" and munge them into an |
244 -- integral form for comparison. The result doesn't need to be meaningful as | 259 -- integral form for comparison. The result doesn't need to be meaningful as |
321 local text = ("%d %s %d"):format(D, CALENDAR_FULLDATE_MONTH_NAMES[M], Y) | 336 local text = ("%d %s %d"):format(D, CALENDAR_FULLDATE_MONTH_NAMES[M], Y) |
322 return text, M, D, Y | 337 return text, M, D, Y |
323 end | 338 end |
324 end | 339 end |
325 | 340 |
326 -- Returns an instance name or abbreviation | 341 -- Returns an instance name or abbreviation, followed by the raid size |
327 local function instance_tag() | 342 local function instance_tag() |
328 local name, typeof, diffcode, diffstr, _, perbossheroic, isdynamic = GetInstanceInfo() | 343 local name, typeof, diffcode, diffstr, _, perbossheroic, isdynamic = GetInstanceInfo() |
329 local t | 344 local t, r |
330 name = addon.instance_abbrev[name] or name | 345 name = addon.instance_abbrev[name] or name |
331 if typeof == "none" then return name end | 346 if typeof == "none" then return name, MAX_RAID_MEMBERS end |
332 -- diffstr is "5 Player", "10 Player (Heroic)", etc. ugh. | 347 -- diffstr is "5 Player", "10 Player (Heroic)", etc. ugh. |
333 if (GetLFGMode()) and (GetLFGModeType() == 'raid') then | 348 if (GetLFGMode()) and (GetLFGModeType() == 'raid') then |
334 t = 'LFR' | 349 t,r = 'LFR', 25 |
335 elseif diffcode == 1 then | 350 elseif diffcode == 1 then |
336 t = ((GetNumRaidMembers()>0) and "10" or "5") | 351 t,r = (GetNumRaidMembers()>0) and "10",10 or "5",5 |
337 elseif diffcode == 2 then | 352 elseif diffcode == 2 then |
338 t = ((GetNumRaidMembers()>0) and "25" or "5h") | 353 t,r = (GetNumRaidMembers()>0) and "25",25 or "5h",5 |
339 elseif diffcode == 3 then | 354 elseif diffcode == 3 then |
340 t = "10h" | 355 t,r = "10h", 10 |
341 elseif diffcode == 4 then | 356 elseif diffcode == 4 then |
342 t = "25h" | 357 t,r = "25h", 25 |
343 end | 358 end |
344 -- dynamic difficulties always return normal "codes" | 359 -- dynamic difficulties always return normal "codes" |
345 if isdynamic and perbossheroic == 1 then | 360 if isdynamic and perbossheroic == 1 then |
346 t = t .. "h" | 361 t = t .. "h" |
347 end | 362 end |
348 return name .. "(" .. t .. ")" | 363 pprint("instance_tag final", t, r) |
364 return name .. "(" .. t .. ")", r | |
349 end | 365 end |
350 addon.instance_tag = instance_tag -- grumble | 366 addon.instance_tag = instance_tag -- grumble |
351 addon.latest_instance = nil -- spelling reminder, assigned elsewhere | 367 addon.latest_instance = nil -- spelling reminder, assigned elsewhere |
352 | 368 |
353 | 369 |
446 for opt,default in pairs(option_defaults) do | 462 for opt,default in pairs(option_defaults) do |
447 if opts[opt] == nil then | 463 if opts[opt] == nil then |
448 opts[opt] = default | 464 opts[opt] = default |
449 end | 465 end |
450 end | 466 end |
467 opts.datarev = option_defaults.datarev | |
451 | 468 |
452 -- transition&remove old options | 469 -- transition&remove old options |
453 opts['forum_use_itemid'] = nil | 470 opts['forum_use_itemid'] = nil |
454 if opts['forum_format'] then | 471 if opts['forum_format'] then |
455 opts.forum['Custom...'] = opts['forum_format'] | 472 opts.forum['Custom...'] = opts['forum_format'] |
508 end | 525 end |
509 end | 526 end |
510 self.history_all.HISTFORMAT = nil -- don't keep this in live data | 527 self.history_all.HISTFORMAT = nil -- don't keep this in live data |
511 --OuroLootSV_hist = nil | 528 --OuroLootSV_hist = nil |
512 | 529 |
513 -- Handle changes to the stored data format, in stages from oldest to | 530 -- Handle changes to the stored data format in stages from oldest to newest. |
514 -- newest. This won't look coherent until multiple stages are happening. | 531 if OuroLootSV then |
515 if stored_datarev == nil then | 532 local dirty = false |
516 self:Print("Transitioning saved data format to 15...") | 533 if stored_datarev == nil then |
517 for i,e in ipairs(OuroLootSV) do | 534 self:Print("Transitioning saved data format to 15..."); dirty = true |
518 if e.bosskill then | 535 for i,e in ipairs(OuroLootSV) do |
519 e.bossname, e.bosskill = e.bosskill, nil | 536 if e.bosskill then |
520 end | 537 e.bossname, e.bosskill = e.bosskill, nil |
521 end | 538 end |
522 stored_datarev = 15 | 539 end |
523 end | 540 stored_datarev = 15 |
524 --if stored_datarev == 15 then.... | 541 end |
542 if stored_datarev == 15 then | |
543 self:Print("Transitioning saved data format to 16..."); dirty = true | |
544 for i,e in ipairs(OuroLootSV) do | |
545 if e.kind == 'boss' then | |
546 e.maxsize, e.raiderlist, e.raidersnap = 0, nil, {} | |
547 end | |
548 end | |
549 OuroLootSV.raiders = OuroLootSV.raiders or {} | |
550 for name,r in pairs(OuroLootSV.raiders) do | |
551 r.subgroup = 0 | |
552 end | |
553 stored_datarev = 16 | |
554 end | |
555 if dirty then self:Print("Saved data has been massaged into shape.") end | |
556 end | |
525 | 557 |
526 _init(self) | 558 _init(self) |
527 self.dprint('flow', "version strings:", revision_large, self.status_text) | 559 self.dprint('flow', "version strings:", revision_large, self.status_text) |
528 self.OnInitialize = nil | 560 self.OnInitialize = nil |
529 end | 561 end |
679 OuroLootSV_log = #OuroLootSV_log > 0 and OuroLootSV_log or nil | 711 OuroLootSV_log = #OuroLootSV_log > 0 and OuroLootSV_log or nil |
680 end | 712 end |
681 | 713 |
682 do | 714 do |
683 local IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, | 715 local IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, |
684 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo = | 716 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo = |
685 IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, | 717 IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, |
686 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo | 718 UnitLevel, UnitInRaid, UnitIsVisible, GetGuildInfo, GetRaidRosterInfo |
687 local time, difftime = time, difftime | 719 local time, difftime = time, difftime |
688 local R_ACTIVE, R_OFFLINE, R_LEFT = 1, 2, 3 | 720 local R_ACTIVE, R_OFFLINE, R_LEFT = 1, 2, 3 |
689 | 721 |
690 local lastevent, now = 0, 0 | 722 local lastevent, now = 0, 0 |
691 local redo_count = 0 | 723 local redo_count = 0 |
725 if name and name ~= UNKNOWN and name ~= UNKNOWNOBJECT and name ~= UKNOWNBEING then | 757 if name and name ~= UNKNOWN and name ~= UNKNOWNOBJECT and name ~= UKNOWNBEING then |
726 if not g_loot.raiders[name] then | 758 if not g_loot.raiders[name] then |
727 g_loot.raiders[name] = { needinfo=true } | 759 g_loot.raiders[name] = { needinfo=true } |
728 end | 760 end |
729 local r = g_loot.raiders[name] | 761 local r = g_loot.raiders[name] |
762 -- We grab a bunch of return values here, but only pay attention to | |
763 -- them under specific circumstances. | |
764 local grri_name, connected, subgroup, level, class, _ | |
765 grri_name, _, subgroup, level, _, class, connected = GetRaidRosterInfo(i) | |
766 assert(name==grri_name, "UnitName =/= grri_name of same raidindex") | |
767 r.subgroup = subgroup | |
730 if r.needinfo and UnitIsVisible(unit) then | 768 if r.needinfo and UnitIsVisible(unit) then |
731 r.needinfo = nil | 769 r.needinfo = nil |
732 r.class = select(2,UnitClass(unit)) | 770 r.class = class --select(2,UnitClass(unit)) |
733 r.race = select(2,UnitRace(unit)) | 771 r.race = select(2,UnitRace(unit)) |
734 r.sex = UnitSex(unit) | 772 r.sex = UnitSex(unit) |
735 r.level = UnitLevel(unit) | 773 r.level = level --UnitLevel(unit) |
736 r.guild = GetGuildInfo(unit) | 774 r.guild = GetGuildInfo(unit) |
737 end | 775 end |
738 local connected = UnitIsConnected(unit) | 776 --local connected = UnitIsConnected(unit) |
739 if connected and r.online ~= R_ACTIVE then | 777 if connected and r.online ~= R_ACTIVE then |
740 r.join = r.join or now | 778 r.join = r.join or now |
741 r.online = R_ACTIVE | 779 r.online = R_ACTIVE |
742 elseif (not connected) and r.online ~= R_OFFLINE then | 780 elseif (not connected) and r.online ~= R_OFFLINE then |
743 r.leave = now | 781 r.leave = now |
868 | 906 |
869 itemid = tonumber(ilink:match("item:(%d+)") or 0) | 907 itemid = tonumber(ilink:match("item:(%d+)") or 0) |
870 -- This is only a 'while' to make jumping out of it easy and still do cleanup below. | 908 -- This is only a 'while' to make jumping out of it easy and still do cleanup below. |
871 while local_override or ((iquality >= self.threshold) and not opts.itemfilter[itemid]) do | 909 while local_override or ((iquality >= self.threshold) and not opts.itemfilter[itemid]) do |
872 if (self.rebroadcast and (not from)) and not local_override then | 910 if (self.rebroadcast and (not from)) and not local_override then |
873 self:broadcast('loot', recipient, itemid, count) | 911 self:vbroadcast('loot', recipient, itemid, count) |
874 end | 912 end |
875 if (not self.enabled) and (not local_override) then break end | 913 if (not self.enabled) and (not local_override) then break end |
876 local signature = recipient .. iname .. (count or "") | 914 local signature = recipient .. iname .. (count or "") |
877 if from and self.recent_loot:test(signature) then | 915 if from and self.recent_loot:test(signature) then |
878 self.dprint('cache', "remote loot <",signature,"> already in cache, skipping") | 916 self.dprint('cache', "remote loot <",signature,"> already in cache, skipping") |
1209 wipe(temp) | 1247 wipe(temp) |
1210 end | 1248 end |
1211 addon.sender_list.namesI = byindex | 1249 addon.sender_list.namesI = byindex |
1212 end | 1250 end |
1213 | 1251 |
1214 -- Message sending. | |
1215 -- See OCR_funcs.tag at the end of this file for incoming message treatment. | |
1216 do | |
1217 local function assemble(...) | |
1218 local msg = ... | |
1219 for i = 2, select('#',...) do | |
1220 msg = msg .. '\a' .. (select(i,...) or "") | |
1221 end | |
1222 return msg | |
1223 end | |
1224 | |
1225 -- broadcast('tag', <stuff>) | |
1226 function addon:broadcast(...) | |
1227 local msg = assemble(...) | |
1228 self.dprint('comm', "<broadcast>:", msg) | |
1229 -- the "GUILD" here is just so that we can also pick up on it | |
1230 self:SendCommMessage(self.ident, msg, self.debug.comm and "GUILD" or "RAID") | |
1231 end | |
1232 -- whispercast(<to>, 'tag', <stuff>) | |
1233 function addon:whispercast(to,...) | |
1234 local msg = assemble(...) | |
1235 self.dprint('comm', "<whispercast>@", to, ":", msg) | |
1236 self:SendCommMessage(self.identTg, msg, "WHISPER", to) | |
1237 end | |
1238 end | |
1239 | |
1240 function addon:DoPing() | 1252 function addon:DoPing() |
1241 self:Print("Give me a ping, Vasili. One ping only, please.") | 1253 self:Print("Give me a ping, Vasili. One ping only, please.") |
1242 self.sender_list.active = {} | 1254 self.sender_list.active = {} |
1243 self.sender_list.names = {} | 1255 self.sender_list.names = {} |
1244 self:broadcast('ping') | 1256 self:broadcast('ping') |
1359 end | 1371 end |
1360 if possible_st then | 1372 if possible_st then |
1361 possible_st:SetData(g_loot) | 1373 possible_st:SetData(g_loot) |
1362 end | 1374 end |
1363 | 1375 |
1364 self.status_text = ("%s communicating as ident %s commrev %d"):format(self.revision,self.ident,self.commrev) | 1376 self.status_text = ("%s communicating as ident %s commrev %s"):format(self.revision,self.ident,self.commrev) |
1365 self:RegisterComm(self.ident) | 1377 self:RegisterComm(self.ident) |
1366 self:RegisterComm(self.identTg, "OnCommReceivedNocache") | 1378 self:RegisterComm(self.identTg, "OnCommReceivedNocache") |
1367 | 1379 |
1368 if self.author_debug then | 1380 if self.author_debug then |
1369 _G.OL = self | 1381 _G.OL = self |
1416 wipe(candidates) | 1428 wipe(candidates) |
1417 end | 1429 end |
1418 addon.recent_boss = create_new_cache ('boss', 10, fixup_durations) | 1430 addon.recent_boss = create_new_cache ('boss', 10, fixup_durations) |
1419 | 1431 |
1420 -- Similar to _do_loot, but duration+ parms only present when locally generated. | 1432 -- Similar to _do_loot, but duration+ parms only present when locally generated. |
1421 local function _do_boss (self, reason, bossname, intag, duration, raiders) | 1433 local function _do_boss (self, reason, bossname, intag, maxsize, duration) |
1422 self.dprint('loot',">>_do_boss, R:", reason, "B:", bossname, "T:", intag, | 1434 self.dprint('loot',">>_do_boss, R:", reason, "B:", bossname, |
1423 "D:", duration, "RL:", (raiders and #raiders or 'nil')) | 1435 "T:", intag, "MS:", maxsize, "D:", duration) |
1424 if self.rebroadcast and duration then | 1436 if self.rebroadcast and duration then |
1425 self:broadcast('boss', reason, bossname, intag) | 1437 self:vbroadcast('boss', reason, bossname, intag, maxsize) |
1426 end | 1438 end |
1427 -- This is only a loop to make jumping out of it easy, and still do cleanup below. | 1439 -- This is only a loop to make jumping out of it easy, and still do cleanup below. |
1428 while self.enabled do | 1440 while self.enabled do |
1429 if reason == 'wipe' and opts.no_tracking_wipes then break end | 1441 if reason == 'wipe' and opts.no_tracking_wipes then break end |
1430 bossname = (opts.snarky_boss and self.boss_abbrev[bossname] or bossname) or bossname | 1442 bossname = (opts.snarky_boss and self.boss_abbrev[bossname] or bossname) or bossname |
1445 local c = { | 1457 local c = { |
1446 kind = 'boss', | 1458 kind = 'boss', |
1447 bossname = bossname, | 1459 bossname = bossname, |
1448 reason = reason, | 1460 reason = reason, |
1449 instance = intag, | 1461 instance = intag, |
1450 duration = duration, -- these two deliberately may be nil | 1462 duration = duration, -- deliberately may be nil |
1451 raiderlist = raiders and table.concat(raiders, ", ") | 1463 raidersnap = CopyTable(g_loot.raiders), |
1464 maxsize = maxsize, | |
1452 } | 1465 } |
1453 tinsert(candidates,c) | 1466 tinsert(candidates,c) |
1454 end | 1467 end |
1455 break | 1468 break |
1456 end | 1469 end |
1457 self.dprint('loot',"<<_do_boss out") | 1470 self.dprint('loot',"<<_do_boss out") |
1458 end | 1471 end |
1459 -- No wrapping layer for now | 1472 -- This exposes the function to OCR, and can be a wrapper layer later. |
1460 addon.on_boss_broadcast = _do_boss | 1473 addon.on_boss_broadcast = _do_boss |
1461 | 1474 |
1462 function addon:_mark_boss_kill (index) | 1475 function addon:_mark_boss_kill (index) |
1463 local e = g_loot[index] | 1476 local e = g_loot[index] |
1464 if not e then | 1477 if not e then |
2026 end | 2039 end |
2027 | 2040 |
2028 | 2041 |
2029 ------ Player communication | 2042 ------ Player communication |
2030 do | 2043 do |
2044 local select, tconcat, strsplit = select, table.concat, strsplit | |
2045 --[[ old way: repeated string concatenations, BAD | |
2046 new way: new table on every call, BAD | |
2047 local msg = ... | |
2048 for i = 2, select('#',...) do | |
2049 msg = msg .. '\a' .. (select(i,...) or "") | |
2050 end | |
2051 return msg | |
2052 ]] | |
2053 local function assemble(t,...) | |
2054 if select('#',...) > 0 then | |
2055 local msg = {t,...} | |
2056 -- tconcat requires strings, but T is known to be one already | |
2057 for i = 2, #msg do | |
2058 msg[i] = tostring(msg[i]) or "" | |
2059 end | |
2060 return tconcat (msg, '\a') | |
2061 end | |
2062 return t | |
2063 end | |
2064 | |
2065 -- broadcast('tag', <stuff>) | |
2066 -- vbroadcast('tag', <stuff>) | |
2067 function addon:vbroadcast(tag,...) | |
2068 return self:broadcast(self.commrev..tag,...) | |
2069 end | |
2070 function addon:broadcast(tag,...) | |
2071 local msg = assemble(tag,...) | |
2072 self.dprint('comm', "<broadcast>:", msg) | |
2073 -- the "GUILD" here is just so that we can also pick up on it | |
2074 self:SendCommMessage(self.ident, msg, self.debug.comm and "GUILD" or "RAID") | |
2075 end | |
2076 -- whispercast(<to>, 'tag', <stuff>) | |
2077 function addon:whispercast(to,...) | |
2078 local msg = assemble(...) | |
2079 self.dprint('comm', "<whispercast>@", to, ":", msg) | |
2080 self:SendCommMessage(self.identTg, msg, "WHISPER", to) | |
2081 end | |
2082 | |
2031 local function adduser (name, status, active) | 2083 local function adduser (name, status, active) |
2032 if status then addon.sender_list.names[name] = status end | 2084 if status then addon.sender_list.names[name] = status end |
2033 if active then addon.sender_list.active[name] = active end | 2085 if active then addon.sender_list.active[name] = active end |
2034 end | 2086 end |
2035 | 2087 |
2057 addon.dprint('comm', "DOTloot, sender", sender, "recip", recip, "item", item, "count", count) | 2109 addon.dprint('comm', "DOTloot, sender", sender, "recip", recip, "item", item, "count", count) |
2058 if not addon.enabled then return end | 2110 if not addon.enabled then return end |
2059 adduser (sender, nil, true) | 2111 adduser (sender, nil, true) |
2060 addon:CHAT_MSG_LOOT ("broadcast", recip, item, count, sender, extratext) | 2112 addon:CHAT_MSG_LOOT ("broadcast", recip, item, count, sender, extratext) |
2061 end | 2113 end |
2114 OCR_funcs['16loot'] = OCR_funcs.loot | |
2062 | 2115 |
2063 OCR_funcs.boss = function (sender, _, reason, bossname, instancetag) | 2116 OCR_funcs.boss = function (sender, _, reason, bossname, instancetag) |
2064 addon.dprint('comm', "DOTboss, sender", sender, "reason", reason, "name", bossname, "it", instancetag) | 2117 addon.dprint('comm', "DOTboss, sender", sender, "reason", reason, |
2118 "name", bossname, "it", instancetag) | |
2065 if not addon.enabled then return end | 2119 if not addon.enabled then return end |
2066 adduser (sender, nil, true) | 2120 adduser (sender, nil, true) |
2067 addon:on_boss_broadcast (reason, bossname, instancetag) | 2121 addon:on_boss_broadcast (reason, bossname, instancetag, --[[maxsize=]]0) |
2122 end | |
2123 OCR_funcs['16boss'] = function (sender, _, reason, bossname, instancetag, maxsize) | |
2124 addon.dprint('comm', "DOTboss16, sender", sender, "reason", reason, | |
2125 "name", bossname, "it", instancetag, "size", maxsize) | |
2126 if not addon.enabled then return end | |
2127 adduser (sender, nil, true) | |
2128 addon:on_boss_broadcast (reason, bossname, instancetag, maxsize) | |
2068 end | 2129 end |
2069 | 2130 |
2070 OCR_funcs.bcast_req = function (sender) | 2131 OCR_funcs.bcast_req = function (sender) |
2071 if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast)) | 2132 if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast)) |
2072 then | 2133 then |