changeset 304:1e55a8ebedbd

Fixed double-counting for loot in items.
author James D. Callahan III <jcallahan@curse.com>
date Mon, 08 Jul 2013 13:26:23 -0500
parents e54e370e3a01
children 4986ef8a338a
files Main.lua
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Main.lua	Mon Jul 08 13:17:22 2013 -0500
+++ b/Main.lua	Mon Jul 08 13:26:23 2013 -0500
@@ -594,30 +594,28 @@
 
         if current_loot.sources then
             for source_guid, loot_data in pairs(current_loot.sources) do
-                local entry, source_id
+                local source_id
 
                 if current_loot.target_type == AF.ITEM then
                     -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc)
                     source_id = current_loot.identifier
-                    entry = DBEntry(data_type, source_id)
                 elseif current_loot.target_type == AF.OBJECT then
                     source_id = ("%s:%s"):format(current_loot.spell_label, select(2, ParseGUID(source_guid)))
-                    entry = DBEntry(data_type, source_id)
                 else
                     source_id = select(2, ParseGUID(source_guid))
-                    entry = DBEntry(data_type, source_id)
                 end
+                local entry = DBEntry(data_type, source_id)
 
                 if entry then
                     local loot_table = LootTable(entry, loot_type, top_field)
 
-                    if not source_list[source_guid] then
+                    if not source_list[source_id] then
                         if top_field then
                             entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
                         else
                             entry[loot_count] = (entry[loot_count] or 0) + 1
                         end
-                        source_list[source_guid] = true
+                        source_list[source_id] = true
                     end
                     UpdateDBEntryLocation(data_type, source_id)
 
@@ -652,6 +650,7 @@
             else
                 entry[loot_count] = (entry[loot_count] or 0) + 1
             end
+            source_list[current_loot.identifier] = true
         end
 
         for index = 1, #current_loot.list do