Mercurial > wow > wowdb-profiler
comparison Main.lua @ 309:3b9c6d588e62 5.3.0-2
Looting fixes.
| author | James D. Callahan III <jcallahan@curse.com> |
|---|---|
| date | Wed, 14 Aug 2013 14:35:45 -0500 |
| parents | 22e2e16318e5 |
| children | de9d571df07f |
comparison
equal
deleted
inserted
replaced
| 308:22e2e16318e5 | 309:3b9c6d588e62 |
|---|---|
| 654 end | 654 end |
| 655 source_list[source_id] = true | 655 source_list[source_id] = true |
| 656 end | 656 end |
| 657 UpdateDBEntryLocation(data_type, source_id) | 657 UpdateDBEntryLocation(data_type, source_id) |
| 658 | 658 |
| 659 if current_loot.target_type == AF.OBJECT then | 659 if current_loot.target_type == AF.ZONE then |
| 660 for item_id, quantity in pairs(loot_data) do | |
| 661 table.insert(loot_table, ("%d:%d"):format(item_id, quantity)) | |
| 662 end | |
| 663 else | |
| 660 for loot_token, quantity in pairs(loot_data) do | 664 for loot_token, quantity in pairs(loot_data) do |
| 661 local label, currency_texture = (":"):split(loot_token) | 665 local label, currency_texture = (":"):split(loot_token) |
| 662 | 666 |
| 663 if label == "currency" and currency_texture then | 667 if label == "currency" and currency_texture then |
| 664 table.insert(loot_table, ("currency:%d:%s"):format(quantity, currency_texture)) | 668 table.insert(loot_table, ("currency:%d:%s"):format(quantity, currency_texture)) |
| 665 elseif loot_token == "money" then | 669 elseif loot_token == "money" then |
| 666 table.insert(loot_table, ("money:%d"):format(quantity)) | 670 table.insert(loot_table, ("money:%d"):format(quantity)) |
| 667 else | 671 else |
| 668 table.insert(loot_table, ("%d:%d"):format(loot_token, quantity)) | 672 table.insert(loot_table, ("%d:%d"):format(loot_token, quantity)) |
| 669 end | 673 end |
| 670 end | |
| 671 else | |
| 672 for item_id, quantity in pairs(loot_data) do | |
| 673 table.insert(loot_table, ("%d:%d"):format(item_id, quantity)) | |
| 674 end | 674 end |
| 675 end | 675 end |
| 676 end | 676 end |
| 677 end | 677 end |
| 678 end | 678 end |
| 1694 encounter_data.loot_counts = encounter_data.loot_counts or {} | 1694 encounter_data.loot_counts = encounter_data.loot_counts or {} |
| 1695 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1 | 1695 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1 |
| 1696 source_list[source_id] = true | 1696 source_list[source_id] = true |
| 1697 end | 1697 end |
| 1698 | 1698 |
| 1699 for item_id, quantity in pairs(loot_data) do | 1699 for loot_token, quantity in pairs(loot_data) do |
| 1700 table.insert(encounter_data[loot_type], ("%d:%d"):format(item_id, quantity)) | 1700 local label, currency_texture = (":"):split(loot_token) |
| 1701 | |
| 1702 if label == "currency" and currency_texture then | |
| 1703 table.insert(encounter_data[loot_type], ("currency:%d:%s"):format(quantity, currency_texture)) | |
| 1704 elseif loot_token == "money" then | |
| 1705 table.insert(encounter_data[loot_type], ("money:%d"):format(quantity)) | |
| 1706 else | |
| 1707 table.insert(encounter_data[loot_type], ("%d:%d"):format(loot_token, quantity)) | |
| 1708 end | |
| 1701 end | 1709 end |
| 1702 end | 1710 end |
| 1703 end | |
| 1704 | |
| 1705 -- TODO: Remove this when GetLootSourceInfo() has values for money | |
| 1706 if #current_loot.list <= 0 then | |
| 1707 return | |
| 1708 end | |
| 1709 local npc = NPCEntry(current_loot.identifier) | |
| 1710 | |
| 1711 if not npc then | |
| 1712 return | |
| 1713 end | |
| 1714 local encounter_data = npc:EncounterData(difficulty_token) | |
| 1715 encounter_data[loot_type] = encounter_data[loot_type] or {} | |
| 1716 | |
| 1717 if not source_list[current_loot.identifier] then | |
| 1718 encounter_data.loot_counts = encounter_data.loot_counts or {} | |
| 1719 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1 | |
| 1720 end | |
| 1721 | |
| 1722 for index = 1, #current_loot.list do | |
| 1723 table.insert(encounter_data[loot_type], current_loot.list[index]) | |
| 1724 end | 1711 end |
| 1725 end, | 1712 end, |
| 1726 [AF.OBJECT] = function() | 1713 [AF.OBJECT] = function() |
| 1727 GenericLootUpdate("objects", InstanceDifficultyToken()) | 1714 GenericLootUpdate("objects", InstanceDifficultyToken()) |
| 1728 end, | 1715 end, |
| 1800 for loot_index = 1, #loot_info, 2 do | 1787 for loot_index = 1, #loot_info, 2 do |
| 1801 local source_guid = loot_info[loot_index] | 1788 local source_guid = loot_info[loot_index] |
| 1802 | 1789 |
| 1803 if not loot_guid_registry[current_loot.label][source_guid] then | 1790 if not loot_guid_registry[current_loot.label][source_guid] then |
| 1804 local loot_quantity = loot_info[loot_index + 1] | 1791 local loot_quantity = loot_info[loot_index + 1] |
| 1792 if #loot_info == 2 and slot_quantity > loot_quantity then | |
| 1793 loot_quantity = slot_quantity | |
| 1794 end | |
| 1805 local source_type, source_id = ParseGUID(source_guid) | 1795 local source_type, source_id = ParseGUID(source_guid) |
| 1806 local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id) | 1796 local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id) |
| 1807 Debug("GUID: %s - Type:ID: %s - Amount: %d (%d)", loot_info[loot_index], source_key, loot_quantity, slot_quantity) | 1797 Debug("GUID: %s - Type:ID: %s - Amount: %d (%d)", loot_info[loot_index], source_key, loot_info[loot_index + 1], slot_quantity) |
| 1808 | 1798 |
| 1809 if slot_type == _G.LOOT_SLOT_ITEM then | 1799 if slot_type == _G.LOOT_SLOT_ITEM then |
| 1810 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot)) | 1800 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot)) |
| 1811 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} | 1801 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} |
| 1812 current_loot.sources[source_guid][item_id] = current_loot.sources[source_guid][item_id] or 0 + slot_quantity | 1802 current_loot.sources[source_guid][item_id] = current_loot.sources[source_guid][item_id] or 0 + loot_quantity |
| 1813 guids_used[source_guid] = true | 1803 guids_used[source_guid] = true |
| 1814 elseif slot_type == _G.LOOT_SLOT_MONEY then | 1804 elseif slot_type == _G.LOOT_SLOT_MONEY then |
| 1815 if current_loot.target_type == AF.OBJECT then | 1805 Debug("money:%d", loot_quantity) |
| 1816 Debug("money:%d", _toCopper(item_text)) | 1806 if current_loot.target_type == AF.ZONE then |
| 1807 table.insert(current_loot.list, ("money:%d"):format(_toCopper(item_text))) | |
| 1808 else | |
| 1817 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} | 1809 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} |
| 1818 current_loot.sources[source_guid]["money"] = current_loot.sources[source_guid]["money"] or 0 + _toCopper(item_text) | 1810 current_loot.sources[source_guid]["money"] = current_loot.sources[source_guid]["money"] or 0 + loot_quantity |
| 1819 else | 1811 guids_used[source_guid] = true |
| 1820 Debug("money:%d", _toCopper(item_text)) | |
| 1821 table.insert(current_loot.list, ("money:%d"):format(_toCopper(item_text))) | |
| 1822 end | 1812 end |
| 1823 elseif slot_type == _G.LOOT_SLOT_CURRENCY then | 1813 elseif slot_type == _G.LOOT_SLOT_CURRENCY then |
| 1824 if current_loot.target_type == AF.OBJECT then | 1814 Debug("Found currency - %s:%d", icon_texture, loot_quantity) |
| 1815 if current_loot.target_type == AF.ZONE then | |
| 1816 table.insert(current_loot.list, ("currency:%d:%s"):format(slot_quantity, icon_texture:match("[^\\]+$"):lower())) | |
| 1817 else | |
| 1825 local currency_token = ("currency:%s"):format(icon_texture:match("[^\\]+$"):lower()) | 1818 local currency_token = ("currency:%s"):format(icon_texture:match("[^\\]+$"):lower()) |
| 1826 Debug("Found currency: %s", icon_texture) | |
| 1827 | 1819 |
| 1828 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} | 1820 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} |
| 1829 current_loot.sources[source_guid][currency_token] = current_loot.sources[source_guid][currency_token] or 0 + slot_quantity | 1821 current_loot.sources[source_guid][currency_token] = current_loot.sources[source_guid][currency_token] or 0 + loot_quantity |
| 1830 else | 1822 guids_used[source_guid] = true |
| 1831 Debug("Found currency: %s", icon_texture) | |
| 1832 table.insert(current_loot.list, ("currency:%d:%s"):format(slot_quantity, icon_texture:match("[^\\]+$"):lower())) | |
| 1833 end | 1823 end |
| 1834 end | 1824 end |
| 1835 end | 1825 end |
| 1836 end | 1826 end |
| 1837 end | 1827 end |
| 2007 table.wipe(current_action) | 1997 table.wipe(current_action) |
| 2008 end | 1998 end |
| 2009 | 1999 |
| 2010 | 2000 |
| 2011 function WDP:PET_JOURNAL_LIST_UPDATE(event_name) | 2001 function WDP:PET_JOURNAL_LIST_UPDATE(event_name) |
| 2002 -- this function produces data currently unused by wowdb.com and it makes debugging errors in the .lua output nearly impossible due to the massive bloat | |
| 2003 if DEBUGGING then | |
| 2004 return | |
| 2005 end | |
| 2006 | |
| 2012 local num_pets = LPJ:NumPets() | 2007 local num_pets = LPJ:NumPets() |
| 2013 | 2008 |
| 2014 for index, pet_id in LPJ:IteratePetIDs() do | 2009 for index, pet_id in LPJ:IteratePetIDs() do |
| 2015 local _, _, is_owned, _, level, _, _, name, icon, pet_type, npc_id, _, _, is_wild = _G.C_PetJournal.GetPetInfoByIndex(index) | 2010 local _, _, is_owned, _, level, _, _, name, icon, pet_type, npc_id, _, _, is_wild = _G.C_PetJournal.GetPetInfoByIndex(index) |
| 2016 | 2011 |
