Mercurial > wow > ouroloot
comparison core.lua @ 55:ac57a4342812
More people going to be looking at g_loot entries, so start cleaning up older fields a bit, and handle loading older data.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Sat, 07 Apr 2012 05:40:20 +0000 |
| parents | 6d5fcbdc0590 |
| children | fcc0d0ff5832 |
comparison
equal
deleted
inserted
replaced
| 54:6d5fcbdc0590 | 55:ac57a4342812 |
|---|---|
| 16 | 16 |
| 17 Time specific g_loot indices: | 17 Time specific g_loot indices: |
| 18 - startday table with month/day/year/text fields from makedate() | 18 - startday table with month/day/year/text fields from makedate() |
| 19 | 19 |
| 20 Boss specific g_loot indices: | 20 Boss specific g_loot indices: |
| 21 - bosskill name of boss/encounter; not necessarily a kill; | 21 - bossname name of boss/encounter; |
| 22 - may be changed if "snarky boss names" option is enabled | 22 - may be changed if "snarky boss names" option is enabled |
| 23 - reason wipe/kill ("pull" does not generate an entry) | 23 - reason wipe/kill ("pull" does not generate an entry) |
| 24 - instance name of instance, including size and difficulty | 24 - instance name of instance, including size and difficulty |
| 25 - duration in seconds; may be missing | 25 - duration in seconds; may be missing |
| 26 - raiderlist "Able, Baker, Charlie"; may be missing | 26 - raiderlist "Able, Baker, Charlie"; may be missing |
| 86 OuroLootSV_log = {} | 86 OuroLootSV_log = {} |
| 87 | 87 |
| 88 | 88 |
| 89 ------ Constants | 89 ------ Constants |
| 90 local option_defaults = { | 90 local option_defaults = { |
| 91 ['datarev'] = 15, -- cheating, this isn't actually an option | |
| 91 ['popup_on_join'] = true, | 92 ['popup_on_join'] = true, |
| 92 ['register_slashloot'] = true, | 93 ['register_slashloot'] = true, |
| 93 ['scroll_to_bottom'] = true, | 94 ['scroll_to_bottom'] = true, |
| 94 ['chatty_on_kill'] = false, | 95 ['chatty_on_kill'] = false, |
| 95 ['no_tracking_wipes'] = false, | 96 ['no_tracking_wipes'] = false, |
| 439 s:Print(virgin, s.format_hypertext('help',"click here",ITEM_QUALITY_UNCOMMON)) | 440 s:Print(virgin, s.format_hypertext('help',"click here",ITEM_QUALITY_UNCOMMON)) |
| 440 virgin = nil | 441 virgin = nil |
| 441 end,10,self) | 442 end,10,self) |
| 442 end | 443 end |
| 443 opts = OuroLootSV_opts | 444 opts = OuroLootSV_opts |
| 445 local stored_datarev = opts.datarev | |
| 444 for opt,default in pairs(option_defaults) do | 446 for opt,default in pairs(option_defaults) do |
| 445 if opts[opt] == nil then | 447 if opts[opt] == nil then |
| 446 opts[opt] = default | 448 opts[opt] = default |
| 447 end | 449 end |
| 448 end | 450 end |
| 505 end | 507 end |
| 506 end | 508 end |
| 507 end | 509 end |
| 508 self.history_all.HISTFORMAT = nil -- don't keep this in live data | 510 self.history_all.HISTFORMAT = nil -- don't keep this in live data |
| 509 --OuroLootSV_hist = nil | 511 --OuroLootSV_hist = nil |
| 512 | |
| 513 -- Handle changes to the stored data format, in stages from oldest to | |
| 514 -- newest. This won't look coherent until multiple stages are happening. | |
| 515 if stored_datarev == nil then | |
| 516 self:Print("Transitioning saved data format to 15...") | |
| 517 for i,e in ipairs(OuroLootSV) do | |
| 518 if e.bosskill then | |
| 519 e.bossname, e.bosskill = e.bosskill, nil | |
| 520 end | |
| 521 end | |
| 522 stored_datarev = 15 | |
| 523 end | |
| 524 --if stored_datarev == 15 then.... | |
| 510 | 525 |
| 511 _init(self) | 526 _init(self) |
| 512 self.dprint('flow', "version strings:", revision_large, self.status_text) | 527 self.dprint('flow', "version strings:", revision_large, self.status_text) |
| 513 self.OnInitialize = nil | 528 self.OnInitialize = nil |
| 514 end | 529 end |
| 799 -- this is set on various boss interactions, so we've got a kill/wipe | 814 -- this is set on various boss interactions, so we've got a kill/wipe |
| 800 -- entry already | 815 -- entry already |
| 801 if addon.latest_instance then return end | 816 if addon.latest_instance then return end |
| 802 addon.latest_instance = instance_tag() | 817 addon.latest_instance = instance_tag() |
| 803 addon:_mark_boss_kill (addon._addLootEntry{ | 818 addon:_mark_boss_kill (addon._addLootEntry{ |
| 804 kind='boss',reason='kill',bosskill=[[trash]],instance=addon.latest_instance,duration=0 | 819 kind='boss',reason='kill',bossname=[[trash]],instance=addon.latest_instance,duration=0 |
| 805 }) | 820 }) |
| 806 end | 821 end |
| 807 | 822 |
| 808 -- Recent loot cache | 823 -- Recent loot cache |
| 809 local candidates = {} | 824 local candidates = {} |
| 1001 return self:BuildMainDisplay() | 1016 return self:BuildMainDisplay() |
| 1002 end | 1017 end |
| 1003 | 1018 |
| 1004 elseif cmd == "fake" then -- maybe comment this out for real users | 1019 elseif cmd == "fake" then -- maybe comment this out for real users |
| 1005 self:_mark_boss_kill (self._addLootEntry{ | 1020 self:_mark_boss_kill (self._addLootEntry{ |
| 1006 kind='boss',reason='kill',bosskill="Baron Steamroller",instance=instance_tag(),duration=0 | 1021 kind='boss',reason='kill',bossname="Baron Steamroller",instance=instance_tag(),duration=0 |
| 1007 }) | 1022 }) |
| 1008 self:CHAT_MSG_LOOT ('manual', my_name, 54797) | 1023 self:CHAT_MSG_LOOT ('manual', my_name, 54797) |
| 1009 if self.display then | 1024 if self.display then |
| 1010 self:redisplay() | 1025 self:redisplay() |
| 1011 end | 1026 end |
| 1393 addon.latest_instance = boss.instance | 1408 addon.latest_instance = boss.instance |
| 1394 addon.dprint('loot', "added boss entry", bossi) | 1409 addon.dprint('loot', "added boss entry", bossi) |
| 1395 if boss.reason == 'kill' then | 1410 if boss.reason == 'kill' then |
| 1396 addon:_mark_boss_kill (bossi) | 1411 addon:_mark_boss_kill (bossi) |
| 1397 if opts.chatty_on_kill then | 1412 if opts.chatty_on_kill then |
| 1398 addon:Print("Registered kill for '%s' in %s!", boss.bosskill, boss.instance) | 1413 addon:Print("Registered kill for '%s' in %s!", boss.bossname, boss.instance) |
| 1399 end | 1414 end |
| 1400 end | 1415 end |
| 1401 wipe(candidates) | 1416 wipe(candidates) |
| 1402 end | 1417 end |
| 1403 addon.recent_boss = create_new_cache ('boss', 10, fixup_durations) | 1418 addon.recent_boss = create_new_cache ('boss', 10, fixup_durations) |
| 1427 -- by the cache, (3) we happen to get some non-local events before doing | 1442 -- by the cache, (3) we happen to get some non-local events before doing |
| 1428 -- our local event (not because of network weirdness but because our local | 1443 -- our local event (not because of network weirdness but because our local |
| 1429 -- DBM might not trigger for a while). | 1444 -- DBM might not trigger for a while). |
| 1430 local c = { | 1445 local c = { |
| 1431 kind = 'boss', | 1446 kind = 'boss', |
| 1432 bosskill = bossname, -- minor misnomer, might not actually be a kill | 1447 bossname = bossname, |
| 1433 reason = reason, | 1448 reason = reason, |
| 1434 instance = intag, | 1449 instance = intag, |
| 1435 duration = duration, -- these two deliberately may be nil | 1450 duration = duration, -- these two deliberately may be nil |
| 1436 raiderlist = raiders and table.concat(raiders, ", ") | 1451 raiderlist = raiders and table.concat(raiders, ", ") |
| 1437 } | 1452 } |
| 1448 local e = g_loot[index] | 1463 local e = g_loot[index] |
| 1449 if not e then | 1464 if not e then |
| 1450 self:Print("Something horribly wrong;", index, "is not a valid entry!") | 1465 self:Print("Something horribly wrong;", index, "is not a valid entry!") |
| 1451 return | 1466 return |
| 1452 end | 1467 end |
| 1453 if not e.bosskill then | 1468 if not e.bossname then |
| 1454 self:Print("Something horribly wrong;", index, "is not a boss entry!") | 1469 self:Print("Something horribly wrong;", index, "is not a boss entry!") |
| 1455 return | 1470 return |
| 1456 end | 1471 end |
| 1457 if e.reason ~= 'wipe' then | 1472 if e.reason ~= 'wipe' then |
| 1458 -- enh, bail | 1473 -- enh, bail |
| 1461 local attempts = 1 | 1476 local attempts = 1 |
| 1462 local first | 1477 local first |
| 1463 | 1478 |
| 1464 local i,d = 1,g_loot[1] | 1479 local i,d = 1,g_loot[1] |
| 1465 while d ~= e do | 1480 while d ~= e do |
| 1466 if d.bosskill and | 1481 if d.bossname and |
| 1467 d.bosskill == e.bosskill and | 1482 d.bossname == e.bossname and |
| 1468 d.instance == e.instance and | 1483 d.instance == e.instance and |
| 1469 d.reason == 'wipe' | 1484 d.reason == 'wipe' |
| 1470 then | 1485 then |
| 1471 first = first or i | 1486 first = first or i |
| 1472 attempts = attempts + 1 | 1487 attempts = attempts + 1 |
| 1646 end | 1661 end |
| 1647 end | 1662 end |
| 1648 | 1663 |
| 1649 assert(g_loot[is].kind == 'boss') | 1664 assert(g_loot[is].kind == 'boss') |
| 1650 local boss = tremove (g_loot, is) | 1665 local boss = tremove (g_loot, is) |
| 1651 --pprint('loot', "MOVING", boss.bosskill) | 1666 --pprint('loot', "MOVING", boss.bossname) |
| 1652 tinsert (g_loot, should_be, boss) | 1667 tinsert (g_loot, should_be, boss) |
| 1653 return should_be | 1668 return should_be |
| 1654 end | 1669 end |
| 1655 end | 1670 end |
| 1656 | 1671 |
