Mercurial > wow > ouroloot
comparison core.lua @ 77:a07c9dd79f3a
Formalize the code handling unique ID collisions that turn out to not be avoidable with improv numbers. Turn on debug.comm and debug.loot with @debug@ markers.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Mon, 11 Jun 2012 21:03:16 +0000 |
| parents | 124da015c4a2 |
| children | f8118aa5fbb8 |
comparison
equal
deleted
inserted
replaced
| 76:124da015c4a2 | 77:a07c9dd79f3a |
|---|---|
| 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 Item '%s' was carrying unique tag " | 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." |
| 147 .."<%s>, but that was already in use! (New sender was '%s', previous cache " | |
| 148 .."entry was <%s/%s>.) This may require a live human to figure out; the " | |
| 149 .."loot in question has not been stored." | |
| 150 local remote_chatty = "|cff00ff00%s|r changed %d/%s from %s%s|r to %s%s|r" | 147 local remote_chatty = "|cff00ff00%s|r changed %d/%s from %s%s|r to %s%s|r" |
| 151 local qualnames = { | 148 local qualnames = { |
| 152 ['gray'] = 0, ['grey'] = 0, ['poor'] = 0, ['trash'] = 0, | 149 ['gray'] = 0, ['grey'] = 0, ['poor'] = 0, ['trash'] = 0, |
| 153 ['white'] = 1, ['common'] = 1, | 150 ['white'] = 1, ['common'] = 1, |
| 154 ['green'] = 2, ['uncommon'] = 2, | 151 ['green'] = 2, ['uncommon'] = 2, |
| 193 flow = false, | 190 flow = false, |
| 194 notraid = false, | 191 notraid = false, |
| 195 cache = false, | 192 cache = false, |
| 196 alsolog = false, | 193 alsolog = false, |
| 197 } | 194 } |
| 195 --@debug@ | |
| 196 DEBUG_PRINT = true | |
| 197 debug.loot = true | |
| 198 debug.comm = true | |
| 199 --@end-debug@ | |
| 200 | |
| 198 -- This looks ugly, but it factors out the load-time decisions from | 201 -- This looks ugly, but it factors out the load-time decisions from |
| 199 -- the run-time ones. Args to [dp]print are concatenated with spaces. | 202 -- the run-time ones. Args to [dp]print are concatenated with spaces. |
| 200 if tekdebug then | 203 if tekdebug then |
| 201 function dprint (t,...) | 204 function dprint (t,...) |
| 202 if DEBUG_PRINT and debug[t] then | 205 if DEBUG_PRINT and debug[t] then |
| 335 local pprint, tabledump = addon.pprint, flib.tabledump | 338 local pprint, tabledump = addon.pprint, flib.tabledump |
| 336 local CopyTable, GetNumRaidMembers = _G.CopyTable, _G.GetNumRaidMembers | 339 local CopyTable, GetNumRaidMembers = _G.CopyTable, _G.GetNumRaidMembers |
| 337 -- En masse forward decls of symbols defined inside local blocks | 340 -- En masse forward decls of symbols defined inside local blocks |
| 338 local _register_bossmod, makedate, create_new_cache, _init, _log | 341 local _register_bossmod, makedate, create_new_cache, _init, _log |
| 339 local _history_by_loot_id, _notify_about_remote, _setup_unique_replace | 342 local _history_by_loot_id, _notify_about_remote, _setup_unique_replace |
| 343 local _unavoidable_collision | |
| 340 | 344 |
| 341 -- Try to extract numbers from the .toc "Version" and munge them into an | 345 -- Try to extract numbers from the .toc "Version" and munge them into an |
| 342 -- integral form for comparison. The result doesn't need to be meaningful as | 346 -- integral form for comparison. The result doesn't need to be meaningful as |
| 343 -- long as we can reliably feed two of them to "<" and get useful answers. | 347 -- long as we can reliably feed two of them to "<" and get useful answers. |
| 344 -- | 348 -- |
| 1376 self.dprint('loot', "substituting", unique, "with", replacement) | 1380 self.dprint('loot', "substituting", unique, "with", replacement) |
| 1377 else | 1381 else |
| 1378 i = g_uniques[unique] | 1382 i = g_uniques[unique] |
| 1379 local err = unique_collision:format (ERROR_CAPS, iname, unique, | 1383 local err = unique_collision:format (ERROR_CAPS, iname, unique, |
| 1380 tostring(from), tostring(i.loot), tostring(i.history)) | 1384 tostring(from), tostring(i.loot), tostring(i.history)) |
| 1381 self:Print(err) | 1385 _unavoidable_collision (err) |
| 1382 _G.PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "master") | |
| 1383 -- Make sure this is logged one way or another | 1386 -- Make sure this is logged one way or another |
| 1384 ;(self.debug.loot and self.dprint or pprint)('loot', "COLLISION", prefix, err); | 1387 ;(self.debug.loot and self.dprint or pprint)('loot', "COLLISION", prefix, err); |
| 1385 ret1, ret2 = nil, err | 1388 ret1, ret2 = nil, err |
| 1386 break | 1389 break |
| 1387 end | 1390 end |
| 2473 g_unique_replace = gur | 2476 g_unique_replace = gur |
| 2474 _setup_unique_replace = nil | 2477 _setup_unique_replace = nil |
| 2475 end | 2478 end |
| 2476 end | 2479 end |
| 2477 | 2480 |
| 2481 do | |
| 2482 local clicky | |
| 2483 function _unavoidable_collision (err) | |
| 2484 -- This should happen so rarely that it's not worth moving into gui.lua | |
| 2485 if not StaticPopupDialogs["OUROL_COLLISION"] then | |
| 2486 StaticPopupDialogs["OUROL_COLLISION"] = flib.StaticPopup{ | |
| 2487 button1 = OKAY, | |
| 2488 } | |
| 2489 clicky = addon.format_hypertext( | |
| 2490 [[ SYSTEM FAILURE -- RELEASE RINZLER ]], "|cffff0000", | |
| 2491 function() StaticPopup_Show "OUROL_COLLISION" end) | |
| 2492 end | |
| 2493 StaticPopupDialogs["OUROL_COLLISION"].text = err | |
| 2494 _G.PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "Master") | |
| 2495 addon:Print (" ") | |
| 2496 addon:Print (" ", clicky) | |
| 2497 addon:Print (" ") | |
| 2498 end | |
| 2499 end | |
| 2500 --function DOTEST() | |
| 2501 -- local err = unique_collision:format (ERROR_CAPS, | |
| 2502 -- "Codpiece of the Grimacing Lunatic", | |
| 2503 -- 'n3183021', 'Farmbuyer', '14', '78') | |
| 2504 -- _unavoidable_collision (err) | |
| 2505 -- pprint('ohfuck', "COLLISION", err) | |
| 2506 --end | |
| 2507 | |
| 2478 | 2508 |
| 2479 ------ Saved texts | 2509 ------ Saved texts |
| 2480 function addon:check_saved_table(silent_p) | 2510 function addon:check_saved_table(silent_p) |
| 2481 local s = _G.OuroLootSV_saved | 2511 local s = _G.OuroLootSV_saved |
| 2482 if s and (#s > 0) then return s end | 2512 if s and (#s > 0) then return s end |
