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.
This commit is contained in:
Kelsi 2026-03-11 04:49:18 -07:00
parent ed48a3c425
commit dd67c88175
2 changed files with 8 additions and 3 deletions

View file

@ -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);
}

View file

@ -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;
}