From c847e3da86ca56305cf1f3c06989c23cb23b0ce4 Mon Sep 17 00:00:00 2001 From: hg <4683435+hgtw@users.noreply.github.com> Date: Wed, 27 Jul 2022 09:52:25 -0400 Subject: [PATCH] [Netcode] Adjust first packet for compress flag (#2326) When a packet was over max_raw_size and zlib failed to compress the first packet chunk then the final output would be 513 bytes which exceeded m_max_packet_size of 512. This occured because the first packet chunk used sublen without adjusting for the new_length + 1 compression flag added in Compress(). When the packet failed to compress then it was already at its max. After the first packet, chunk sizes are calculated using max_raw_size which already accounted for the compress flag. (From #979) This should fix #2325 --- common/net/daybreak_connection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/net/daybreak_connection.cpp b/common/net/daybreak_connection.cpp index 125a240dd..641f482ac 100644 --- a/common/net/daybreak_connection.cpp +++ b/common/net/daybreak_connection.cpp @@ -1394,7 +1394,7 @@ void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id, first_header.total_size = (uint32_t)HostToNetwork((uint32_t)length); size_t used = 0; - size_t sublen = m_max_packet_size - m_crc_bytes - DaybreakReliableFragmentHeader::size(); + size_t sublen = m_max_packet_size - m_crc_bytes - DaybreakReliableFragmentHeader::size() - 1; // -1 for compress flag DynamicPacket first_packet; first_packet.PutSerialize(0, first_header); first_packet.PutData(DaybreakReliableFragmentHeader::size(), (char*)p.Data() + used, sublen);