Skip to content

Commit

Permalink
fix: wrong packet in protocol 11.00 (sendSaleItemList) (opentibiabr#2837
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kokekanon authored and s2leandro155 committed Sep 26, 2024
1 parent 8b248ec commit be253c8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4931,8 +4931,9 @@ void ProtocolGame::sendSaleItemList(const std::vector<ShopBlock> &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) {
Expand All @@ -4947,14 +4948,18 @@ void ProtocolGame::sendSaleItemList(const std::vector<ShopBlock> &shopVector, co
} else {
msg.add<uint16_t>(std::min<uint16_t>(it->second, std::numeric_limits<uint16_t>::max()));
}
if (++itemsToSend >= 0xFFFF) {
if (++itemsToSend >= ItemsToSendLimit) {
break;
}
}
}

msg.setBufferPosition(msgPosition);
msg.add<uint16_t>(itemsToSend);
if (oldProtocol) {
msg.addByte(static_cast<uint8_t>(itemsToSend));
} else {
msg.add<uint16_t>(itemsToSend);
}
writeToOutputBuffer(msg);
}

Expand Down

0 comments on commit be253c8

Please sign in to comment.