Mercurial > wow > ouroloot
comparison core.lua @ 81:0f6355bcfe68
Initial version of reassign_loot that handles remote broadcasting, tested in sandbox. Catch tab generation errors at a higher level and take apart the window (including STs) rather than propagating Lua errors upwards.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Fri, 15 Jun 2012 20:04:05 +0000 |
parents | f01d8d1b8f82 |
children | ae17128ef3f2 |
comparison
equal
deleted
inserted
replaced
80:f01d8d1b8f82 | 81:0f6355bcfe68 |
---|---|
141 .." welcome message will not intrude again." | 141 .." welcome message will not intrude again." |
142 local newer_warning = "A newer version has been released. You can %s to display" | 142 local newer_warning = "A newer version has been released. You can %s to display" |
143 .." a download URL for copy-and-pasting. You can %s to ping other raiders" | 143 .." a download URL for copy-and-pasting. You can %s to ping other raiders" |
144 .." for their installed versions (same as '/ouroloot ping' or clicking the" | 144 .." for their installed versions (same as '/ouroloot ping' or clicking the" |
145 .." 'Ping!' button on the options panel)." | 145 .." 'Ping!' button on the options panel)." |
146 local unique_collision = "|cffff1010%s:|r|nItem '%s' was carrying unique tag <%s>, but that was already in use; tried to generate a new tag and failed!|n|nRemote sender was '%s', previous cache entry was <%s/%s>.|n|nThis may require a live human to figure out; the loot in question has not been stored." | 146 local horrible_error_text = [[|cffff1010]] .. ERROR_CAPS |
147 ..[[:|n|cffffff00Something unrecoverable has happened. The error message]] | |
148 ..[[ which was provided follows in white:|r|n|n%s|n|n|cffffff00Ouro Loot]] | |
149 ..[[ will not display a window until this situation is corrected. ]] | |
150 ..[[ You can try typing|n|cff00ff40/ouroloot fix ?|n]] | |
151 ..[[|cffffff00to see what can be done by software alone. You may still]] | |
152 ..[[ need to do a "/reload" afterwards, or even restart the game client.]] | |
153 local unique_collision = "Item '%s' was carrying unique tag <%s>, but that was already in use; tried to generate a new tag and failed!|n|nRemote sender was '%s', previous cache entry was <%s/%s>.|n|nThis may require a live human to figure out; the loot in question has not been stored." | |
147 local remote_chatty = "|cff00ff00%s|r changed %d/%s from %s%s|r to %s%s|r" | 154 local remote_chatty = "|cff00ff00%s|r changed %d/%s from %s%s|r to %s%s|r" |
148 local qualnames = { | 155 local qualnames = { |
149 ['gray'] = 0, ['grey'] = 0, ['poor'] = 0, ['trash'] = 0, | 156 ['gray'] = 0, ['grey'] = 0, ['poor'] = 0, ['trash'] = 0, |
150 ['white'] = 1, ['common'] = 1, | 157 ['white'] = 1, ['common'] = 1, |
151 ['green'] = 2, ['uncommon'] = 2, | 158 ['green'] = 2, ['uncommon'] = 2, |
337 | 344 |
338 local pprint, tabledump = addon.pprint, flib.tabledump | 345 local pprint, tabledump = addon.pprint, flib.tabledump |
339 local CopyTable, GetNumRaidMembers = _G.CopyTable, _G.GetNumRaidMembers | 346 local CopyTable, GetNumRaidMembers = _G.CopyTable, _G.GetNumRaidMembers |
340 -- En masse forward decls of symbols defined inside local blocks | 347 -- En masse forward decls of symbols defined inside local blocks |
341 local _register_bossmod, makedate, create_new_cache, _init, _log | 348 local _register_bossmod, makedate, create_new_cache, _init, _log |
342 local _history_by_loot_id, _notify_about_remote, _setup_unique_replace | 349 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision |
343 local _unavoidable_collision | 350 local _notify_about_change, _notify_about_remote |
344 | 351 |
345 -- Try to extract numbers from the .toc "Version" and munge them into an | 352 -- Try to extract numbers from the .toc "Version" and munge them into an |
346 -- integral form for comparison. The result doesn't need to be meaningful as | 353 -- integral form for comparison. The result doesn't need to be meaningful as |
347 -- long as we can reliably feed two of them to "<" and get useful answers. | 354 -- long as we can reliably feed two of them to "<" and get useful answers. |
348 -- | 355 -- |
1380 -- collision, but we've generated a placeholder for now | 1387 -- collision, but we've generated a placeholder for now |
1381 -- and broadcast the fact | 1388 -- and broadcast the fact |
1382 self.dprint('loot', "substituting", unique, "with", replacement) | 1389 self.dprint('loot', "substituting", unique, "with", replacement) |
1383 else | 1390 else |
1384 i = g_uniques[unique] | 1391 i = g_uniques[unique] |
1385 local err = unique_collision:format (ERROR_CAPS, iname, unique, | 1392 local err = unique_collision:format (iname, unique, |
1386 tostring(from), tostring(i.loot), tostring(i.history)) | 1393 tostring(from), tostring(i.loot), tostring(i.history)) |
1387 _unavoidable_collision (err) | 1394 _unavoidable_collision (err) |
1388 -- Make sure this is logged one way or another | 1395 -- Make sure this is logged one way or another |
1389 ;(self.debug.loot and self.dprint or pprint)('loot', "COLLISION", prefix, err); | 1396 ;(self.debug.loot and self.dprint or pprint)('loot', "COLLISION", prefix, err); |
1390 ret1, ret2 = nil, err | 1397 ret1, ret2 = nil, err |
1623 elseif cmd == "help" then | 1630 elseif cmd == "help" then |
1624 self:BuildMainDisplay('help') | 1631 self:BuildMainDisplay('help') |
1625 elseif cmd == "ping" then | 1632 elseif cmd == "ping" then |
1626 self:DoPing() | 1633 self:DoPing() |
1627 | 1634 |
1628 elseif cmd == "fixcache" then | 1635 elseif cmd == "fix" then |
1629 self:do_item_cache_fixup() | 1636 if arg == "?" then |
1637 self:Print[['/loot fix cache' updates loot that wasn't in the cache]] | |
1638 self:Print[['/loot fix history' repairs inconsistent data on the History tab]] | |
1639 self:Print[['/loot fix' changes no stored data, only allows the window to be displayed again (this is built into all fixes above)]] | |
1640 return | |
1641 elseif arg == "cache" then | |
1642 self:do_item_cache_fixup() | |
1643 elseif arg == "history" then | |
1644 self:repair_history_integrity() | |
1645 end | |
1646 self.NOLOAD = nil | |
1647 self:Print("Window unlocked, best of luck.") | |
1630 | 1648 |
1631 else | 1649 else |
1632 if self:OpenMainDisplayToTab(cmd) then | 1650 if self:OpenMainDisplayToTab(cmd) then |
1633 return | 1651 return |
1634 end | 1652 end |
1796 else | 1814 else |
1797 self:Print("'%s' was not a valid chat frame number/name, no change has been made.", arg) | 1815 self:Print("'%s' was not a valid chat frame number/name, no change has been made.", arg) |
1798 end | 1816 end |
1799 end | 1817 end |
1800 | 1818 |
1801 function _notify_about_remote (sender, index, from_whom, olddisp) | 1819 local hexes = _G.setmetatable({}, {__index = function (t, k) |
1820 local r = _G.math.floor(255*k.r+0.5) | |
1821 local g = _G.math.floor(255*k.g+0.5) | |
1822 local b = _G.math.floor(255*k.b+0.5) | |
1823 local hex = ("|cff%.2x%.2x%.2x"):format(r,g,b) | |
1824 t[k] = hex | |
1825 return hex | |
1826 end}) | |
1827 function _notify_about_change (chatframe, source, index, olddisp, from_whom, from_class) | |
1802 local e = g_loot[index] | 1828 local e = g_loot[index] |
1803 if not e then | 1829 if not e then |
1804 -- how did this happen? | 1830 -- how did this happen? |
1805 return | 1831 return |
1806 end | 1832 end |
1807 local from_color, from_text, to_color, to_text | 1833 local from_color, from_text, to_color, to_text |
1808 if from_whom then | 1834 if from_whom then |
1809 -- FIXME need to return previous name/class from reassign_loot | 1835 from_color = from_class |
1810 | 1836 and addon.class_colors[from_class] |
1837 or _G.NORMAL_FONT_COLOR | |
1838 from_color = hexes[from_color] | |
1839 from_text = from_whom | |
1840 to_color = e.person_class | |
1841 and addon.class_colors[e.person_class] | |
1842 or _G.NORMAL_FONT_COLOR | |
1843 to_color = hexes[to_color] | |
1844 to_text = e.person | |
1811 else | 1845 else |
1812 if olddisp then | 1846 if olddisp then |
1813 from_text = addon.disposition_colors[olddisp].text | 1847 from_text = addon.disposition_colors[olddisp].text |
1814 else | 1848 else |
1815 olddisp = "normal" | 1849 olddisp = "normal" |
1822 to_text = "normal" | 1856 to_text = "normal" |
1823 end | 1857 end |
1824 to_color = addon.disposition_colors[e.disposition or "normal"].hex | 1858 to_color = addon.disposition_colors[e.disposition or "normal"].hex |
1825 end | 1859 end |
1826 | 1860 |
1827 addon.dprint ('loot', "notifying:", sender, index, | 1861 addon.dprint ('loot', "notification:", source, index, |
1828 e.itemlink, from_color, from_text, to_color, to_text) | 1862 e.itemlink, from_color, from_text, to_color, to_text) |
1829 addon:CFPrint (remote_change_chatframe, remote_chatty, sender, index, | 1863 addon:CFPrint (chatframe, remote_chatty, source, index, |
1830 e.itemlink, from_color, from_text, to_color, to_text) | 1864 e.itemlink, from_color, from_text, to_color, to_text) |
1865 end | |
1866 | |
1867 function _notify_about_remote (sender, index, olddisp, from_whom, from_class) | |
1868 _notify_about_change (remote_change_chatframe, sender, index, olddisp, from_whom, from_class) | |
1831 end | 1869 end |
1832 end | 1870 end |
1833 | 1871 |
1834 -- Adds indices to traverse the tables in a nice sorted order. | 1872 -- Adds indices to traverse the tables in a nice sorted order. |
1835 do | 1873 do |
2503 end | 2541 end |
2504 end | 2542 end |
2505 | 2543 |
2506 do | 2544 do |
2507 local clicky | 2545 local clicky |
2508 function _unavoidable_collision (err) | 2546 function addon:horrible_horrible_error (err_msg) |
2547 if self.display then | |
2548 local d = self.display | |
2549 if d then | |
2550 local eoist = d:GetUserData("eoiST") | |
2551 if eoist then eoist:Hide() end | |
2552 local histst = d:GetUserData("histST") | |
2553 if histst then histst:Hide() end | |
2554 d:Hide() | |
2555 end | |
2556 end | |
2557 self.NOLOAD = err_msg | |
2509 -- This should happen so rarely that it's not worth moving into gui.lua | 2558 -- This should happen so rarely that it's not worth moving into gui.lua |
2510 if not StaticPopupDialogs["OUROL_COLLISION"] then | 2559 if not StaticPopupDialogs["OUROL_ARGH"] then |
2511 StaticPopupDialogs["OUROL_COLLISION"] = flib.StaticPopup{ | 2560 StaticPopupDialogs["OUROL_ARGH"] = flib.StaticPopup{ |
2512 button1 = OKAY, | 2561 button1 = OKAY, |
2513 } | 2562 } |
2514 clicky = addon.format_hypertext( | 2563 clicky = addon.format_hypertext( |
2515 [[ SYSTEM FAILURE -- RELEASE RINZLER ]], "|cffff0000", | 2564 [[ SYSTEM FAILURE -- RELEASE RINZLER ]], "|cffff0000", |
2516 function() StaticPopup_Show "OUROL_COLLISION" end) | 2565 function() StaticPopup_Show "OUROL_ARGH" end) |
2517 end | 2566 end |
2518 StaticPopupDialogs["OUROL_COLLISION"].text = err | 2567 StaticPopupDialogs["OUROL_ARGH"].text = horrible_error_text:format(err_msg) |
2519 _G.PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "Master") | 2568 _G.PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "Master") |
2520 addon:Print (" ") | 2569 addon:Print (" ") |
2521 addon:Print (" ", clicky) | 2570 addon:Print (" ", clicky) |
2522 addon:Print (" ") | 2571 addon:Print (" ") |
2523 end | 2572 end |
2573 | |
2574 function _unavoidable_collision (err) | |
2575 addon:horrible_horrible_error (err) | |
2576 -- we don't actually need to kill the GUI in this case | |
2577 addon.NOLOAD = nil | |
2578 end | |
2524 end | 2579 end |
2525 --function DOTEST() | 2580 --function DOTEST() |
2526 -- local err = unique_collision:format (ERROR_CAPS, | 2581 -- local err = unique_collision:format ( |
2527 -- "Codpiece of the Grimacing Lunatic", | 2582 -- "Codpiece of the Grimacing Lunatic", |
2528 -- 'n3183021', 'Farmbuyer', '14', '78') | 2583 -- 'n3183021', 'Farmbuyer', '14', '78') |
2529 -- _unavoidable_collision (err) | 2584 -- _unavoidable_collision (err) |
2530 -- pprint('ohfuck', "COLLISION", err) | 2585 -- pprint('ohfuck', "COLLISION", err) |
2531 --end | 2586 --end |
2538 _G.OuroLootSV_saved = nil | 2593 _G.OuroLootSV_saved = nil |
2539 if not silent_p then self:Print("There are no saved loot texts.") end | 2594 if not silent_p then self:Print("There are no saved loot texts.") end |
2540 end | 2595 end |
2541 | 2596 |
2542 function addon:save_list() | 2597 function addon:save_list() |
2543 local s = self:check_saved_table(); if not s then return end; | 2598 local s = self:check_saved_table(); if not s then return end |
2544 for i,t in ipairs(s) do | 2599 for i,t in ipairs(s) do |
2545 self:Print("#%d %s %d entries %s", i, t.date, t.count, t.name) | 2600 self:Print("#%d %s %d entries %s", i, t.date, t.count, t.name) |
2546 end | 2601 end |
2547 end | 2602 end |
2548 | 2603 |
2562 SV[n] = save | 2617 SV[n] = save |
2563 return self:save_list() | 2618 return self:save_list() |
2564 end | 2619 end |
2565 | 2620 |
2566 function addon:save_restore(num) | 2621 function addon:save_restore(num) |
2567 local s = self:check_saved_table(); if not s then return end; | 2622 local s = self:check_saved_table(); if not s then return end |
2568 if (not num) or (num > #s) then | 2623 if (not num) or (num > #s) then |
2569 return self:Print("Saved text number must be 1 - "..#s) | 2624 return self:Print("Saved text number must be 1 - "..#s) |
2570 end | 2625 end |
2571 local save = s[num] | 2626 local save = s[num] |
2572 self:Print("Overwriting current loot data with saved text #%d '%s'", num, save.name) | 2627 self:Print("Overwriting current loot data with saved text #%d '%s'", num, save.name) |
2577 g_loot[text] = save[text] | 2632 g_loot[text] = save[text] |
2578 end | 2633 end |
2579 end | 2634 end |
2580 | 2635 |
2581 function addon:save_delete(num) | 2636 function addon:save_delete(num) |
2582 local s = self:check_saved_table(); if not s then return end; | 2637 local s = self:check_saved_table(); if not s then return end |
2583 if (not num) or (num > #s) then | 2638 if (not num) or (num > #s) then |
2584 return self:Print("Saved text number must be 1 - "..#s) | 2639 return self:Print("Saved text number must be 1 - "..#s) |
2585 end | 2640 end |
2586 self:Print("Deleting saved text #"..num) | 2641 self:Print("Deleting saved text #"..num) |
2587 tremove(s,num) | 2642 tremove(s,num) |
2639 new_uniques[i] = uniques_bywhen[tstamp] | 2694 new_uniques[i] = uniques_bywhen[tstamp] |
2640 end | 2695 end |
2641 p.unique = new_uniques | 2696 p.unique = new_uniques |
2642 end | 2697 end |
2643 | 2698 |
2699 function addon:repair_history_integrity() | |
2700 local rcount, pcount, hcount, errors = 0, 0, 0, 0 | |
2701 local empties_to_delete = {} | |
2702 | |
2703 for rname,realm in pairs(self.history_all) do | |
2704 for pk,player in ipairs(realm) do | |
2705 local id, when, unique, count = {}, {}, {}, {} | |
2706 for i,h in ipairs(player.unique) do | |
2707 h = tostring(h) | |
2708 if player.when[h] and player.id[h] then | |
2709 unique[#unique+1] = h | |
2710 id[h] = player.id[h] | |
2711 when[h] = player.when[h] | |
2712 count[h] = player.count[h] | |
2713 else | |
2714 self:Print("Realm %s, player %s, entry %d: tag <%s>, id <%s>, time <%s>, count <%s>", | |
2715 rname, player.name, i, h, tostring(player.id[h]), | |
2716 tostring(player.when[h]), tostring(player.count[h])) | |
2717 errors = errors + 1 | |
2718 end | |
2719 hcount = hcount + 1 | |
2720 end | |
2721 player.id, player.when, player.unique, player.count = | |
2722 id, when, unique, count | |
2723 player.person_class = g_loot.raiders[player.name] | |
2724 and g_loot.raiders[player.name].class | |
2725 if #player.unique > 1 then | |
2726 sort_player(player) | |
2727 elseif #player.unique == 0 then | |
2728 tinsert (empties_to_delete, 1, pk) | |
2729 end | |
2730 pcount = pcount + 1 | |
2731 end | |
2732 if #empties_to_delete > 0 then | |
2733 for _,pk in ipairs(empties_to_delete) do | |
2734 local player = tremove (realm, pk) | |
2735 self:Print("Realm %s, player %s, is empty", rname, player.name) | |
2736 end | |
2737 wipe(empties_to_delete) | |
2738 end | |
2739 if #realm == 0 then | |
2740 self.history_all[rname] = nil | |
2741 self:Print("Realm %s is empty", rname) | |
2742 end | |
2743 rcount = rcount + 1 | |
2744 end | |
2745 self:_build_history_names() | |
2746 if errors > 0 then | |
2747 self:Print("The listed entries have been erased from history.") | |
2748 end | |
2749 end | |
2750 | |
2644 -- Possibly called during login. Cleared when no longer needed. | 2751 -- Possibly called during login. Cleared when no longer needed. |
2645 -- Rewrites a PLAYER table from format 3 to format 4. | 2752 -- Rewrites a PLAYER table from format 3 to format 4. |
2646 function addon:_uplift_history_format (player) | 2753 function addon:_uplift_history_format (player) |
2647 local unique, when, id, count = {}, {}, {}, {} | 2754 local unique, when, id, count = {}, {}, {}, {} |
2648 local name = player.name | 2755 local name = player.name |
2882 errtxt = "ZOMG! %s was in history but now is gone. Possibly your history tables have been corrupted and should be recreated. This is likely a bug. Tell Farmbuyer what steps you took to cause this." | 2989 errtxt = "ZOMG! %s was in history but now is gone. Possibly your history tables have been corrupted and should be recreated. This is likely a bug. Tell Farmbuyer what steps you took to cause this." |
2883 end | 2990 end |
2884 return nil, errtxt | 2991 return nil, errtxt |
2885 end | 2992 end |
2886 | 2993 |
2887 function addon:reassign_loot (index, to_name) | 2994 -- Handles reassigning loot between players. Arguments depend on who's |
2888 assert(type(to_name)=='string' and to_name:len()>0) | 2995 -- calling it: |
2889 local e = g_loot[index] | 2996 -- "local", row_index, new_recipient |
2997 -- "remote", sender, unique_id, item_id, old_recipient, new_recipient | |
2998 -- In the local case, must also broadcast a trigger. In the remote case, | |
2999 -- must figure out the corresponding loot entry (if it exists). In both | |
3000 -- cases, must update history appropriately. Returns nil if anything odd | |
3001 -- happens; returns the affected loot index on success. | |
3002 --function addon:reassign_loot (index, to_name) | |
3003 function addon:reassign_loot (how, ...) | |
3004 -- This must all be filled out in all cases: | |
3005 local e, index, from_name, to_name, unique, id | |
3006 -- Only set in remote case: | |
3007 local sender | |
3008 | |
3009 if how == "local" then | |
3010 -- GUI doesn't allow reassignment unless the item is not-shard, | |
3011 -- so we can assume the presence of a unique tag in this function. | |
3012 index, to_name = ... | |
3013 assert(type(to_name)=='string' and to_name:len()>0) | |
3014 index = assert(tonumber(index)) | |
3015 e = g_loot[index] | |
3016 id = e.id | |
3017 unique = assert(e.unique) | |
3018 from_name = e.person | |
3019 | |
3020 elseif how == "remote" then | |
3021 sender, unique, id, from_name, to_name = ... | |
3022 id = tonumber(id) | |
3023 local cache | |
3024 local loop = 0 | |
3025 repeat -- wtb continue statement pst | |
3026 if loop > 1 then break end | |
3027 e = nil | |
3028 cache = cache and g_uniques:SEARCH(unique) or g_uniques[unique] | |
3029 index = tonumber(cache.loot) | |
3030 if index then | |
3031 e = g_loot[index] | |
3032 else | |
3033 end | |
3034 loop = loop + 1 | |
3035 until e and (e.id == id) | |
3036 | |
3037 else | |
3038 return -- silently ignore future cases from future clients | |
3039 end | |
3040 | |
3041 if self.debug.loot then | |
3042 local m = ("Reassign index %d (pre-unique %s) with id %d from '%s' to '%s'."): | |
3043 format(index, unique, id, tostring(from_name), tostring(to_name)) | |
3044 self.dprint('loot', m) | |
3045 if sender == my_name then | |
3046 self.dprint('loot',"(Returning early from debug mode's double self-reassign.)") | |
3047 return index | |
3048 end | |
3049 end | |
3050 | |
3051 if not e then | |
3052 -- say something? | |
3053 return | |
3054 end | |
3055 | |
2890 local from_i, from_h, hist_i = _history_by_loot_id (e, "reassign") | 3056 local from_i, from_h, hist_i = _history_by_loot_id (e, "reassign") |
2891 local from_name = e.person | |
2892 local to_i,to_h = self:get_loot_history(to_name) | 3057 local to_i,to_h = self:get_loot_history(to_name) |
2893 | 3058 |
2894 if not from_i then -- from_h here is the formatted error text | 3059 if not from_i then |
2895 self:Print(from_h .. " Loot will be reassigned, but history will NOT be updated.", e.itemlink) | 3060 if how == "local" then |
3061 -- from_h here is the formatted error text | |
3062 self:Print(from_h .. " Loot will be reassigned, but history will NOT be updated.", e.itemlink) | |
3063 end | |
2896 else | 3064 else |
3065 -- XXX do some sanity checks here? from_name == from_h.name, etc? | |
3066 | |
2897 local U = tremove (from_h.unique, hist_i) | 3067 local U = tremove (from_h.unique, hist_i) |
2898 -- The loot master giveth... | 3068 -- The loot master giveth... |
2899 to_h.unique[#to_h.unique+1] = U | 3069 to_h.unique[#to_h.unique+1] = U |
2900 to_h.when[U] = from_h.when[U] | 3070 to_h.when[U] = from_h.when[U] |
2901 to_h.id[U] = from_h.id[U] | 3071 to_h.id[U] = from_h.id[U] |
2906 from_h.id[U] = nil | 3076 from_h.id[U] = nil |
2907 from_h.count[U] = nil | 3077 from_h.count[U] = nil |
2908 -- Blessed be the lookup cache of the loot master. | 3078 -- Blessed be the lookup cache of the loot master. |
2909 g_uniques[U] = { loot = index, history = to_i } | 3079 g_uniques[U] = { loot = index, history = to_i } |
2910 end | 3080 end |
3081 local from_person_class = e.person_class or from_h.person_class | |
3082 or (g_loot.raiders[from_name] and g_loot.raiders[from_name].class) | |
3083 or select(2,_G.UnitClass(from_name)) | |
2911 e.person = to_name | 3084 e.person = to_name |
2912 e.person_class = select(2,_G.UnitClass(to_name)) | 3085 e.person_class = to_h.person_class |
3086 or (g_loot.raiders[to_name] and g_loot.raiders[to_name].class) | |
3087 or select(2,_G.UnitClass(to_name)) | |
2913 self.hist_clean = nil | 3088 self.hist_clean = nil |
2914 | 3089 self.loot_clean = nil |
2915 self:Print("Reassigned entry %d/%s from '%s' to '%s'.", index, e.itemlink, from_name, to_name) | 3090 |
3091 if how == "local" then | |
3092 --self:Print("Reassigned entry %d/%s from '%s' to '%s'.", index, e.itemlink, from_name, to_name) | |
3093 _notify_about_change (_G.DEFAULT_CHAT_FRAME, _G.UNIT_YOU, index, | |
3094 nil, from_name, from_person_class) | |
3095 self:vbroadcast('reassign', unique, id, from_name, to_name) | |
3096 elseif opts.chatty_on_remote_changes then | |
3097 _notify_about_remote (sender, index, nil, from_name, from_person_class) | |
3098 end | |
3099 if self.display then | |
3100 self.display:GetUserData("eoiST"):OuroLoot_Refresh(index) | |
3101 self:redisplay() | |
3102 end | |
3103 return index | |
2916 end | 3104 end |
2917 | 3105 |
2918 -- Similar to _addHistoryEntry. The second arg may be a loot entry | 3106 -- Similar to _addHistoryEntry. The second arg may be a loot entry |
2919 -- (which used to be at LOOTINDEX), or nil (and the loot entry will | 3107 -- (which used to be at LOOTINDEX), or nil (and the loot entry will |
2920 -- be pulled from LOOTINDEX instead). | 3108 -- be pulled from LOOTINDEX instead). |
3033 unique = e.unique -- can potentially still be nil at this step | 3221 unique = e.unique -- can potentially still be nil at this step |
3034 olddisp = e.disposition | 3222 olddisp = e.disposition |
3035 | 3223 |
3036 elseif how == "remote" then | 3224 elseif how == "remote" then |
3037 sender, unique, id, olddisp, newdisp = ... | 3225 sender, unique, id, olddisp, newdisp = ... |
3038 local cache = g_uniques[unique] | 3226 id = tonumber(id) |
3039 if cache.loot then | 3227 local cache |
3228 local loop = 0 | |
3229 repeat -- wtb continue statement pst | |
3230 if loop > 1 then break end | |
3231 e = nil | |
3232 cache = cache and g_uniques:SEARCH(unique) or g_uniques[unique] | |
3040 index = tonumber(cache.loot) | 3233 index = tonumber(cache.loot) |
3041 e = g_loot[index] | 3234 if index then |
3042 end | 3235 e = g_loot[index] |
3236 else | |
3237 end | |
3238 loop = loop + 1 | |
3239 until e and (e.id == id) | |
3043 | 3240 |
3044 else | 3241 else |
3045 return -- silently ignore future cases from future clients | 3242 return -- silently ignore future cases from future clients |
3046 end | 3243 end |
3047 | 3244 |
3062 | 3259 |
3063 e.disposition = newdisp | 3260 e.disposition = newdisp |
3064 e.bcast_from = nil -- I actually don't remember now why this gets cleared... | 3261 e.bcast_from = nil -- I actually don't remember now why this gets cleared... |
3065 e.extratext = nil | 3262 e.extratext = nil |
3066 self:history_handle_disposition (index, olddisp) | 3263 self:history_handle_disposition (index, olddisp) |
3264 self.hist_clean = nil | |
3265 self.loot_clean = nil | |
3067 -- A unique tag has been set by this point. | 3266 -- A unique tag has been set by this point. |
3068 if how == "local" then | 3267 if how == "local" then |
3069 unique = assert(e.unique) | 3268 unique = assert(e.unique) |
3070 self:vbroadcast('mark', unique, id, olddisp, newdisp) | 3269 self:vbroadcast('mark', unique, id, olddisp, newdisp) |
3071 end | 3270 end |
3153 addon.dprint('comm', "DOTmark/17, sender", sender, "unique", unique, | 3352 addon.dprint('comm', "DOTmark/17, sender", sender, "unique", unique, |
3154 "item", item, "from old", old, "to new", new) | 3353 "item", item, "from old", old, "to new", new) |
3155 local index = addon:loot_mark_disposition ("remote", sender, unique, item, old, new) | 3354 local index = addon:loot_mark_disposition ("remote", sender, unique, item, old, new) |
3156 --if not addon.enabled then return end -- hmm | 3355 --if not addon.enabled then return end -- hmm |
3157 if index and opts.chatty_on_remote_changes then | 3356 if index and opts.chatty_on_remote_changes then |
3158 _notify_about_remote (sender, index, --[[from_whom=]]nil, old) | 3357 _notify_about_remote (sender, index, old) |
3159 end | 3358 end |
3359 end | |
3360 | |
3361 OCR_funcs['17reassign'] = function (sender, _, unique, item, from, to) | |
3362 addon.dprint('comm', "DOTreassign/17, sender", sender, "unique", unique, | |
3363 "item", item, "from", from, "to", to) | |
3364 --[[local index =]] addon:reassign_loot ("remote", sender, unique, item, from, to) | |
3365 -- Notification handled inside reassign_loot. | |
3160 end | 3366 end |
3161 | 3367 |
3162 OCR_funcs['16loot'] = function (sender, _, recip, item, count, extratext) | 3368 OCR_funcs['16loot'] = function (sender, _, recip, item, count, extratext) |
3163 addon.dprint('comm', "DOTloot/16, sender", sender, "recip", recip, "item", item, "count", count) | 3369 addon.dprint('comm', "DOTloot/16, sender", sender, "recip", recip, "item", item, "count", count) |
3164 if not addon.enabled then return end | 3370 if not addon.enabled then return end |