Skip to content

Commit

Permalink
Merge pull request #80293 from Faless/mp/fix_enet_flags_with_channels
Browse files Browse the repository at this point in the history
[ENet] Properly set transfer flags when using custom channels
  • Loading branch information
akien-mga committed Aug 7, 2023
2 parents 40363a8 + b96d247 commit e43ae7c
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions modules/enet/enet_multiplayer_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e43ae7c

Please sign in to comment.