# HG changeset patch # User James D. Callahan III # Date 1345659621 18000 # Node ID 376d3e03d632906164694dd599be704c8520eaae # Parent 7179e2938324ee7c07f8b0d28dd2c4c404273b37 Ignore loot_list if empty. Hold NPC GUIDs in a loot registry to avoid recording the same NPC loot multiple times. diff -r 7179e2938324 -r 376d3e03d632 Main.lua --- a/Main.lua Wed Aug 22 12:49:42 2012 -0500 +++ b/Main.lua Wed Aug 22 13:20:21 2012 -0500 @@ -434,7 +434,7 @@ end end -- TODO: Remove this when GetLootSourceInfo() has values for money - if action_data.type == AF.OBJECT then + if #action_data.loot_list <= 0 or action_data.type == AF.OBJECT then -- Unfortunately, this means we can't record money from chests... return end @@ -882,6 +882,9 @@ end -- TODO: Remove this when GetLootSourceInfo() has values for money + if #action_data.loot_list <= 0 then + return + end local npc = NPCEntry(action_data.identifier) if not npc then @@ -920,6 +923,8 @@ end, } + -- Prevent opening the same loot window multiple times from recording data multiple times. + local loot_guid_registry = {} function WDP:LOOT_OPENED() if action_data.looting then @@ -959,15 +964,19 @@ -- Odd index is GUID, even is count. for loot_index = 1, #loot_info, 2 do local source_guid = loot_info[loot_index] - local loot_quantity = loot_info[loot_index + 1] - local source_type, source_id = ParseGUID(source_guid) - -- TODO: Remove debugging - -- local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id) - -- print(("GUID: %s - Type:ID: %s - Amount: %d"):format(loot_info[loot_index], source_key, loot_quantity)) - local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot)) - action_data.loot_sources[source_guid] = action_data.loot_sources[source_guid] or {} - action_data.loot_sources[source_guid][item_id] = action_data.loot_sources[source_guid][item_id] or 0 + loot_quantity + if not loot_guid_registry[source_guid] then + local loot_quantity = loot_info[loot_index + 1] + local source_type, source_id = ParseGUID(source_guid) + -- TODO: Remove debugging + -- local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id) + -- print(("GUID: %s - Type:ID: %s - Amount: %d"):format(loot_info[loot_index], source_key, loot_quantity)) + + local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot)) + action_data.loot_sources[source_guid] = action_data.loot_sources[source_guid] or {} + action_data.loot_sources[source_guid][item_id] = action_data.loot_sources[source_guid][item_id] or 0 + loot_quantity + loot_guid_registry[source_guid] = true + end end elseif slot_type == _G.LOOT_SLOT_MONEY then table.insert(action_data.loot_list, ("money:%d"):format(_toCopper(item_text)))