# HG changeset patch # User yellowfive # Date 1557191116 25200 # Node ID f27a7c64b21f68b37982d819a3c92daa45a73345 # Parent f66108c1f6744250cb8b137b58a42c37ea635e36 Tweaks to item matching in junk list features. diff -r f66108c1f674 -r f27a7c64b21f Import.lua --- a/Import.lua Mon May 06 17:06:26 2019 -0700 +++ b/Import.lua Mon May 06 18:05:16 2019 -0700 @@ -485,7 +485,7 @@ -- Junk is a simple list of items to discard, in the desired display order Amr.db.char.JunkData.Junk = parseItemList(parts, junkStartPos, "n/a", false) - + -- extra information contains extra enchant info if #data1 >= 3 then parts = { strsplit("@", data1[3]) } diff -r f66108c1f674 -r f27a7c64b21f Junk.lua --- a/Junk.lua Mon May 06 17:06:26 2019 -0700 +++ b/Junk.lua Mon May 06 18:05:16 2019 -0700 @@ -25,6 +25,10 @@ usedItems[bagId] = {} end + local bestMatchDiffs = 1000000 + local bestMatch = nil + local threshold + for slotId = 1, numSlots do if not usedItems[bagId][slotId] then local _, itemCount, _, _, _, _, itemLink = GetContainerItemInfo(bagId, slotId) @@ -41,18 +45,39 @@ end -- see if it matches - if Amr.CountItemDifferences(matchItem, itemData) == 0 then + local diffs = Amr.CountItemDifferences(matchItem, itemData) + if diffs == 0 then usedItems[bagId][slotId] = true itemData.bagId = bagId itemData.slotId = slotId return itemData + elseif diffs < 10000 then + if itemData.azerite and #itemData.azerite > 0 then + threshold = 100 + else + threshold = 10000 + end + if diffs < threshold and diffs < bestMatchDiffs then + -- closest match we could find + bestMatchDiffs = diffs + itemData.bagId = bagId + itemData.slotId = slotId + bestMatch = itemData + end end end end end end - - return nil + + -- if we couldn't get a perfect match, take the best match that might have some small differences like + -- an old school enchant or upgrade ID that didn't load + if bestMatch then + usedItems[bestMatch.bagId][bestMatch.slotId] = true + return bestMatch + else + return nil + end end -- @@ -406,6 +431,10 @@ end -- check bank data + local bestMatchDiffs = 100000 + local bestMatch = nil + local threshold + if Amr.db.char.BankItems then for bagId, v in pairs(Amr.db.char.BankItems) do if not usedItems[bagId] then @@ -415,18 +444,39 @@ for i, itemData in ipairs(v) do if itemData and not usedItems[bagId][i] then -- see if it matches - if Amr.CountItemDifferences(matchItem, itemData) == 0 then + local diffs = Amr.CountItemDifferences(matchItem, itemData) + if diffs == 0 then usedItems[bagId][i] = true itemData.bagId = bagId itemData.slotId = i return itemData + elseif diffs < 10000 then + if itemData.azerite and #itemData.azerite > 0 then + threshold = 100 + else + threshold = 10000 + end + if diffs < threshold and diffs < bestMatchDiffs then + -- closest match we could find + bestMatchDiffs = diffs + itemData.bagId = bagId + itemData.slotId = i + bestMatch = itemData + end end end end end end - return nil + -- if we couldn't get a perfect match, take the best match that might have some small differences like + -- an old school enchant or upgrade ID that didn't load + if bestMatch then + usedItems[bestMatch.bagId][bestMatch.slotId] = true + return bestMatch + else + return nil + end end local function renderItem(item, itemLink, scroll)