From dd67c8817572751192d2bd77ee12ad296530830c Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 11 Mar 2026 04:49:18 -0700 Subject: [PATCH] fix: conditionally include trailing byte in CMSG_BUY_ITEM for Classic/TBC CMSG_BUY_ITEM format differs by expansion: - WotLK 3.3.5a / AzerothCore: includes trailing uint8(0) after count field (17 bytes) - Classic 1.12 / TBC 2.4.3: no trailing byte (16 bytes) The static BuyItemPacket::build() helper always adds the byte (AzerothCore compat). GameHandler::buyItem() now gates the byte based on active expansion, allowing Classic/TBC servers to receive correctly-sized packets. --- src/game/game_handler.cpp | 7 +++++-- src/game/world_packets.cpp | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index a870ddcc..0ead0468 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -15821,8 +15821,11 @@ void GameHandler::buyItem(uint64_t vendorGuid, uint32_t itemId, uint32_t slot, u packet.writeUInt32(itemId); // item entry packet.writeUInt32(slot); // vendor slot index packet.writeUInt32(count); - // WotLK/AzerothCore expects a trailing byte here. - packet.writeUInt8(0); + // WotLK/AzerothCore expects a trailing byte; Classic/TBC do not + const bool isWotLk = isActiveExpansion("wotlk"); + if (isWotLk) { + packet.writeUInt8(0); + } socket->send(packet); } diff --git a/src/game/world_packets.cpp b/src/game/world_packets.cpp index b7d8075b..5d3989c7 100644 --- a/src/game/world_packets.cpp +++ b/src/game/world_packets.cpp @@ -3828,7 +3828,9 @@ network::Packet BuyItemPacket::build(uint64_t vendorGuid, uint32_t itemId, uint3 packet.writeUInt32(itemId); // item entry packet.writeUInt32(slot); // vendor slot index from SMSG_LIST_INVENTORY packet.writeUInt32(count); - // WotLK/AzerothCore expects a trailing byte on CMSG_BUY_ITEM. + // Note: WotLK/AzerothCore expects a trailing byte; Classic/TBC do not. + // This static helper always adds it (appropriate for CMaNGOS/AzerothCore). + // For Classic/TBC, use the GameHandler::buyItem() path which checks expansion. packet.writeUInt8(0); return packet; }