diff Gear.lua @ 200:6e8838b231d4 v97

Fixed issue with distinguishing different variants of the same item.
author Yellowfive
date Wed, 13 Jan 2021 13:11:54 -0600
parents 4ccc9ff6e824
children
line wrap: on
line diff
--- a/Gear.lua	Tue Dec 22 11:10:25 2020 -0600
+++ b/Gear.lua	Wed Jan 13 13:11:54 2021 -0600
@@ -32,16 +32,20 @@
 		return 1000000 
 	end
 	
-    -- different versions of same item (id + bonus ids + suffix + drop level, constitutes a different physical drop)
-    if Amr.GetItemUniqueId(item1, true, true) ~= Amr.GetItemUniqueId(item2, true, true) then
-		return 100000
-    end
-    
-    -- different upgrade levels of the same item
-    if item1.upgradeId ~= item2.upgradeId then
-        return 10000
-	end
-	
+	--if item1.guid and item2.guid and item1.guid == item2.guid then
+	--	-- these have the same guid, so even if bonus id or something doesn't match for some reason, they are identical items
+	--else
+		-- different versions of same item (id + bonus ids + suffix + drop level, constitutes a different physical drop)
+		if Amr.GetItemUniqueId(item1, true, true) ~= Amr.GetItemUniqueId(item2, true, true) then
+			return 100000
+		end
+		
+		-- different upgrade levels of the same item
+		if item1.upgradeId ~= item2.upgradeId then
+			return 10000
+		end
+	--end
+
 	-- a change that requires reforging is considered more different than a change that does not;
 	-- it is assumed that item1 is how we want the item to be in the end, and item2 is how it currently is
 	local aztReforges = 0
@@ -118,6 +122,7 @@
 	for k,listItem in pairs(list) do		
 		if listItem then
 			local diff = countItemDifferences(item, listItem)
+
 			if diff < bestDiff then
 				-- each physical item can only be used once, the usedItems table has items we can't use in this search
 				local key = string.format("%s_%s", tableType, k)
@@ -125,10 +130,10 @@
 					bestItem = listItem
 					bestDiff = diff
 					bestLoc = key
-					found = true
 				end
 			end
-			if found then break end
+
+			if bestDiff == 0 then break end
 		end
 	end
 	
@@ -1155,6 +1160,7 @@
 				local diff = countItemDifferences(new, old)				
 
 				if diff > 0 then
+
 					list[slotId] = new
 					if list == itemsToEquip.mh or list == itemsToEquip.oh then
 						itemsToEquip.weapons[slotId] = {}