From c73c5612bc816ca6152131eb4216193e9f9b0d58 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Wed, 8 Mar 2023 11:51:46 -0300 Subject: [PATCH] Open raid lib update --- Libs/LibOpenRaid/GetPlayerInformation.lua | 2 +- Libs/LibOpenRaid/LibOpenRaid.lua | 25 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Libs/LibOpenRaid/GetPlayerInformation.lua b/Libs/LibOpenRaid/GetPlayerInformation.lua index 8be233f1..1c84aa46 100644 --- a/Libs/LibOpenRaid/GetPlayerInformation.lua +++ b/Libs/LibOpenRaid/GetPlayerInformation.lua @@ -335,7 +335,7 @@ function openRaidLib.GearManager.GetPlayerWeaponEnchant() elseif(LIB_OPEN_RAID_WEAPON_ENCHANT_IDS[offHandEnchantId]) then weaponEnchant = 1 end - return weaponEnchant + return weaponEnchant, mainHandEnchantId or 0, offHandEnchantId or 0 end function openRaidLib.GearManager.GetPlayerGemsAndEnchantInfo() diff --git a/Libs/LibOpenRaid/LibOpenRaid.lua b/Libs/LibOpenRaid/LibOpenRaid.lua index e3fd0160..d359dd33 100644 --- a/Libs/LibOpenRaid/LibOpenRaid.lua +++ b/Libs/LibOpenRaid/LibOpenRaid.lua @@ -1588,7 +1588,7 @@ openRaidLib.internalCallback.RegisterCallback("onLeaveCombat", openRaidLib.UnitI local specMainAttribute = openRaidLib.specAttribute[playerClass][specId] --1 int, 2 dex, 3 str if (not specId or not specMainAttribute) then - return {0, 0, 0, {}, {}, {}} + return {0, 0, 0, {}, {}, {}, 0, 0} end --item level @@ -1598,7 +1598,7 @@ openRaidLib.internalCallback.RegisterCallback("onLeaveCombat", openRaidLib.UnitI local gearDurability = openRaidLib.GearManager.GetPlayerGearDurability() --get weapon enchant - local weaponEnchant = openRaidLib.GearManager.GetPlayerWeaponEnchant() + local weaponEnchant, mainHandEnchantId, offHandEnchantId = openRaidLib.GearManager.GetPlayerWeaponEnchant() --enchants and gems local slotsWithoutGems, slotsWithoutEnchant = openRaidLib.GearManager.GetPlayerGemsAndEnchantInfo() @@ -1614,12 +1614,14 @@ openRaidLib.internalCallback.RegisterCallback("onLeaveCombat", openRaidLib.UnitI playerGearInfo[#playerGearInfo+1] = slotsWithoutEnchant --[4] - undefined playerGearInfo[#playerGearInfo+1] = slotsWithoutGems --[5] - undefined playerGearInfo[#playerGearInfo+1] = equippedGearList --[6] - undefined + playerGearInfo[#playerGearInfo+1] = mainHandEnchantId --[7] + playerGearInfo[#playerGearInfo+1] = offHandEnchantId --[8] return playerGearInfo end --when received the gear update from another player, store it and trigger a callback - function openRaidLib.GearManager.AddUnitGearList(unitName, itemLevel, durability, weaponEnchant, noEnchantTable, noGemsTable, equippedGearList) + function openRaidLib.GearManager.AddUnitGearList(unitName, itemLevel, durability, weaponEnchant, noEnchantTable, noGemsTable, equippedGearList, mainHandEnchantId, offHandEnchantId) local unitGearInfo = openRaidLib.GearManager.GetUnitGear(unitName, true) unitGearInfo.ilevel = itemLevel @@ -1627,6 +1629,8 @@ openRaidLib.internalCallback.RegisterCallback("onLeaveCombat", openRaidLib.UnitI unitGearInfo.weaponEnchant = weaponEnchant unitGearInfo.noGems = noGemsTable unitGearInfo.noEnchants = noEnchantTable + unitGearInfo.mainHandEnchantId = mainHandEnchantId + unitGearInfo.offHandEnchantId = offHandEnchantId --parse and replace the 'equippedGearList' openRaidLib.GearManager.BuildEquipmentItemLinks(equippedGearList) @@ -1649,7 +1653,16 @@ openRaidLib.internalCallback.RegisterCallback("onLeaveCombat", openRaidLib.UnitI local noGemsTableSize = data[noGemsTableIndex] local equippedGearListIndex = tonumber(noEnchantTableSize + noGemsTableSize + 6) --6 is the same has the 5 but +1 index for the gems table size - --local equippedGearListSize = data[noGemsTableIndex] + + local equippedGearListSize = data[equippedGearListIndex] + + local mainHandEnchantId, offHandEnchantId = 0, 0 + if equippedGearListSize then + local mainHandEnchantIdIndex = tonumber(noEnchantTableSize + noGemsTableSize + equippedGearListSize + 7) + mainHandEnchantId = tonumber(data[mainHandEnchantIdIndex]) or 0 + local offHandEnchantIdIndex = tonumber(mainHandEnchantIdIndex + 1) + offHandEnchantId = tonumber(data[offHandEnchantIdIndex]) or 0 + end --unpack the enchant data as a ipairs table local noEnchantTableUnpacked = openRaidLib.UnpackTable(data, 4, false, false, noEnchantTableSize) @@ -1659,7 +1672,7 @@ openRaidLib.internalCallback.RegisterCallback("onLeaveCombat", openRaidLib.UnitI local equippedGearListUnpacked = equippedGearListIndex and openRaidLib.UnpackTable(data, equippedGearListIndex, false, true, 4) or {} --add to the list of gear information - openRaidLib.GearManager.AddUnitGearList(unitName, itemLevel, durability, weaponEnchant, noEnchantTableUnpacked, noGemsTableUnpacked, equippedGearListUnpacked) + openRaidLib.GearManager.AddUnitGearList(unitName, itemLevel, durability, weaponEnchant, noEnchantTableUnpacked, noGemsTableUnpacked, equippedGearListUnpacked, mainHandEnchantId, offHandEnchantId) end openRaidLib.commHandler.RegisterComm(CONST_COMM_GEARINFO_FULL_PREFIX, openRaidLib.GearManager.OnReceiveGearFullInfo) @@ -1673,6 +1686,8 @@ openRaidLib.internalCallback.RegisterCallback("onLeaveCombat", openRaidLib.UnitI --[4] table with integers of equipSlot without enchant --[5] table with integers of equipSlot which has a gem slot but the slot is empty --[6] table with all gear from the player + --[7] int mainHandEnchantId + --[8] int offHandEnchantId local dataToSend = "" .. CONST_COMM_GEARINFO_FULL_PREFIX .. "," local playerGearInfo = openRaidLib.GearManager.GetPlayerFullGearInfo()