Mercurial > wow > wowdb-profiler
comparison Main.lua @ 388:1c6098b69ec9
Added support for CHAT_MSG_CURRENCY data and replaced a few clunky conditional statements.
| author | MMOSimca <MMOSimca@gmail.com> |
|---|---|
| date | Tue, 16 Dec 2014 20:56:29 -0500 |
| parents | b4a0a56ab3ae |
| children | b00732fa9352 |
comparison
equal
deleted
inserted
replaced
| 387:b4a0a56ab3ae | 388:1c6098b69ec9 |
|---|---|
| 57 local TIMBER_ITEM_ID = 114781 | 57 local TIMBER_ITEM_ID = 114781 |
| 58 | 58 |
| 59 -- Ignoring NPC casts of the following spells | 59 -- Ignoring NPC casts of the following spells |
| 60 local CHI_WAVE_SPELL_ID = 132464 | 60 local CHI_WAVE_SPELL_ID = 132464 |
| 61 local DISGUISE_SPELL_ID = 121308 | 61 local DISGUISE_SPELL_ID = 121308 |
| 62 | |
| 63 -- For timer-based loot gathering of abnormal containers (that don't use SHOW_LOOT_TOAST, sadly) | |
| 64 local BAG_OF_SALVAGE_ITEM_ID = private.DELAYED_CONTAINER_SPELL_ID_TO_ITEM_ID_MAP[168178] | |
| 65 local CRATE_OF_SALVAGE_ITEM_ID = private.DELAYED_CONTAINER_SPELL_ID_TO_ITEM_ID_MAP[168179] | |
| 66 local BIG_CRATE_OF_SALVAGE_ITEM_ID = private.DELAYED_CONTAINER_SPELL_ID_TO_ITEM_ID_MAP[168180] | |
| 67 | 62 |
| 68 -- Constant for duplicate boss data; a dirty hack to get around world bosses that cannot be identified individually and cannot be linked on wowdb because they are not in a raid | 63 -- Constant for duplicate boss data; a dirty hack to get around world bosses that cannot be identified individually and cannot be linked on wowdb because they are not in a raid |
| 69 local DUPLICATE_WORLD_BOSS_IDS = { | 64 local DUPLICATE_WORLD_BOSS_IDS = { |
| 70 [71952] = { 71953, 71954, 71955, }, | 65 [71952] = { 71953, 71954, 71955, }, |
| 71 } | 66 } |
| 97 local EVENT_MAPPING = { | 92 local EVENT_MAPPING = { |
| 98 AUCTION_HOUSE_SHOW = true, | 93 AUCTION_HOUSE_SHOW = true, |
| 99 BANKFRAME_OPENED = true, | 94 BANKFRAME_OPENED = true, |
| 100 BATTLEFIELDS_SHOW = true, | 95 BATTLEFIELDS_SHOW = true, |
| 101 BLACK_MARKET_ITEM_UPDATE = true, | 96 BLACK_MARKET_ITEM_UPDATE = true, |
| 97 CHAT_MSG_CURRENCY = true, | |
| 102 CHAT_MSG_LOOT = true, | 98 CHAT_MSG_LOOT = true, |
| 103 CHAT_MSG_MONSTER_SAY = "RecordQuote", | 99 CHAT_MSG_MONSTER_SAY = "RecordQuote", |
| 104 CHAT_MSG_MONSTER_WHISPER = "RecordQuote", | 100 CHAT_MSG_MONSTER_WHISPER = "RecordQuote", |
| 105 CHAT_MSG_MONSTER_YELL = "RecordQuote", | 101 CHAT_MSG_MONSTER_YELL = "RecordQuote", |
| 106 CHAT_MSG_SYSTEM = true, | 102 CHAT_MSG_SYSTEM = true, |
| 720 return | 716 return |
| 721 end | 717 end |
| 722 local entry | 718 local entry |
| 723 | 719 |
| 724 -- At this point we only have a name if it's an object. | 720 -- At this point we only have a name if it's an object. |
| 721 -- (As of 5.x, the above statement is almost never true, but there are a few cases, like gas extractions.) | |
| 725 if current_loot.target_type == AF.OBJECT then | 722 if current_loot.target_type == AF.OBJECT then |
| 726 entry = DBEntry(data_type, ("%s:%s"):format(current_loot.spell_label, current_loot.object_name)) | 723 entry = DBEntry(data_type, ("%s:%s"):format(current_loot.spell_label, current_loot.object_name)) |
| 727 else | 724 else |
| 728 entry = DBEntry(data_type, current_loot.identifier) | 725 entry = DBEntry(data_type, current_loot.identifier) |
| 729 end | 726 end |
| 891 if chat_loot_timer_handle then | 888 if chat_loot_timer_handle then |
| 892 chat_loot_timer_handle:Cancel() | 889 chat_loot_timer_handle:Cancel() |
| 893 chat_loot_timer_handle = nil | 890 chat_loot_timer_handle = nil |
| 894 end | 891 end |
| 895 | 892 |
| 896 if current_loot and current_loot.identifier and (current_loot.identifier == BAG_OF_SALVAGE_ITEM_ID or current_loot.identifier == CRATE_OF_SALVAGE_ITEM_ID or current_loot.identifier == BIG_CRATE_OF_SALVAGE_ITEM_ID) then | 893 if current_loot and current_loot.identifier and (CONTAINER_ITEM_ID_LIST[current_loot.identifier] ~= nil) then |
| 897 GenericLootUpdate("items") | 894 GenericLootUpdate("items") |
| 898 end | 895 end |
| 899 current_loot = nil | 896 current_loot = nil |
| 900 end | 897 end |
| 901 | 898 |
| 1454 end | 1451 end |
| 1455 end | 1452 end |
| 1456 | 1453 |
| 1457 | 1454 |
| 1458 do | 1455 do |
| 1456 local CHAT_MSG_CURRENCY_UPDATE_FUNCS = { | |
| 1457 [AF.ITEM] = function(currency_texture, quantity) | |
| 1458 local currency_token = ("currency:%s"):format(currency_texture) | |
| 1459 local container_id = current_loot.identifier -- For faster access, since this is going to be called 9 times in the next 3 lines | |
| 1460 -- Verify that we're still assigning data to the right items | |
| 1461 if container_id and (CONTAINER_ITEM_ID_LIST[container_id] ~= nil) then | |
| 1462 Debug("CHAT_MSG_CURRENCY: AF.ITEM %s (%d)", currency_token, quantity) | |
| 1463 current_loot.sources[container_id] = current_loot.sources[container_id] or {} | |
| 1464 current_loot.sources[container_id][currency_token] = (current_loot.sources[container_id][currency_token] or 0) + quantity | |
| 1465 else -- If not, cancel the timer and wipe the loot table early | |
| 1466 Debug("CHAT_MSG_CURRENCY: We would have assigned the wrong loot!") | |
| 1467 ClearChatLootData() | |
| 1468 end | |
| 1469 end, | |
| 1470 [AF.NPC] = function(currency_texture, quantity) | |
| 1471 Debug("CHAT_MSG_CURRENCY: AF.NPC currency:%s (%d)", currency_texture, quantity) | |
| 1472 end, | |
| 1473 [AF.ZONE] = function(currency_texture, quantity) | |
| 1474 local currency_token = ("currency:%s"):format(currency_texture) | |
| 1475 Debug("CHAT_MSG_CURRENCY: AF.ZONE %s (%d)", currency_token, quantity) | |
| 1476 InitializeCurrentLoot() | |
| 1477 current_loot.list[1] = ("%s:%d"):format(currency_token, quantity) | |
| 1478 GenericLootUpdate("zones") | |
| 1479 current_loot = nil | |
| 1480 end, | |
| 1481 } | |
| 1482 | |
| 1483 | |
| 1484 function WDP:CHAT_MSG_CURRENCY(event_name, message) | |
| 1485 local category | |
| 1486 | |
| 1487 local currency_link, quantity = deformat(message, _G.CURRENCY_GAINED_MULTIPLE) | |
| 1488 if not currency_link then | |
| 1489 quantity, currency_link = 1, deformat(message, _G.CURRENCY_GAINED) | |
| 1490 end | |
| 1491 local currency_texture = CurrencyLinkToTexture(currency_link) | |
| 1492 | |
| 1493 if not currency_texture or currency_texture == "" then | |
| 1494 return | |
| 1495 end | |
| 1496 | |
| 1497 -- Set update category | |
| 1498 if current_action.spell_label == "FISHING" then | |
| 1499 category = AF.ZONE | |
| 1500 elseif raid_boss_id then | |
| 1501 category = AF.NPC | |
| 1502 elseif chat_loot_timer_handle then | |
| 1503 category = AF.ITEM | |
| 1504 end | |
| 1505 | |
| 1506 -- Take action based on update category | |
| 1507 local update_func = CHAT_MSG_CURRENCY_UPDATE_FUNCS[category] | |
| 1508 if not category or not update_func then | |
| 1509 return | |
| 1510 end | |
| 1511 update_func(currency_texture, quantity) | |
| 1512 end | |
| 1513 | |
| 1514 | |
| 1459 local CHAT_MSG_LOOT_UPDATE_FUNCS = { | 1515 local CHAT_MSG_LOOT_UPDATE_FUNCS = { |
| 1460 [AF.ITEM] = function(item_id, quantity) | 1516 [AF.ITEM] = function(item_id, quantity) |
| 1461 local container_id = current_loot.identifier -- For faster access, since this is going to be called 9 times in the next 3 lines | 1517 local container_id = current_loot.identifier -- For faster access, since this is going to be called 9 times in the next 3 lines |
| 1462 -- Verify that we're still assigning data to the right items | 1518 -- Verify that we're still assigning data to the right items |
| 1463 if container_id and (container_id == BAG_OF_SALVAGE_ITEM_ID or container_id == CRATE_OF_SALVAGE_ITEM_ID or container_id == BIG_CRATE_OF_SALVAGE_ITEM_ID) then | 1519 if container_id and (CONTAINER_ITEM_ID_LIST[container_id] ~= nil) then |
| 1464 Debug("CHAT_MSG_LOOT: AF.ITEM %d (%d)", item_id, quantity) | 1520 Debug("CHAT_MSG_LOOT: AF.ITEM %d (%d)", item_id, quantity) |
| 1465 current_loot.sources[container_id] = current_loot.sources[container_id] or {} | 1521 current_loot.sources[container_id] = current_loot.sources[container_id] or {} |
| 1466 current_loot.sources[container_id][item_id] = (current_loot.sources[container_id][item_id] or 0) + quantity | 1522 current_loot.sources[container_id][item_id] = (current_loot.sources[container_id][item_id] or 0) + quantity |
| 1467 else -- If not, cancel the timer and wipe the loot table early | 1523 else -- If not, cancel the timer and wipe the loot table early |
| 1468 Debug("CHAT_MSG_LOOT: We would have assigned the wrong loot!") | 1524 Debug("CHAT_MSG_LOOT: We would have assigned the wrong loot!") |
| 1496 current_loot = nil | 1552 current_loot = nil |
| 1497 end, | 1553 end, |
| 1498 } | 1554 } |
| 1499 | 1555 |
| 1500 | 1556 |
| 1501 function WDP:CHAT_MSG_CURRENCY(event_name, message) | 1557 function WDP:CHAT_MSG_LOOT(event_name, message) |
| 1502 local category | 1558 local category |
| 1503 | 1559 |
| 1504 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE) | 1560 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE) |
| 1505 if not item_link then | 1561 if not item_link then |
| 1506 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF) | 1562 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF) |
| 1515 if last_timber_spell_id and item_id == TIMBER_ITEM_ID then | 1571 if last_timber_spell_id and item_id == TIMBER_ITEM_ID then |
| 1516 category = AF.OBJECT | 1572 category = AF.OBJECT |
| 1517 -- Recently changed from ~= "EXTRACT_GAS" because of some occassional bad data, and, as far as I know, no benefit. | 1573 -- Recently changed from ~= "EXTRACT_GAS" because of some occassional bad data, and, as far as I know, no benefit. |
| 1518 elseif current_action.spell_label == "FISHING" then | 1574 elseif current_action.spell_label == "FISHING" then |
| 1519 category = AF.ZONE | 1575 category = AF.ZONE |
| 1520 elseif private.raid_boss_id then | 1576 elseif raid_boss_id then |
| 1521 category = AF.NPC | 1577 category = AF.NPC |
| 1522 elseif chat_loot_timer_handle then | 1578 elseif chat_loot_timer_handle then |
| 1523 category = AF.ITEM | 1579 category = AF.ITEM |
| 1524 end | 1580 end |
| 1525 | 1581 |
| 1530 RecordItemData(item_id, item_link, true) | 1586 RecordItemData(item_id, item_link, true) |
| 1531 return | 1587 return |
| 1532 end | 1588 end |
| 1533 update_func(item_id, quantity) | 1589 update_func(item_id, quantity) |
| 1534 end | 1590 end |
| 1535 | 1591 end |
| 1536 | 1592 |
| 1537 function WDP:CHAT_MSG_SYSTEM(event_name, message) | 1593 |
| 1538 local item_link, quantity = deformat(message, _G.ERR_QUEST_REWARD_ITEM_MULT_IS) | 1594 function WDP:CHAT_MSG_SYSTEM(event_name, message) |
| 1539 if not item_link then | 1595 local item_link, quantity = deformat(message, _G.ERR_QUEST_REWARD_ITEM_MULT_IS) |
| 1540 quantity, item_link = 1, deformat(message, _G.ERR_QUEST_REWARD_ITEM_S) | 1596 if not item_link then |
| 1541 end | 1597 quantity, item_link = 1, deformat(message, _G.ERR_QUEST_REWARD_ITEM_S) |
| 1542 local item_id = ItemLinkToID(item_link) | 1598 end |
| 1543 | 1599 local item_id = ItemLinkToID(item_link) |
| 1544 if not item_id then | 1600 |
| 1545 return | 1601 if not item_id then |
| 1546 end | 1602 return |
| 1547 | 1603 end |
| 1548 -- We only want to record the item's incoming data; no other need for system messages atm. | 1604 |
| 1549 RecordItemData(item_id, item_link, true) | 1605 -- We only want to record the item's incoming data; no other need for system messages atm. |
| 1550 end | 1606 RecordItemData(item_id, item_link, true) |
| 1551 end | 1607 end |
| 1552 | 1608 |
| 1553 | 1609 |
| 1554 function WDP:RecordQuote(event_name, message, source_name, language_name) | 1610 function WDP:RecordQuote(event_name, message, source_name, language_name) |
| 1555 if not ALLOWED_LOCALES[CLIENT_LOCALE] or not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then | 1611 if not ALLOWED_LOCALES[CLIENT_LOCALE] or not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then |
