From 7b5e378c3672e34d96b21c161dccc8f7943f73ba Mon Sep 17 00:00:00 2001 From: kokekanon <114332266+kokekanon@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:10:51 -0400 Subject: [PATCH 1/2] fix: packet protocol 11.00 --- src/server/network/protocol/protocolgame.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index ca6f1f77961..73aae6b8b38 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -4954,7 +4954,11 @@ void ProtocolGame::sendSaleItemList(const std::vector &shopVector, co } msg.setBufferPosition(msgPosition); - msg.add(itemsToSend); + if (oldProtocol) { + msg.addByte(itemsToSend); + } else { + msg.add(itemsToSend); + } writeToOutputBuffer(msg); } From 15391eb06c68e3750cca8dada8593dea619c86b7 Mon Sep 17 00:00:00 2001 From: kokekanon <114332266+kokekanon@users.noreply.github.com> Date: Wed, 21 Aug 2024 21:39:52 -0400 Subject: [PATCH 2/2] Review luan --- src/server/network/protocol/protocolgame.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 73aae6b8b38..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,7 +4948,7 @@ 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; } } @@ -4955,7 +4956,7 @@ void ProtocolGame::sendSaleItemList(const std::vector &shopVector, co msg.setBufferPosition(msgPosition); if (oldProtocol) { - msg.addByte(itemsToSend); + msg.addByte(static_cast(itemsToSend)); } else { msg.add(itemsToSend); }