changeset 195:4ccc9ff6e824 v95

Update item parsing for new item link format changes.
author Yellowfive
date Tue, 24 Nov 2020 16:20:10 -0600
parents 02bbbf5ef3db
children b4f74de03b43
files AskMrRobot-Serializer/AskMrRobot-Serializer.lua AskMrRobot.toc Constants.lua Gear.lua Import.lua
diffstat 5 files changed, 92 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/AskMrRobot-Serializer/AskMrRobot-Serializer.lua	Wed Nov 11 23:58:39 2020 -0800
+++ b/AskMrRobot-Serializer/AskMrRobot-Serializer.lua	Tue Nov 24 16:20:10 2020 -0600
@@ -1,6 +1,6 @@
 -- AskMrRobot-Serializer will serialize and communicate character data between users.
 
-local MAJOR, MINOR = "AskMrRobot-Serializer", 94
+local MAJOR, MINOR = "AskMrRobot-Serializer", 95
 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
 if not Amr then return end -- already loaded by something else
@@ -156,21 +156,11 @@
 }
 
 Amr.InstanceIds = {
-	Uldir = 1861,
-	Dazar = 2070,
-	Storms = 2096,
-	Palace = 2164,
-	Nyalotha = 2217,
 	Nathria = 2296
 }
 
 -- instances that AskMrRobot currently supports logging for
 Amr.SupportedInstanceIds = {
-	[1861] = true,
-	[2070] = true,
-	[2096] = true,
-	[2164] = true,
-	[2217] = true,
 	[2296] = true
 }
 
@@ -188,10 +178,10 @@
 	return ret
 end
 
---                 1      2    3      4      5      6    7   8   9   10   11       12         
---                 itemId:ench:gem1  :gem2  :gem3  :gem4:suf:uid:lvl:spec:flags   :instdiffid:numbonusIDs:bonusIDs1...n     :varies:?:relic bonus ids
---|cffe6cc80|Hitem:128866:    :152046:147100:152025:    :   :   :110:66  :16777472:9         :4          :736:1494:1490:1495:709   :1:3:3610:1472:3528:3:3562:1483:3528:3:3610:1477:3336|h[Truthguard]|h|r
---
+--                 1      2    3      4      5      6    7   8   9   10   11       12         13                             14     15 16   17 18
+--                 itemId:ench:gem1  :gem2  :gem3  :gem4:suf:uid:lvl:spec:flags   :instdiffid:numbonusIDs:bonusIDs1...n     :varies:? :relic bonus ids
+--|cffe6cc80|Hitem:128866:    :152046:147100:152025:    :   :   :110:66  :16777472:9         :4          :736:1494:1490:1495:709   :1 :3:3610:1472:3528:3:3562:1483:3528:3:3610:1477:3336|h[Truthguard]|h|r
+--|cff1eff00|Hitem:175722:    :      :      :      :    :   :   :57 :102 :        :11        :1          :6707              :2     :28:1340:9 :54:::|h[name]|h|r
 -- get an object with all of the parts of the item link format that we care about
 function Amr.ParseItemLink(itemLink)
     if not itemLink then return nil end
@@ -222,19 +212,23 @@
 	
 	item.upgradeId = 0
 	item.level = 0
+	item.stat1 = 0
+	item.stat2 = 0
 
-	-- part 14 + numBonuses, unsure what this is... sometimes it is "2"
-	-- part 15 + numBonuses, unsure what this is... may indicate what part 16 will mean?
-	-- part 16 + numBonuses, is player level at drop when applicable
-	-- part 17 + numBonuses, unsure what this is...
-	-- part 18 + numBonuses, unsure what this is...
-	-- part 19 + numBonuses, relic info would be here for legion artifacts
-
-	local someNumber = tonumber(parts[15 + offset]) or 0
-	if someNumber ~= 0 then
-		local lvl = tonumber(parts[16 + offset]) or 0
-		if lvl <= 60 then
-			item.level = lvl
+	-- part 14 + numBonuses, seems to be the number of prop-value "pairs" that will follow,
+	-- for now we just parse the properties that we care about
+	local numProps = tonumber(parts[14 + offset]) or 0
+	if numProps > 0 then
+		for i = 15 + offset, 14 + offset + numProps * 2, 2 do
+			local prop = tonumber(parts[i]) or 0
+			local propVal = tonumber(parts[i + 1]) or 0
+			if prop == 9 then
+				item.level = propVal
+			elseif prop == 29 then
+				item.stat1 = propVal
+			elseif prop == 30 then
+				item.stat2 = propVal
+			end
 		end
 	end
 
