From 13960a93b2a7c114446c109de059db305db4555d Mon Sep 17 00:00:00 2001 From: Kevin <115616336+lag@users.noreply.github.com> Date: Fri, 6 Mar 2026 19:23:32 -0600 Subject: Max players from 8 -> 255 + small connection optimizations (#722) * Multiplayer 8 to max byte increase. Made-with: Cursor * Server chunk optimizations for large player counts, server full notification fix, added to server.properties. --- Minecraft.Client/Windows64/Network/WinsockNetLayer.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Minecraft.Client/Windows64/Network/WinsockNetLayer.h') diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.h b/Minecraft.Client/Windows64/Network/WinsockNetLayer.h index fd1280f7..f30240d3 100644 --- a/Minecraft.Client/Windows64/Network/WinsockNetLayer.h +++ b/Minecraft.Client/Windows64/Network/WinsockNetLayer.h @@ -12,7 +12,8 @@ #pragma comment(lib, "Ws2_32.lib") #define WIN64_NET_DEFAULT_PORT 25565 -#define WIN64_NET_MAX_CLIENTS 7 +#define WIN64_NET_MAX_CLIENTS 255 +#define WIN64_SMALLID_REJECT 0xFF #define WIN64_NET_RECV_BUFFER_SIZE 65536 #define WIN64_NET_MAX_PACKET_SIZE (4 * 1024 * 1024) #define WIN64_LAN_DISCOVERY_PORT 25566 @@ -89,6 +90,7 @@ public: static bool StartAdvertising(int gamePort, const wchar_t* hostName, unsigned int gameSettings, unsigned int texPackId, unsigned char subTexId, unsigned short netVer); static void StopAdvertising(); static void UpdateAdvertisePlayerCount(BYTE count); + static void UpdateAdvertiseMaxPlayers(BYTE maxPlayers); static void UpdateAdvertiseJoinable(bool joinable); static bool StartDiscovery(); @@ -116,7 +118,7 @@ private: static BYTE s_localSmallId; static BYTE s_hostSmallId; - static BYTE s_nextSmallId; + static unsigned int s_nextSmallId; static CRITICAL_SECTION s_sendLock; static CRITICAL_SECTION s_connectionsLock; @@ -141,6 +143,12 @@ private: static CRITICAL_SECTION s_freeSmallIdLock; static std::vector s_freeSmallIds; + // O(1) smallId -> socket lookup so we don't scan s_connections (which never shrinks) on every send + static SOCKET s_smallIdToSocket[256]; + static CRITICAL_SECTION s_smallIdToSocketLock; + +public: + static void ClearSocketForSmallId(BYTE smallId); }; extern bool g_Win64MultiplayerHost; -- cgit v1.2.3