From 2ac25bebaa0b081d0b1d26572eb263479528850c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 16 Jul 2023 15:11:09 -0500 Subject: [PATCH] Send unreliable traffic as reliable when we have just one channel --- src/ControlStream.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ControlStream.c b/src/ControlStream.c index 7ef68b0..b3f602f 100644 --- a/src/ControlStream.c +++ b/src/ControlStream.c @@ -634,6 +634,14 @@ static bool sendMessageEnet(short ptype, short paylen, const void* payload, uint // the peer's supported channel count. if (!IS_SUNSHINE() || channelId >= peer->channelCount) { channelId = 0; + + // Send unreliable traffic as reliable if we only have one channel. + // This avoids unwanted sequencing between reliable and unreliable + // traffic that can lead to delays. + if (flags == 0) { + flags |= ENET_PACKET_FLAG_RELIABLE; + enetPacket->flags |= ENET_PACKET_FLAG_RELIABLE; + } } // Queue the packet to be sent