From 9600dd40e3701770f607bc7cd2f89cab9b62d463 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 20 Mar 2026 05:01:21 -0700 Subject: [PATCH] fix: correct CMSG_EQUIPMENT_SET_USE packet format The packet previously sent only a uint32 setId, which does not match the WotLK protocol. AzerothCore/TrinityCore expect 19 iterations of (PackedGuid itemGuid + uint8 srcBag + uint8 srcSlot). Now looks up the equipment set's target item GUIDs and searches equipment, backpack, and extra bags to provide correct source locations for each item. --- src/game/game_handler.cpp | 53 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 583d4599..a9ed7a4b 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -10676,11 +10676,58 @@ void GameHandler::sendRequestVehicleExit() { } void GameHandler::useEquipmentSet(uint32_t setId) { - if (state != WorldState::IN_WORLD) return; - // CMSG_EQUIPMENT_SET_USE: uint32 setId + if (state != WorldState::IN_WORLD || !socket) return; + // Find the equipment set to get target item GUIDs per slot + const EquipmentSet* es = nullptr; + for (const auto& s : equipmentSets_) { + if (s.setId == setId) { es = &s; break; } + } + if (!es) { + addUIError("Equipment set not found."); + return; + } + // CMSG_EQUIPMENT_SET_USE: 19 × (PackedGuid itemGuid + uint8 srcBag + uint8 srcSlot) network::Packet pkt(wireOpcode(Opcode::CMSG_EQUIPMENT_SET_USE)); - pkt.writeUInt32(setId); + for (int slot = 0; slot < 19; ++slot) { + uint64_t itemGuid = es->itemGuids[slot]; + MovementPacket::writePackedGuid(pkt, itemGuid); + uint8_t srcBag = 0xFF; + uint8_t srcSlot = 0; + if (itemGuid != 0) { + bool found = false; + // Check if item is already in an equipment slot + for (int eq = 0; eq < 19 && !found; ++eq) { + if (getEquipSlotGuid(eq) == itemGuid) { + srcBag = 0xFF; // INVENTORY_SLOT_BAG_0 + srcSlot = static_cast(eq); + found = true; + } + } + // Check backpack (slots 23-38 in the body container) + for (int bp = 0; bp < 16 && !found; ++bp) { + if (getBackpackItemGuid(bp) == itemGuid) { + srcBag = 0xFF; + srcSlot = static_cast(23 + bp); + found = true; + } + } + // Check extra bags (bag indices 19-22) + for (int bag = 0; bag < 4 && !found; ++bag) { + int bagSize = inventory.getBagSize(bag); + for (int s = 0; s < bagSize && !found; ++s) { + if (getBagItemGuid(bag, s) == itemGuid) { + srcBag = static_cast(19 + bag); + srcSlot = static_cast(s); + found = true; + } + } + } + } + pkt.writeUInt8(srcBag); + pkt.writeUInt8(srcSlot); + } socket->send(pkt); + LOG_INFO("CMSG_EQUIPMENT_SET_USE: setId=", setId); } void GameHandler::saveEquipmentSet(const std::string& name, const std::string& iconName,