@@ -291,9 +285,15 @@
     if not noUpgrade and item.upgradeId ~= 0 then
         ret = ret .. "u" .. item.upgradeId
     end
-	if item.level ~= 0 then
+	if item.level and item.level ~= 0 then
 		ret = ret .. "v" .. item.level
 	end
+	if item.stat1 and item.stat1 ~= 0 then
+		ret = ret .. "j" .. item.stat1
+	end
+	if item.stat2 and item.stat2 ~= 0 then
+		ret = ret .. "k" .. item.stat2
+	end
     return ret
 end
 
@@ -595,7 +595,7 @@
             table.insert(itemParts, "u" .. (itemData.upgradeId - prevUpgradeId))
             prevUpgradeId = itemData.upgradeId
         end
-		if itemData.level ~= 0 then
+		if itemData.level and itemData.level ~= 0 then
 			table.insert(itemParts, "v" .. (itemData.level - prevLevel))
 			prevLevel = itemData.level
 		end
@@ -606,6 +606,13 @@
             end
 		end
 		
+		if itemData.stat1 and itemData.stat1 ~= 0 then
+			table.insert(itemParts, "j" .. itemData.stat1)
+		end
+		if itemData.stat2 and itemData.stat2 ~= 0 then
+			table.insert(itemParts, "k" .. itemData.stat2)
+		end
+
 		--[[
 		if itemData.azerite then
 			for aIndex, aValue in ipairs(itemData.azerite) do
@@ -652,7 +659,7 @@
                 table.insert(itemParts, "r" .. (bValue - prevRelicBonusId))
                 prevRelicBonusId = bValue
             end
-		end
+		end		
 
 		if itemData.guid then
 			table.insert(itemParts, "!" .. itemData.guid)
--- a/AskMrRobot.toc	Wed Nov 11 23:58:39 2020 -0800
+++ b/AskMrRobot.toc	Tue Nov 24 16:20:10 2020 -0600
@@ -1,7 +1,7 @@
-## Interface: 90001
+## Interface: 90002
 ## Title: Ask Mr. Robot
 ## Author: Team Robot, Inc.
-## Version: 94
+## Version: 95
 ## Notes: Gear import/export, combat logging, and more.
 ## URL: www.askmrrobot.com
 ## SavedVariables: AskMrRobotDb4
--- a/Constants.lua	Wed Nov 11 23:58:39 2020 -0800
+++ b/Constants.lua	Tue Nov 24 16:20:10 2020 -0600
@@ -107,7 +107,7 @@
 }
 
 -- instance IDs ordered in preferred display order
-Amr.InstanceIdsOrdered = { 1861, 2070, 2096, 2164, 2217, 2296 }
+Amr.InstanceIdsOrdered = { 2296 }
 
 Amr.Difficulties = {
 	Lfr = 17,
@@ -129,7 +129,7 @@
 -- Item Methods
 ------------------------------------------------------------------------------------------
 
---                 1      2    3      4      5      6    7   8   9   10   11       12         
+--                 1      2    3      4      5      6    7   8   9   10   11       12         13
 --                 itemId:ench:gem1  :gem2  :gem3  :gem4:suf:uid:lvl:spec:flags   :instdiffid:numbonusIDs:bonusIDs1...n     :varies:?:relic bonus ids
 --|cffe6cc80|Hitem:128866:    :152046:147100:152025:    :   :   :110:66  :16777472:9         :4          :736:1494:1490:1495:709   :1:3:3610:1472:3528:3:3562:1483:3528:3:3610:1477:3336|h[Truthguard]|h|r
 --
@@ -162,6 +162,7 @@
 
     table.insert(parts, 0) -- difficulty id, doesn't matter
     
+    -- 13, num bonus ids
     if itemObj.bonusIds then
         table.insert(parts, #itemObj.bonusIds)
         for i,v in ipairs(itemObj.bonusIds) do
@@ -171,16 +172,42 @@
 		table.insert(parts, 0) -- no bonus ids
     end
     
+    --[[
+    if itemObj.upgradeId and itemObj.upgradeId ~= 0 then
+        -- figure this out (if we still care)
+    end]]
+    
+    -- 14 + bonus id count, number of "properties"
+    local propCount = 0
     if itemObj.level and itemObj.level ~= 0 then
-        table.insert(parts, 2) -- not sure if this is always 2 or not...
-        table.insert(parts, 9) -- not sure if this is always 9 or not...
-        table.insert(parts, itemObj.level)
-    elseif itemObj.upgradeId and itemObj.upgradeId ~= 0 then
-        -- figure this out (if we still care)
+        propCount = propCount + 1
     end
-    
-    -- we don't bother with relic bonus ids anymore when generating links
-    table.insert(parts, 0)
+    if itemObj.stat1 and itemObj.stat1 ~= 0 then
+        propCount = propCount + 1
+    end
+    if itemObj.stat2 and itemObj.stat2 ~= 0 then
+        propCount = propCount + 1
+    end
+
+    if propCount > 0 then
+        table.insert(parts, propCount)
+        if itemObj.level and itemObj.level ~= 0 then
+            table.insert(parts, 9)
+            table.insert(parts, itemObj.level)
+        end
+        if itemObj.stat1 and itemObj.stat1 ~= 0 then
+            table.insert(parts, 29)
+            table.insert(parts, itemObj.stat1)
+        end
+        if itemObj.stat2 and itemObj.stat2 ~= 0 then
+            table.insert(parts, 30)
+            table.insert(parts, itemObj.stat2)
+        end
+    else
+        table.insert(parts, 0) -- no props
+    end
+
+    -- these last 3 seem to be blank for most items...
     table.insert(parts, 0)
     table.insert(parts, 0)
     table.insert(parts, 0)
--- a/Gear.lua	Wed Nov 11 23:58:39 2020 -0800
+++ b/Gear.lua	Tue Nov 24 16:20:10 2020 -0600
@@ -688,13 +688,23 @@
 -- scan a bag for the best matching item
 local function scanBagForItem(item, bagId, bestItem, bestDiff, bestLink)
 	local numSlots = GetContainerNumSlots(bagId)
-	local loc = ItemLocation.CreateEmpty()
+	--local loc = ItemLocation.CreateEmpty()
+	local blizzItem
 	for slotId = 1, numSlots do
 		local _, _, _, _, _, _, itemLink = GetContainerItemInfo(bagId, slotId)
         -- we skip any stackable item, as far as we know, there is no equippable gear that can be stacked
 		if itemLink then
 			local bagItem = Amr.ParseItemLink(itemLink)
 			if bagItem ~= nil then
+
+				blizzItem = Item:CreateFromBagAndSlot(bagId, slotId)
+
+				-- seems to be of the form Item-1147-0-4000000XXXXXXXXX, so we take just the last 9 digits
+				bagItem.guid = blizzItem:GetItemGUID()
+				if bagItem.guid and strlen(bagItem.guid) > 9 then
+					bagItem.guid = strsub(bagItem.guid, -9)
+				end
+
 				-- see if this is an azerite item and read azerite power ids
 				--[[loc:SetBagAndSlot(bagId, slotId)
 				if C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(loc) then
@@ -1140,11 +1150,11 @@
 
 				-- find the best matching item anywhere in the player's gear
 				local bestItem, bestDiff = Amr:FindMatchingItem(new, player, usedItems)
+				
 				new = bestItem
-
 				local diff = countItemDifferences(new, old)				
 
-				if diff > 0 then	
+				if diff > 0 then
 					list[slotId] = new
 					if list == itemsToEquip.mh or list == itemsToEquip.oh then
 						itemsToEquip.weapons[slotId] = {}
--- a/Import.lua	Wed Nov 11 23:58:39 2020 -0800
+++ b/Import.lua	Tue Nov 24 16:20:10 2020 -0600
@@ -231,7 +231,9 @@
             obj.id = tokens["i"]
             obj.suffixId = tokens["f"] or 0
             obj.upgradeId = tokens["u"] or 0
-			obj.level = tokens["v"] or 0
+            obj.level = tokens["v"] or 0
+            obj.stat1 = tokens["j"] or 0
+            obj.stat2 = tokens["k"] or 0
             obj.enchantId = tokens["e"] or 0
 			obj.inventoryId = tokens["t"] or 0