comparison core.lua @ 89:939569ded66f

- Also include revision numbers when sending/displaying version data. - Do a tweaked variant of the "ensure useful unique tags" code in _addLootEntry. - When debugging comms, send to raid *and* guild instead of either. - Remove flaky optimization in fixup_unique_replacements. Thanks to Hyndron for helping me test this with genuine non-contrived data.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 28 Jun 2012 19:44:53 +0000
parents c9f955f9a285
children 92e0db376858
comparison
equal deleted inserted replaced
88:c9f955f9a285 89:939569ded66f
163 ['artifact'] = 6, 163 ['artifact'] = 6,
164 --['heirloom'] = 7, 164 --['heirloom'] = 7,
165 } 165 }
166 local my_name = UnitName('player') 166 local my_name = UnitName('player')
167 local comm_cleanup_ttl = 4 -- seconds in the communications cache 167 local comm_cleanup_ttl = 4 -- seconds in the communications cache
168 local revision_large = nil -- defaults to 1, possibly changed by revision 168 local version_large = nil -- defaults to 1, possibly changed by version
169 local g_LOOT_ITEM_ss, g_LOOT_ITEM_MULTIPLE_sss, g_LOOT_ITEM_SELF_s, g_LOOT_ITEM_SELF_MULTIPLE_ss 169 local g_LOOT_ITEM_ss, g_LOOT_ITEM_MULTIPLE_sss, g_LOOT_ITEM_SELF_s, g_LOOT_ITEM_SELF_MULTIPLE_ss
170 170
171 171
172 ------ Addon member data 172 ------ Addon member data
173 local flib = LibStub("LibFarmbuyer") 173 local flib = LibStub("LibFarmbuyer")
175 175
176 -- Play cute games with namespaces here just to save typing. WTB Lua 5.2 PST. 176 -- Play cute games with namespaces here just to save typing. WTB Lua 5.2 PST.
177 do local _G = _G setfenv (1, addon) 177 do local _G = _G setfenv (1, addon)
178 178
179 commrev = '17' 179 commrev = '17'
180 revision = _G.GetAddOnMetadata(nametag,"Version") or "?" -- "x.yy.z", etc 180 version = _G.GetAddOnMetadata(nametag,"Version") or "?" -- "x.yy.z", etc
181 ident = "OuroLoot2" 181 ident = "OuroLoot2"
182 identTg = "OuroLoot2Tg" 182 identTg = "OuroLoot2Tg"
183 status_text = nil 183 status_text = nil
184 revision = "@project-revision@"
185 --@debug@
186 revision = "DEVEL"
187 --@end-debug@
184 188
185 tekdebug = nil 189 tekdebug = nil
186 if _G.tekDebug then 190 if _G.tekDebug then
187 local tdframe = _G.tekDebug:GetFrame("Ouro Loot") 191 local tdframe = _G.tekDebug:GetFrame("Ouro Loot")
188 function tekdebug (txt) 192 function tekdebug (txt)
381 385
382 -- Try to extract numbers from the .toc "Version" and munge them into an 386 -- Try to extract numbers from the .toc "Version" and munge them into an
383 -- integral form for comparison. The result doesn't need to be meaningful as 387 -- integral form for comparison. The result doesn't need to be meaningful as
384 -- long as we can reliably feed two of them to "<" and get useful answers. 388 -- long as we can reliably feed two of them to "<" and get useful answers.
385 -- 389 --
386 -- This makes/reinforces an assumption that revision_large of release packages 390 -- This makes/reinforces an assumption that version_large of release packages
387 -- (e.g., 2016001) will always be higher than those of development packages 391 -- (e.g., 2016001) will always be higher than those of development packages
388 -- (e.g., 87), due to the tagging system versus subversion file revs. This 392 -- (e.g., 87), due to the tagging system versus subversion file revs. This
389 -- is good, as local dev code will never trigger a false positive update 393 -- is good, as local dev code will never trigger a false positive update
390 -- warning for other users. 394 -- warning for other users.
391 do 395 do
392 local r = 0 396 local r = 0
393 for d in addon.revision:gmatch("%d+") do 397 for d in addon.version:gmatch("%d+") do
394 r = 1000*r + d 398 r = 1000*r + d
395 end 399 end
396 -- If it's a big enough number to obviously be a release, then make 400 -- If it's a big enough number to obviously be a release, then make
397 -- sure it's big enough to overcome many small previous point releases. 401 -- sure it's big enough to overcome many small previous point releases.
398 while r > 2000 and r < 2000000 do 402 while r > 2000 and r < 2000000 do
399 r = 1000*r 403 r = 1000*r
400 end 404 end
401 revision_large = math.max(r,1) 405 version_large = math.max(r,1)
402 end 406 end
403 407
404 -- Hypertext support, inspired by DBM broadcast pizza timers 408 -- Hypertext support, inspired by DBM broadcast pizza timers
405 do 409 do
406 local hypertext_format_str = "|HOuroLoot:%d|h%s[%s]|r|h" 410 local hypertext_format_str = "|HOuroLoot:%d|h%s[%s]|r|h"
870 end 874 end
871 if dirty then self:Print("Saved data has been massaged into shape.") end 875 if dirty then self:Print("Saved data has been massaged into shape.") end
872 end 876 end
873 877
874 _init(self) 878 _init(self)
875 self.dprint('flow', "version strings:", revision_large, self.status_text) 879 self.dprint('flow', "version strings:", version_large, self.revision, self.status_text)
876 self.load_assert = nil 880 self.load_assert = nil
877 self.OnInitialize = nil -- free up ALL the things! 881 self.OnInitialize = nil -- free up ALL the things!
878 end 882 end
879 883
880 function addon:OnEnable() 884 function addon:OnEnable()
1047 -- Fires before the plugin's own OnEnable (inherited or otherwise). 1051 -- Fires before the plugin's own OnEnable (inherited or otherwise).
1048 --function addon:OnModuleCreated (plugin) 1052 --function addon:OnModuleCreated (plugin)
1049 -- print("created plugin", plugin:GetName()) 1053 -- print("created plugin", plugin:GetName())
1050 --end 1054 --end
1051 1055
1052 local olrev = tonumber("@project-revision@") or 0
1053 local err = [[Module '%s' cannot register itself because it failed a required condition: '%s']] 1056 local err = [[Module '%s' cannot register itself because it failed a required condition: '%s']]
1054 function addon:ConstrainedNewModule (modname, minrev, mincomm, mindata) 1057 function addon:ConstrainedNewModule (modname, minrev, mincomm, mindata)
1055 if not addon.author_debug then 1058 if not addon.author_debug then
1056 if minrev and minrev > olrev then 1059 if minrev and tonumber(minrev) > (tonumber(self.revision) or math.huge) then
1057 self:Print(err,modname, 1060 self:Print(err,modname,
1058 "revision "..olrev.." older than minimum "..minrev) 1061 "revision "..self.revision.." older than minimum "..minrev)
1059 return false 1062 return false
1060 end 1063 end
1061 if mincomm and mincomm > tonumber(self.commrev) then 1064 if mincomm and tonumber(mincomm) > tonumber(self.commrev) then
1062 self:Print(err,modname, 1065 self:Print(err,modname,
1063 "commrev "..self.commrev.." older than minimum "..mincomm) 1066 "commrev "..self.commrev.." older than minimum "..mincomm)
1064 return false 1067 return false
1065 end 1068 end
1066 if mindata and mindata > opts.datarev then 1069 if mindata and tonumber(mindata) > opts.datarev then
1067 self:Print(err,modname, 1070 self:Print(err,modname,
1068 "datarev "..opts.datarev.." older than minimum "..mindata) 1071 "datarev "..opts.datarev.." older than minimum "..mindata)
1069 return false 1072 return false
1070 end 1073 end
1071 end 1074 end
1541 if not itemstring then 1544 if not itemstring then
1542 itemstring = msg:match(g_LOOT_ITEM_SELF_s) 1545 itemstring = msg:match(g_LOOT_ITEM_SELF_s)
1543 end 1546 end
1544 end 1547 end
1545 1548
1549 if not itemstring then return end -- "PlayerX selected Greed", etc, not looting
1546 self.dprint('loot', "CHAT_MSG_LOOT, person is", person, 1550 self.dprint('loot', "CHAT_MSG_LOOT, person is", person,
1547 ", itemstring is", itemstring, ", count is", count) 1551 ", itemstring is", itemstring, ", count is", count)
1548 if not itemstring then return end -- "PlayerX selected Greed", etc, not looting
1549 1552
1550 -- Name might be colorized, remove the highlighting 1553 -- Name might be colorized, remove the highlighting
1551 if person then 1554 if person then
1552 person = person:match("|c%x%x%x%x%x%x%x%x(%S+)") or person 1555 person = person:match("|c%x%x%x%x%x%x%x%x(%S+)") or person
1553 else 1556 else
1735 self:SetThreshold (opt_threshold, --[[quiet_p=]]true) 1738 self:SetThreshold (opt_threshold, --[[quiet_p=]]true)
1736 end 1739 end
1737 self:Print("Now %s; threshold currently %s.", 1740 self:Print("Now %s; threshold currently %s.",
1738 self.enabled and "tracking" or "only broadcasting", 1741 self.enabled and "tracking" or "only broadcasting",
1739 self.thresholds[self.threshold]) 1742 self.thresholds[self.threshold])
1740 self:broadcast('revcheck',revision_large) 1743 self:broadcast('revcheck',version_large)
1741 end 1744 end
1742 1745
1743 -- Note: running '/loot off' will also avoid the popup reminder when 1746 -- Note: running '/loot off' will also avoid the popup reminder when
1744 -- joining a raid, but will not change the saved option setting. 1747 -- joining a raid, but will not change the saved option setting.
1745 function addon:Deactivate() 1748 function addon:Deactivate()
1845 local e = g_loot[index] 1848 local e = g_loot[index]
1846 if not e then 1849 if not e then
1847 -- how did this happen? 1850 -- how did this happen?
1848 return 1851 return
1849 end 1852 end
1853 if source == my_name then
1854 source = _G.UNIT_YOU
1855 end
1850 local from_text, to_text 1856 local from_text, to_text
1851 if from_whom then 1857 if from_whom then
1858 if from_whom == my_name then
1859 from_whom = _G.UNIT_YOU
1860 end
1852 from_text = addon:colorize (from_whom, from_class) 1861 from_text = addon:colorize (from_whom, from_class)
1853 to_text = addon:colorize (e.person, e.person_class) 1862 to_text = e.person == my_name and _G.UNIT_YOU or e.person
1863 to_text = addon:colorize (to_text, e.person_class)
1854 else 1864 else
1855 if olddisp then 1865 if olddisp then
1856 from_text = addon.disposition_colors[olddisp].text 1866 from_text = addon.disposition_colors[olddisp].text
1857 else 1867 else
1858 olddisp = "normal" 1868 olddisp = "normal"
1908 function addon:DoPing() 1918 function addon:DoPing()
1909 self:Print("Give me a ping, Vasili. One ping only, please.") 1919 self:Print("Give me a ping, Vasili. One ping only, please.")
1910 self.sender_list.active = {} 1920 self.sender_list.active = {}
1911 self.sender_list.names = {} 1921 self.sender_list.names = {}
1912 self:broadcast('ping') 1922 self:broadcast('ping')
1913 self:broadcast('revcheck',revision_large) 1923 self:broadcast('revcheck',version_large)
1914 end 1924 end
1915 1925
1916 function addon:_check_revision (otherrev) 1926 function addon:_check_version (otherrev)
1917 self.dprint('comm', "revchecking against", otherrev) 1927 self.dprint('comm', "revchecking against", otherrev)
1918 otherrev = tonumber(otherrev) 1928 otherrev = tonumber(otherrev)
1919 if otherrev == revision_large then 1929 if otherrev == version_large then
1920 -- normal case 1930 -- normal case
1921 1931
1922 elseif otherrev < revision_large then 1932 elseif otherrev < version_large then
1923 self.dprint('comm', "ours is newer, notifying") 1933 self.dprint('comm', "ours is newer, notifying")
1924 self:broadcast('revcheck',revision_large) 1934 self:broadcast('revcheck',version_large)
1925 1935
1926 else 1936 else
1927 self.dprint('comm', "ours is older, (possibly) yammering") 1937 self.dprint('comm', "ours is older, (possibly) yammering")
1928 if newer_warning then 1938 if newer_warning then
1929 local pop = addon.format_hypertext ([[click here]], ITEM_QUALITY_UNCOMMON, 1939 local pop = addon.format_hypertext ([[click here]], ITEM_QUALITY_UNCOMMON,
2041 end 2051 end
2042 if possible_st then 2052 if possible_st then
2043 possible_st:SetData(g_loot) 2053 possible_st:SetData(g_loot)
2044 end 2054 end
2045 2055
2046 self.status_text = ("%s communicating as ident %s commrev %s"): 2056 self.status_text = ("%s(r%s) communicating as ident %s commrev %s"):
2047 format (self.revision, self.ident, self.commrev) 2057 format (self.version, self.revision, self.ident, self.commrev)
2048 self:RegisterComm(self.ident) 2058 self:RegisterComm(self.ident)
2049 self:RegisterComm(self.identTg, "OnCommReceivedNocache") 2059 self:RegisterComm(self.identTg, "OnCommReceivedNocache")
2050 2060
2051 if self.author_debug then 2061 if self.author_debug then
2052 _G.Oloot = g_loot 2062 _G.Oloot = g_loot
2327 end 2337 end
2328 addon:_fill_out_eoi_data(1) 2338 addon:_fill_out_eoi_data(1)
2329 end 2339 end
2330 2340
2331 -- Adding anything original to g_loot goes through this routine. 2341 -- Adding anything original to g_loot goes through this routine.
2342 -- More precisely, anything new on the EOI tab hits this; it does not
2343 -- necessarily need to be a looted item.
2332 function addon._addLootEntry (e) 2344 function addon._addLootEntry (e)
2333 setmetatable(e,loot_entry_mt) 2345 setmetatable(e,loot_entry_mt)
2334 2346
2335 if not done_todays_date then do_todays_date() end 2347 if not done_todays_date then do_todays_date() end
2336 2348
2338 --local localuptime = math.floor(GetTime()) 2350 --local localuptime = math.floor(GetTime())
2339 local time_t = _G.time() 2351 local time_t = _G.time()
2340 e.hour = h 2352 e.hour = h
2341 e.minute = m 2353 e.minute = m
2342 e.stamp = time_t --localuptime 2354 e.stamp = time_t --localuptime
2355 if e.kind == 'loot' then
2356 if (not e.unique) or (#e.unique==0) then
2357 e.unique = e.id .. (e.disposition or e.person) .. _G.date("%Y/%m/%d %H:%M",e.stamp)
2358 end
2359 end
2343 local index = #g_loot + 1 2360 local index = #g_loot + 1
2344 g_loot[index] = e 2361 g_loot[index] = e
2345 return index 2362 return index
2346 end 2363 end
2347 2364
2461 winning_index = i 2478 winning_index = i
2462 end 2479 end
2463 info[i] = nil 2480 info[i] = nil
2464 end 2481 end
2465 pprint('improv', "final:", winner[1], winner[2]) 2482 pprint('improv', "final:", winner[1], winner[2])
2466 --@debug@
2467 -- purely a sanity check
2468 if winning_index == 1 then
2469 if winner[2] ~= info.LOCAL then
2470 pprint('improv',
2471 "things locally generated are not locally generated?",
2472 info.LOCAL, winner[2])
2473 end
2474 end
2475 --@end-debug@
2476 --[[ 2483 --[[
2477 A: winner was generated locally 2484 A: winner was generated locally
2478 >winning_index == 1 2485 >winning_index == 1
2479 >g_loot and history already has the replacement value 2486 >g_loot and history already has the replacement value
2480 B: winner was generated remotely 2487 B: winner was generated remotely
2481 >need to scan and replace 2488 >need to scan and replace
2482 Detecting A is strictly an optimization. We should be able to do 2489 Detecting A is strictly an optimization. We should be able to do
2483 this code safely in all cases. 2490 this code safely in all cases. Important to note: a local winner
2491 will always be at index 1, but a winner at index 1 does not necessarily
2492 mean it was locally generated (e.g., if the local itemfilter drops
2493 it but a remote player does an improv). Just do the general case
2494 until/unless this becomes a problem.
2484 ]] 2495 ]]
2485 if 2496 --XXX this branch still needs to be tested with live data
2486 --@debug@ 2497 local cache = g_uniques:SEARCH(exist)
2487 true or 2498 local looti,hi,ui = cache.loot, cache.history, cache.history_may
2488 --@end-debug@ 2499
2489 winning_index ~= 1 then 2500 -- Active loot
2490 --XXX this branch still needs to be tested with live data 2501 if looti and g_loot[looti].unique == exist then
2491 local cache = g_uniques:SEARCH(exist) 2502 pprint('improv', "found and replaced loot entry", looti)
2492 local looti,hi,ui = cache.loot, cache.history, cache.history_may 2503 g_loot[looti].unique = winner[2]
2493 2504 else
2494 -- Active loot 2505 -- If sharded, filtered, or the improv was done by the local
2495 if looti and g_loot[looti].unique == exist then 2506 -- player, then the "previous" unique would not have made it
2496 pprint('improv', "found and replaced loot entry", looti) 2507 -- into the tables to begin with. So don't flag an error.
2497 g_loot[looti].unique = winner[2] 2508 pprint('improv', "No active loot found", looti,
2509 looti and g_loot[looti].unique, winning_index)
2510 end
2511
2512 -- History
2513 if hi ~= g_uniques.NOTFOUND then
2514 hi = addon.history.byname[hi]
2515 local hist = addon.history[hi]
2516 if ui and hist.unique[ui] == exist then
2517 -- ui is valid
2498 else 2518 else
2499 -- If winning_index == 1, the "previous" unique would not 2519 ui = nil
2500 -- have made it into the tables to begin with. So don't 2520 for i,ui2 in ipairs(hist.unique) do
2501 -- flag an error. Still should be looked at. 2521 if ui2 == exist then
2502 pprint('improv', "Um.", looti, g_loot[looti].unique, winning_index) 2522 ui = i
2503 end 2523 break
2504
2505 -- History
2506 if hi ~= g_uniques.NOTFOUND then
2507 hi = addon.history.byname[hi]
2508 local hist = addon.history[hi]
2509 if ui and hist.unique[ui] == exist then
2510 -- ui is valid
2511 else
2512 ui = nil
2513 for i,ui2 in ipairs(hist.unique) do
2514 if ui2 == exist then
2515 ui = i
2516 break
2517 end
2518 end 2524 end
2519 end 2525 end
2520 if ui then 2526 end
2521 pprint('improv', "found and replacing history entry", hi, 2527 if ui then
2522 ui, hist.name) 2528 pprint('improv', "found and replacing history entry", hi,
2523 assert(exist ~= winner[2]) 2529 ui, hist.name)
2524 hist.when[winner[2]] = hist.when[exist] 2530 assert(exist ~= winner[2])
2525 hist.id[winner[2]] = hist.id[exist] 2531 hist.when[winner[2]] = hist.when[exist]
2526 hist.count[winner[2]] = hist.count[exist] 2532 hist.id[winner[2]] = hist.id[exist]
2527 hist.unique[ui] = winner[2] 2533 hist.count[winner[2]] = hist.count[exist]
2528 hist.when[exist] = nil 2534 hist.unique[ui] = winner[2]
2529 hist.id[exist] = nil 2535 hist.when[exist] = nil
2530 hist.count[exist] = nil 2536 hist.id[exist] = nil
2531 end 2537 hist.count[exist] = nil
2532 end 2538 end
2533 end 2539 end
2540
2534 pprint('improv', "finished with", exist, "into", winner[2]) 2541 pprint('improv', "finished with", exist, "into", winner[2])
2535 flib.del(winner) 2542 flib.del(winner)
2536 flib.del(info) 2543 flib.del(info)
2537 gur.replacements[exist] = nil 2544 gur.replacements[exist] = nil
2538 end 2545 end
2815 pprint(hmmm) -- more? 2822 pprint(hmmm) -- more?
2816 -- try to simply fix up errors as we go 2823 -- try to simply fix up errors as we go
2817 g_uniques[e.unique] = { loot = i, history = g_uniques.NOTFOUND } 2824 g_uniques[e.unique] = { loot = i, history = g_uniques.NOTFOUND }
2818 end 2825 end
2819 else 2826 else
2827 -- The usual cause: when only source is from an older client
2828 -- and the disposition did not trigger addhistory, then not
2829 -- even a stub history entry happens. Code has now been added
2830 -- to try harder to prevent this, but it's still best to not
2831 -- simple ignore it.
2820 trouble = true 2832 trouble = true
2821 pprint('loot', "ERROR precache loop found bad unique tag!", 2833 pprint('loot', "ERROR precache loop found missing/outdated unique tag!",
2822 i, "tag", tostring(e.unique), "from?", tostring(e.bcast_from)) 2834 i, "tag <"..tostring(e.unique).."> from?", tostring(e.bcast_from))
2823 end 2835 end
2824 end 2836 end
2825 UpdateAddOnMemoryUsage() 2837 UpdateAddOnMemoryUsage()
2826 local after = GetAddOnMemoryUsage(nametag) 2838 local after = GetAddOnMemoryUsage(nametag)
2827 self:Print("Pre-scanning history for faster loot handling on %s used %.2f MB of memory across %d entries.", 2839 self:Print("Pre-scanning history for faster loot handling on %s used %.2f MB of memory across %d entries.",
2828 self.history.realm, (after-before)/1024, count) 2840 self.history.realm, (after-before)/1024, count)
2829 if trouble then 2841 if trouble then
2830 self:Print("Note that there were inconsistencies in the data;", 2842 self:Print("Note that there were inconsistencies in the data;",
2831 "you should consider submitting a bug report (including your", 2843 "you should consider submitting a bug report (including your",
2832 "SavedVariables file), and regenerating or preening this", 2844 "SavedVariables file), and regenerating or preening this",
2833 "realm's loot history.") 2845 "realm's loot history. If you keep seeing this message, type",
2846 "'/ouroloot fix ?' and try some of those actions.")
2834 end 2847 end
2835 g_uniques:SETMODE('probe') 2848 g_uniques:SETMODE('probe')
2836 self._cache_history_uniques = nil 2849 self._cache_history_uniques = nil
2837 end 2850 end
2838 2851
3343 local function assemble(t,...) 3356 local function assemble(t,...)
3344 local n = select('#',...) 3357 local n = select('#',...)
3345 if n > 0 then 3358 if n > 0 then
3346 local msg = {t,...} 3359 local msg = {t,...}
3347 -- tconcat requires strings, but T is known to be one already 3360 -- tconcat requires strings, but T is known to be one already
3348 -- can't use #msg since there might be holes 3361 -- can't use #msg since there might be nil holes
3349 for i = 2, n+1 do 3362 for i = 2, n+1 do
3350 msg[i] = tostring(msg[i] or "") 3363 msg[i] = tostring(msg[i] or "")
3351 end 3364 end
3352 return tconcat (msg, '\a') 3365 return tconcat (msg, '\a')
3353 end 3366 end
3360 return self:broadcast(self.commrev..tag,...) 3373 return self:broadcast(self.commrev..tag,...)
3361 end 3374 end
3362 function addon:broadcast(tag,...) 3375 function addon:broadcast(tag,...)
3363 local msg = assemble(tag,...) 3376 local msg = assemble(tag,...)
3364 self.dprint('comm', "<broadcast>:", msg) 3377 self.dprint('comm', "<broadcast>:", msg)
3365 -- the "GUILD" here is just so that we can also pick up on it 3378 self:SendCommMessage(self.ident, msg, "RAID")
3366 self:SendCommMessage(self.ident, msg, self.debug.comm and "GUILD" or "RAID") 3379 -- this is what lets us debug our own message traffic:
3380 if self.debug.comm then
3381 self:SendCommMessage(self.ident, msg, "GUILD")
3382 end
3367 end 3383 end
3368 -- whispercast(<to>, 'tag', <stuff>) 3384 -- whispercast(<to>, 'tag', <stuff>)
3369 function addon:whispercast(to,...) 3385 function addon:whispercast(to,...)
3370 local msg = assemble(...) 3386 local msg = assemble(...)
3371 self.dprint('comm', "<whispercast>@", to, ":", msg) 3387 self.dprint('comm', "<whispercast>@", to, ":", msg)
3382 -- player is not tracking loot, so test for that when appropriate. 3398 -- player is not tracking loot, so test for that when appropriate.
3383 local OCR_funcs = {} 3399 local OCR_funcs = {}
3384 3400
3385 OCR_funcs.ping = function (sender) 3401 OCR_funcs.ping = function (sender)
3386 pprint('comm', "incoming ping from", sender) 3402 pprint('comm', "incoming ping from", sender)
3387 addon:whispercast (sender, 'pong', addon.revision, 3403 local what = addon.enabled and "tracking" or
3388 addon.enabled and "tracking" or (addon.rebroadcast and "broadcasting" or "disabled")) 3404 (addon.rebroadcast and "broadcasting" or "disabled")
3389 end 3405 addon:whispercast (sender, 'pong', addon.version, what, addon.revision)
3390 OCR_funcs.pong = function (sender, _, rev, status) 3406 end
3391 local s = ("|cff00ff00%s|r %s is |cff00ffff%s|r"):format(sender,rev,status) 3407 OCR_funcs.pong = function (sender, _, ver, status, opt_rev)
3408 local s = ("|cff00ff00%s|r %s(r%s) is |cff00ffff%s|r"):
3409 format (sender, ver, opt_rev or "?", status)
3392 addon:Print("Echo: ", s) 3410 addon:Print("Echo: ", s)
3393 adduser (sender, s, status=="tracking" or status=="broadcasting" or nil) 3411 adduser (sender, s, status=="tracking" or status=="broadcasting" or nil)
3394 end 3412 end
3395 OCR_funcs.revcheck = function (sender, _, revlarge) 3413 OCR_funcs.revcheck = function (sender, _, revlarge)
3396 addon.dprint('comm', "revcheck, sender", sender) 3414 addon.dprint('comm', "revcheck, sender", sender)
3397 addon:_check_revision (revlarge) 3415 addon:_check_version (revlarge)
3398 end 3416 end
3399 3417
3400 OCR_funcs['17improv'] = function (sender, _, senderid, existing, replace) 3418 OCR_funcs['17improv'] = function (sender, _, senderid, existing, replace)
3401 addon.dprint('comm', "DOTimprov/17, sender", sender, "id", senderid, 3419 addon.dprint('comm', "DOTimprov/17, sender", sender, "id", senderid,
3402 "existing", existing, "replace", replace) 3420 "existing", existing, "replace", replace)
3503 local n = select('#',...) 3521 local n = select('#',...)
3504 for i = 1, n do 3522 for i = 1, n do
3505 local d = select(i,...) 3523 local d = select(i,...)
3506 OCR_data[i] = (d ~= "") and d or nil 3524 OCR_data[i] = (d ~= "") and d or nil
3507 end 3525 end
3508 addon.dprint('comm', ":... processing", tag, "from", sender, "with arg count", n) 3526 addon.dprint('comm', ":...processing", tag, "from", sender, "with arg count", n)
3509 return f(sender,tag,unpack(OCR_data,1,n)) 3527 return f(sender,tag,unpack(OCR_data,1,n))
3510 end 3528 end
3511 addon.dprint('comm', "unknown comm message", tag, "from", sender) 3529 addon.dprint('comm', "unknown comm message", tag, "from", sender)
3512 end 3530 end
3513 -- Recent message cache (this can be accessed via advanced options panel) 3531 -- Recent message cache (this can be accessed via advanced options panel)