From b96d247ba2242b3fcf3649a5004e5954d3a6c57f Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Sat, 5 Aug 2023 12:27:02 +0200 Subject: [PATCH] [ENet] Properly set transfer flags when using custom channels --- modules/enet/enet_multiplayer_peer.cpp | 29 +++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp index af5bd2929c3..63f12ea1c13 100644 --- a/modules/enet/enet_multiplayer_peer.cpp +++ b/modules/enet/enet_multiplayer_peer.cpp @@ -343,23 +343,22 @@ Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size int packet_flags = 0; int channel = SYSCH_RELIABLE; int tr_channel = get_transfer_channel(); + switch (get_transfer_mode()) { + case TRANSFER_MODE_UNRELIABLE: { + packet_flags = ENET_PACKET_FLAG_UNSEQUENCED | ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT; + channel = SYSCH_UNRELIABLE; + } break; + case TRANSFER_MODE_UNRELIABLE_ORDERED: { + packet_flags = ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT; + channel = SYSCH_UNRELIABLE; + } break; + case TRANSFER_MODE_RELIABLE: { + packet_flags = ENET_PACKET_FLAG_RELIABLE; + channel = SYSCH_RELIABLE; + } break; + } if (tr_channel > 0) { channel = SYSCH_MAX + tr_channel - 1; - } else { - switch (get_transfer_mode()) { - case TRANSFER_MODE_UNRELIABLE: { - packet_flags = ENET_PACKET_FLAG_UNSEQUENCED | ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT; - channel = SYSCH_UNRELIABLE; - } break; - case TRANSFER_MODE_UNRELIABLE_ORDERED: { - packet_flags = ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT; - channel = SYSCH_UNRELIABLE; - } break; - case TRANSFER_MODE_RELIABLE: { - packet_flags = ENET_PACKET_FLAG_RELIABLE; - channel = SYSCH_RELIABLE; - } break; - } } #ifdef DEBUG_ENABLED