diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index ca6f1f77961..032b9b512d0 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -4931,8 +4931,9 @@ void ProtocolGame::sendSaleItemList(const std::vector &shopVector, co } uint16_t itemsToSend = 0; + const uint16_t ItemsToSendLimit = oldProtocol ? 0xFF : 0xFFFF; auto msgPosition = msg.getBufferPosition(); - msg.skipBytes(2); + msg.skipBytes(oldProtocol ? 1 : 2); for (const ShopBlock &shopBlock : shopVector) { if (shopBlock.itemSellPrice == 0) { @@ -4947,14 +4948,18 @@ void ProtocolGame::sendSaleItemList(const std::vector &shopVector, co } else { msg.add(std::min(it->second, std::numeric_limits::max())); } - if (++itemsToSend >= 0xFFFF) { + if (++itemsToSend >= ItemsToSendLimit) { break; } } } msg.setBufferPosition(msgPosition); - msg.add(itemsToSend); + if (oldProtocol) { + msg.addByte(static_cast(itemsToSend)); + } else { + msg.add(itemsToSend); + } writeToOutputBuffer(msg); }