comparison core.lua @ 38:bb41be8f13b2

Remove some older commented code. Cosmetic comment changes. Clear stray empty 'count' strings out of rebroadcast loot histories, if restoring previous version's data (and not in combat).
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 23 Dec 2011 01:08:02 +0000
parents cd745a18d7c7
children 8f7ec6ccf5e3
comparison
equal deleted inserted replaced
37:cd745a18d7c7 38:bb41be8f13b2
143 143
144 -- The rest is also used in the GUI: 144 -- The rest is also used in the GUI:
145 145
146 popped = nil -- non-nil when reminder has been shown, actual value unimportant 146 popped = nil -- non-nil when reminder has been shown, actual value unimportant
147 147
148 -- This is an amalgamation of all four LOOT_ITEM_* patterns.
149 -- Captures: 1 person/You, 2 itemstring, 3 rest of string after final |r until '.'
150 -- Can change 'loot' to 'item' to trigger on, e.g., extracting stuff from mail.
151 --loot_pattern = "(%S+) receives? loot:.*|cff%x+|H(.-)|h.*|r(.*)%.$"
152
153 bossmod_registered = nil 148 bossmod_registered = nil
154 bossmods = {} 149 bossmods = {}
155 150
156 requesting = nil -- for prompting for additional rebroadcasters 151 requesting = nil -- for prompting for additional rebroadcasters
157 152
153 -- don't use NUM_ITEM_QUALITIES as the upper bound unless we expect heirlooms to show up
158 thresholds = {} 154 thresholds = {}
159 for i = 0,6 do 155 for i = 0,6 do
160 thresholds[i] = _G.ITEM_QUALITY_COLORS[i].hex .. _G["ITEM_QUALITY"..i.."_DESC"] .. "|r" 156 thresholds[i] = _G.ITEM_QUALITY_COLORS[i].hex .. _G["ITEM_QUALITY"..i.."_DESC"] .. "|r"
161 end 157 end
162 158
182 local _register_bossmod 178 local _register_bossmod
183 local makedate, create_new_cache, _init 179 local makedate, create_new_cache, _init
184 180
185 -- Try to extract numbers from the .toc "Version" and munge them into an 181 -- Try to extract numbers from the .toc "Version" and munge them into an
186 -- integral form for comparison. The result doesn't need to be meaningful as 182 -- integral form for comparison. The result doesn't need to be meaningful as
187 -- long as we can reliably feed two of them to "<" and get useful results. 183 -- long as we can reliably feed two of them to "<" and get useful answers.
188 -- 184 --
189 -- This makes/reinforces an assumption that revision_large of release packages 185 -- This makes/reinforces an assumption that revision_large of release packages
190 -- (e.g., 2016001) will always be higher than those of development packages 186 -- (e.g., 2016001) will always be higher than those of development packages
191 -- (e.g., 87), due to the tagging system versus subversion file revs. This 187 -- (e.g., 87), due to the tagging system versus subversion file revs. This
192 -- is good, as local dev code will never trigger a false positive update 188 -- is good, as local dev code will never trigger a false positive update
193 -- warning for other users. 189 -- warning for other users. The downside is that additional decimal places
190 -- in the Version field for bugfixes (e.g., "2.16.4.1") imposes a high-water
191 -- mark, as subsequent shorter strings ("2.16.5", "2.17") will never be larger.
194 do 192 do
195 local r = 0 193 local r = 0
196 for d in addon.revision:gmatch("%d+") do 194 for d in addon.revision:gmatch("%d+") do
197 r = 1000*r + d 195 r = 1000*r + d
198 end 196 end
201 199
202 -- Hypertext support, inspired by DBM broadcast pizza timers 200 -- Hypertext support, inspired by DBM broadcast pizza timers
203 do 201 do
204 local hypertext_format_str = "|HOuroRaid:%s|h%s[%s]|r|h" 202 local hypertext_format_str = "|HOuroRaid:%s|h%s[%s]|r|h"
205 203
206 -- text will automatically be surrounded by brackets 204 -- TEXT will automatically be surrounded by brackets
205 -- COLOR can be item quality code or a hex string
207 function addon.format_hypertext (code, text, color) 206 function addon.format_hypertext (code, text, color)
208 return hypertext_format_str:format (code, 207 return hypertext_format_str:format (code,
209 type(color)=='number' and ITEM_QUALITY_COLORS[color].hex or color, 208 type(color)=='number' and ITEM_QUALITY_COLORS[color].hex or color,
210 text) 209 text)
211 end 210 end
377 for opt,default in pairs(option_defaults) do 376 for opt,default in pairs(option_defaults) do
378 if opts[opt] == nil then 377 if opts[opt] == nil then
379 opts[opt] = default 378 opts[opt] = default
380 end 379 end
381 end 380 end
381
382 -- transition&remove old options 382 -- transition&remove old options
383 opts['forum_use_itemid'] = nil 383 opts['forum_use_itemid'] = nil
384 if opts['forum_format'] then 384 if opts['forum_format'] then
385 opts.forum['Custom...'] = opts['forum_format'] 385 opts.forum['Custom...'] = opts['forum_format']
386 opts['forum_format'] = nil 386 opts['forum_format'] = nil
403 end 403 end
404 if OuroLootSV.autoshard then 404 if OuroLootSV.autoshard then
405 opts.autoshard = OuroLootSV.autoshard; OuroLootSV.autoshard = nil 405 opts.autoshard = OuroLootSV.autoshard; OuroLootSV.autoshard = nil
406 end 406 end
407 end 407 end
408
408 -- get item filter table if needed 409 -- get item filter table if needed
409 if opts.itemfilter == nil then 410 if opts.itemfilter == nil then
410 opts.itemfilter = addon.default_itemfilter 411 opts.itemfilter = addon.default_itemfilter
411 end 412 end
412 addon.default_itemfilter = nil 413 addon.default_itemfilter = nil
419 420
420 self.history_all = self.history_all or OuroLootSV_hist or {} 421 self.history_all = self.history_all or OuroLootSV_hist or {}
421 local r = assert(GetRealmName()) 422 local r = assert(GetRealmName())
422 self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r) 423 self.history_all[r] = self:_prep_new_history_category (self.history_all[r], r)
423 self.history = self.history_all[r] 424 self.history = self.history_all[r]
425 if (not InCombatLockdown()) and OuroLootSV_hist and
426 (OuroLootSV_hist.HISTFORMAT == nil) -- restored data but it's older
427 then
428 -- Big honkin' loop
429 for rname,realm in pairs(self.history_all) do
430 for pk,player in ipairs(realm) do
431 for lk,loot in ipairs(player) do
432 if loot.count == "" then
433 loot.count = nil
434 end
435 end
436 end
437 end
438 end
439 self.history_all.HISTFORMAT = nil -- don't keep this in live data
424 --OuroLootSV_hist = nil 440 --OuroLootSV_hist = nil
425 441
426 _init(self) 442 _init(self)
427 self.dprint('flow', "version strings:", revision_large, self.status_text) 443 self.dprint('flow', "version strings:", revision_large, self.status_text)
428 self.OnInitialize = nil 444 self.OnInitialize = nil
456 local btn = CreateFrame("Button", "OuroLootBindingOpen", nil, "SecureActionButtonTemplate") 472 local btn = CreateFrame("Button", "OuroLootBindingOpen", nil, "SecureActionButtonTemplate")
457 btn:SetAttribute("type", "macro") 473 btn:SetAttribute("type", "macro")
458 btn:SetAttribute("macrotext", "/ouroloot toggle") 474 btn:SetAttribute("macrotext", "/ouroloot toggle")
459 if SetBindingClick(opts.keybinding_text, "OuroLootBindingOpen") then 475 if SetBindingClick(opts.keybinding_text, "OuroLootBindingOpen") then
460 -- a simple SaveBindings(GetCurrentBindingSet()) occasionally fails when GCBS 476 -- a simple SaveBindings(GetCurrentBindingSet()) occasionally fails when GCBS
461 -- decides to return neither 1 nor 2 during load 477 -- decides to return neither 1 nor 2 during load, for reasons nobody has ever learned
462 local c = GetCurrentBindingSet() 478 local c = GetCurrentBindingSet()
463 if c == ACCOUNT_BINDINGS or c == CHARACTER_BINDINGS then 479 if c == ACCOUNT_BINDINGS or c == CHARACTER_BINDINGS then
464 SaveBindings(c) 480 SaveBindings(c)
465 end 481 end
466 else 482 else
524 OuroLootSV = g_loot 540 OuroLootSV = g_loot
525 else 541 else
526 OuroLootSV = nil 542 OuroLootSV = nil
527 end 543 end
528 544
545 worth_saving = false
529 for r,t in pairs(self.history_all) do if type(t) == 'table' then 546 for r,t in pairs(self.history_all) do if type(t) == 'table' then
530 if #t == 0 then 547 if #t == 0 then
531 self.history_all[r] = nil 548 self.history_all[r] = nil
532 else 549 else
550 worth_saving = true
533 t.realm = nil 551 t.realm = nil
534 t.st = nil 552 t.st = nil
535 t.byname = nil 553 t.byname = nil
536 end 554 end
537 end end 555 end end
538 OuroLootSV_hist = self.history_all 556 if worth_saving then
557 OuroLootSV_hist = self.history_all
558 OuroLootSV_hist.HISTFORMAT = 2
559 else
560 OuroLootSV_hist = nil
561 end
539 OuroLootSV_log = #OuroLootSV_log > 0 and OuroLootSV_log or nil 562 OuroLootSV_log = #OuroLootSV_log > 0 and OuroLootSV_log or nil
540 end 563 end
541 564
542 do 565 do
543 local IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex, 566 local IsInInstance, UnitName, UnitIsConnected, UnitClass, UnitRace, UnitSex,
672 -- Recent loot cache 695 -- Recent loot cache
673 local candidates = {} 696 local candidates = {}
674 local function prefer_local_loots (cache) 697 local function prefer_local_loots (cache)
675 -- The function name is a bit of a misnomer, as local entries overwrite 698 -- The function name is a bit of a misnomer, as local entries overwrite
676 -- remote entries as the candidate table is populated. This routine is 699 -- remote entries as the candidate table is populated. This routine is
677 -- to extract the results once the cache timers have expired. 700 -- here to extract the results once the cache timers have expired.
701 --
678 -- Keep this sync'd with the local_override branch below. 702 -- Keep this sync'd with the local_override branch below.
679 for i,sig in ipairs(candidates) do 703 for i,sig in ipairs(candidates) do
680 addon.dprint('loot', "processing candidate entry", i, sig) 704 addon.dprint('loot', "processing candidate entry", i, sig)
681 local loot = candidates[sig] 705 local loot = candidates[sig]
682 if loot then 706 if loot then
734 itemname = iname, 758 itemname = iname,
735 id = itemid, 759 id = itemid,
736 itemlink = ilink, 760 itemlink = ilink,
737 itexture = itexture, 761 itexture = itexture,
738 disposition = (recipient == self.sharder) and 'shard' or nil, 762 disposition = (recipient == self.sharder) and 'shard' or nil,
739 count = count, 763 count = (count and count ~= "") and count or nil,
740 bcast_from = from, 764 bcast_from = from,
741 extratext = extratext, 765 extratext = extratext,
742 is_heroic = self:is_heroic_item(ilink), 766 is_heroic = self:is_heroic_item(ilink),
743 } 767 }
744 if local_override then 768 if local_override then
783 807
784 if event == "CHAT_MSG_LOOT" then 808 if event == "CHAT_MSG_LOOT" then
785 local msg = ... 809 local msg = ...
786 local person, itemstring, count 810 local person, itemstring, count
787 --ChatFrame2:AddMessage("original string: >"..(msg:gsub("\124","\124\124")).."<") 811 --ChatFrame2:AddMessage("original string: >"..(msg:gsub("\124","\124\124")).."<")
788 --local person, itemstring, remainder = msg:match(self.loot_pattern)
789 812
790 -- test in most likely order: other people get more loot than "you" do 813 -- test in most likely order: other people get more loot than "you" do
791 person, itemstring, count = msg:match(g_LOOT_ITEM_MULTIPLE_sss) 814 person, itemstring, count = msg:match(g_LOOT_ITEM_MULTIPLE_sss)
792 if not person then 815 if not person then
793 person, itemstring = msg:match(g_LOOT_ITEM_ss) 816 person, itemstring = msg:match(g_LOOT_ITEM_ss)
797 if not itemstring then 820 if not itemstring then
798 itemstring = msg:match(g_LOOT_ITEM_SELF_s) 821 itemstring = msg:match(g_LOOT_ITEM_SELF_s)
799 end 822 end
800 end 823 end
801 824
802 --self.dprint('loot', "CHAT_MSG_LOOT, person is", person, ", itemstring is", itemstring, ", rest is", remainder)
803 self.dprint('loot', "CHAT_MSG_LOOT, person is", person, ", itemstring is", itemstring, ", count is", count) 825 self.dprint('loot', "CHAT_MSG_LOOT, person is", person, ", itemstring is", itemstring, ", count is", count)
804 if not itemstring then return end -- "So-and-So selected Greed", etc, not actual looting 826 if not itemstring then return end -- "So-and-So selected Greed", etc, not actual looting
805 --local count = remainder and remainder:match(".*(x%d+)$")
806 827
807 -- Name might be colorized, remove the highlighting 828 -- Name might be colorized, remove the highlighting
808 if person then 829 if person then
809 person = person:match("|c%x%x%x%x%x%x%x%x(%S+)") or person 830 person = person:match("|c%x%x%x%x%x%x%x%x(%S+)") or person
810 else 831 else
811 -- UNIT_YOU / You 832 person = my_name -- UNIT_YOU / You
812 person = my_name
813 end 833 end
814 834
815 --local id = tonumber((select(2, strsplit(":", itemstring)))) 835 --local id = tonumber((select(2, strsplit(":", itemstring))))
816 local id = tonumber(itemstring:match('|Hitem:(%d+):')) 836 local id = tonumber(itemstring:match('|Hitem:(%d+):'))
817 837
1896 end 1916 end
1897 1917
1898 OCR_funcs.bcast_req = function (sender) 1918 OCR_funcs.bcast_req = function (sender)
1899 if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast)) 1919 if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast))
1900 then 1920 then
1901 addon:Print("%s has requested additional broadcasters! Choose %s to enable rebroadcasting, or %s to remain off and also ignore rebroadcast requests for as long as you're logged in. Or do nothing for now to see if other requests arrive.", 1921 addon:Print("%s has requested additional broadcasters! Choose %s to enable rebroadcasting, or %s to remain off and also ignore rebroadcast requests for as long as you're logged in.",
1902 sender, 1922 sender,
1903 addon.format_hypertext('bcaston',"the red pill",'|cffff4040'), 1923 addon.format_hypertext('bcaston',"the red pill",'|cffff4040'),
1904 addon.format_hypertext('waferthin',"the blue pill",'|cff0070dd')) 1924 addon.format_hypertext('waferthin',"the blue pill",'|cff0070dd'))
1905 end 1925 end
1906 addon.popped = true 1926 addon.popped = true