comparison AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 191:4aeedce4c995 v93

Added better identification of duplicate items.
author yellowfive
date Fri, 30 Oct 2020 21:14:57 -0700
parents 21a69c63fee8
children cb7eb9b9cc24
comparison
equal deleted inserted replaced
190:4232d073a90b 191:4aeedce4c995
1 -- AskMrRobot-Serializer will serialize and communicate character data between users. 1 -- AskMrRobot-Serializer will serialize and communicate character data between users.
2 2
3 local MAJOR, MINOR = "AskMrRobot-Serializer", 92 3 local MAJOR, MINOR = "AskMrRobot-Serializer", 93
4 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) 4 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
5 5
6 if not Amr then return end -- already loaded by something else 6 if not Amr then return end -- already loaded by something else
7 7
8 -- event and comm used for player snapshotting on entering combat 8 -- event and comm used for player snapshotting on entering combat
427 ]] 427 ]]
428 428
429 -- get currently equipped items, store with currently active spec 429 -- get currently equipped items, store with currently active spec
430 local function readEquippedItems(ret) 430 local function readEquippedItems(ret)
431 local equippedItems = {}; 431 local equippedItems = {};
432 local loc = ItemLocation.CreateEmpty() 432 --local loc = ItemLocation.CreateEmpty()
433 local item
433 for slotNum = 1, #Amr.SlotIds do 434 for slotNum = 1, #Amr.SlotIds do
434 local slotId = Amr.SlotIds[slotNum] 435 local slotId = Amr.SlotIds[slotNum]
435 local itemLink = GetInventoryItemLink("player", slotId) 436 local itemLink = GetInventoryItemLink("player", slotId)
436 if itemLink then 437 if itemLink then
437 local itemData = Amr.ParseItemLink(itemLink) 438 local itemData = Amr.ParseItemLink(itemLink)
438 if itemData then 439 if itemData then
440 item = Item:CreateFromEquipmentSlot(slotId)
441
442 -- seems to be of the form Item-1147-0-4000000XXXXXXXXX, so we take just the last 9 digits
443 itemData.guid = item:GetItemGUID()
444 if itemData.guid and strlen(itemData.guid) > 9 then
445 itemData.guid = strsub(itemData.guid, -9)
446 end
447
439 --[[ 448 --[[
440 -- see if this is an azerite item and read azerite power ids 449 -- see if this is an azerite item and read azerite power ids
441 loc:SetEquipmentSlot(slotId) 450 loc:SetEquipmentSlot(slotId)
442 if C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(loc) then 451 if C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem(loc) then
443 local powers = Amr.ReadAzeritePowers(loc) 452 local powers = Amr.ReadAzeritePowers(loc)
571 local prevUpgradeId = 0 580 local prevUpgradeId = 0
572 local prevBonusId = 0 581 local prevBonusId = 0
573 local prevLevel = 0 582 local prevLevel = 0
574 --local prevAzeriteId = 0 583 --local prevAzeriteId = 0
575 local prevRelicBonusId = 0 584 local prevRelicBonusId = 0
585
576 for i, itemData in ipairs(itemObjects) do 586 for i, itemData in ipairs(itemObjects) do
577 local itemParts = {} 587 local itemParts = {}
578 588
579 table.insert(itemParts, itemData.id - prevItemId) 589 table.insert(itemParts, itemData.id - prevItemId)
580 prevItemId = itemData.id 590 prevItemId = itemData.id
640 if itemData.relicBonusIds and itemData.relicBonusIds[3] ~= nil then 650 if itemData.relicBonusIds and itemData.relicBonusIds[3] ~= nil then
641 for bIndex, bValue in ipairs(itemData.relicBonusIds[3]) do 651 for bIndex, bValue in ipairs(itemData.relicBonusIds[3]) do
642 table.insert(itemParts, "r" .. (bValue - prevRelicBonusId)) 652 table.insert(itemParts, "r" .. (bValue - prevRelicBonusId))
643 prevRelicBonusId = bValue 653 prevRelicBonusId = bValue
644 end 654 end
655 end
656
657 if itemData.guid then
658 table.insert(itemParts, "!" .. itemData.guid)
645 end 659 end
646 660
647 table.insert(fields, table.concat(itemParts, "")) 661 table.insert(fields, table.concat(itemParts, ""))
648 end 662 end
649 end 663 end