Update StarNetPacketSocket.cpp

This commit is contained in:
Kae 2024-07-27 18:56:16 +10:00
parent a5788e7585
commit 0ec199b3af

View File

@ -371,14 +371,14 @@ void P2PPacketSocket::sendPackets(List<PacketPtr> packets) {
if (compressionStreamEnabled()) { if (compressionStreamEnabled()) {
DataStreamBuffer outBuffer; DataStreamBuffer outBuffer;
while (it.hasNext()) { while (it.hasNext()) {
PacketPtr& packet = it.next(); PacketType currentType = it.peekNext()->type();
auto packetType = packet->type();
DataStreamBuffer packetBuffer; DataStreamBuffer packetBuffer;
packet->write(packetBuffer); while (it.hasNext() && it.peekNext()->type() == currentType)
outBuffer.write(packetType); it.next()->write(packetBuffer);
outBuffer.writeVlqI((int)packetBuffer.size()); outBuffer.write(currentType);
outBuffer.write<bool>(false);
outBuffer.writeData(packetBuffer.ptr(), packetBuffer.size()); outBuffer.writeData(packetBuffer.ptr(), packetBuffer.size());
m_outgoingStats.mix(packetType, packetBuffer.size(), false); m_outgoingStats.mix(currentType, packetBuffer.size(), false);
} }
m_outputMessages.append(m_compressionStream.compress(outBuffer.data())); m_outputMessages.append(m_compressionStream.compress(outBuffer.data()));
} else { } else {