From c790922805db6b7328022be2a0366fe6ff63f507 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Fri, 21 Jun 2024 21:24:57 -0400 Subject: [PATCH] Fix max player count limit code I did a couple hours ago --- src/pc/network/packets/packet_join.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index 7af60ead..2f7fa473 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -78,15 +78,17 @@ void network_send_join(struct Packet* joinRequestPacket) { // figure out id u8 globalIndex = joinRequestPacket->localIndex; + u8 connectedCount = 1; if (globalIndex == UNKNOWN_LOCAL_INDEX) { for (u32 i = 1; i < MAX_PLAYERS; i++) { - if (i >= gServerSettings.maxPlayers) { break; } if (!gNetworkPlayers[i].connected) { globalIndex = i; break; + } else { + connectedCount++; } } - if (globalIndex == UNKNOWN_LOCAL_INDEX) { + if (globalIndex == UNKNOWN_LOCAL_INDEX || connectedCount >= gServerSettings.maxPlayers) { network_send_kick(0, EKT_FULL_PARTY); return; }