fix: update sendPing to set source ID before sequence number for proper header resizing

This commit is contained in:
MayaTheShy
2025-11-10 01:41:21 -05:00
parent c8fb6b1d58
commit 7d7dedf494

View File

@@ -1538,10 +1538,13 @@ void OverteClient::handlePing(const char* payload, size_t len) {
void OverteClient::sendPing(int fd, const sockaddr_storage& addr, socklen_t addrLen) {
// Create NLPacket for Ping with correct version
NLPacket packet(PacketType::Ping, PacketVersions::Ping_IncludeConnectionID, false);
// Include our local ID if we have one (sourced packet)
// Set source ID first (this resizes header and writes it)
if (m_localID != 0) {
packet.setSourceID(m_localID);
}
// Then set sequence number (this updates the header without resizing)
packet.setSequenceNumber(m_sequenceNumber++);
// Add timestamp (microseconds since epoch)