From 367b48af6b6350b85ab9a39cabb3b5e2285c9129 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Fri, 13 Mar 2026 01:29:21 -0700 Subject: [PATCH] fix: handle short loot-failure response in LootResponseParser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Servers send a 9-byte packet (guid+lootType) with lootType=LOOT_NONE when loot is unavailable (locked chest, another player looting, needs a key). The previous parser required ≥14 bytes (guid+lootType+gold+itemCount) and logged a spurious WARNING for every such failure response. Now: - Accept the 9-byte form; return false so the caller skips opening the loot window (correct behaviour for a failure/empty response). - Log at DEBUG level instead of WARNING for the short form. - Keep the original WARNING for genuinely malformed packets < 9 bytes. --- src/game/world_packets.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/game/world_packets.cpp b/src/game/world_packets.cpp index e2fb3772..e183ff16 100644 --- a/src/game/world_packets.cpp +++ b/src/game/world_packets.cpp @@ -3971,13 +3971,27 @@ network::Packet LootReleasePacket::build(uint64_t lootGuid) { bool LootResponseParser::parse(network::Packet& packet, LootResponseData& data, bool isWotlkFormat) { data = LootResponseData{}; - if (packet.getSize() - packet.getReadPos() < 14) { - LOG_WARNING("LootResponseParser: packet too short"); + size_t avail = packet.getSize() - packet.getReadPos(); + + // Minimum is guid(8)+lootType(1) = 9 bytes. Servers send a short packet with + // lootType=0 (LOOT_NONE) when loot is unavailable (e.g. chest not yet opened, + // needs a key, or another player is looting). We treat this as an empty-loot + // signal and return false so the caller knows not to open the loot window. + if (avail < 9) { + LOG_WARNING("LootResponseParser: packet too short (", avail, " bytes)"); return false; } data.lootGuid = packet.readUInt64(); data.lootType = packet.readUInt8(); + + // Short failure packet — no gold/item data follows. + avail = packet.getSize() - packet.getReadPos(); + if (avail < 5) { + LOG_DEBUG("LootResponseParser: lootType=", (int)data.lootType, " (empty/failure response)"); + return false; + } + data.gold = packet.readUInt32(); uint8_t itemCount = packet.readUInt8();