diff options
| author | qwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com> | 2026-03-16 21:44:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-16 21:44:26 -0500 |
| commit | ce739f6045ec72127491286ea3f3f21e537c1b55 (patch) | |
| tree | f33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Windows64/Network/WinsockNetLayer.h | |
| parent | 255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff) | |
| parent | 5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff) | |
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Windows64/Network/WinsockNetLayer.h')
| -rw-r--r-- | Minecraft.Client/Windows64/Network/WinsockNetLayer.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/Minecraft.Client/Windows64/Network/WinsockNetLayer.h b/Minecraft.Client/Windows64/Network/WinsockNetLayer.h index fd1280f7..afccbd66 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 @@ -65,12 +66,18 @@ public: static bool Initialize(); static void Shutdown(); - static bool HostGame(int port, const char* bindIp = NULL); + static bool HostGame(int port, const char* bindIp = nullptr); static bool JoinGame(const char* ip, int port); static bool SendToSmallId(BYTE targetSmallId, const void* data, int dataSize); static bool SendOnSocket(SOCKET sock, const void* data, int dataSize); + // Non-host split-screen: additional TCP connections to host, one per pad + static bool JoinSplitScreen(int padIndex, BYTE* outSmallId); + static void CloseSplitScreenConnection(int padIndex); + static SOCKET GetLocalSocket(BYTE senderSmallId); + static BYTE GetSplitScreenSmallId(int padIndex); + static bool IsHosting() { return s_isHost; } static bool IsConnected() { return s_connected; } static bool IsActive() { return s_active; } @@ -89,6 +96,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(); @@ -101,6 +109,7 @@ private: static DWORD WINAPI AcceptThreadProc(LPVOID param); static DWORD WINAPI RecvThreadProc(LPVOID param); static DWORD WINAPI ClientRecvThreadProc(LPVOID param); + static DWORD WINAPI SplitScreenRecvThreadProc(LPVOID param); static DWORD WINAPI AdvertiseThreadProc(LPVOID param); static DWORD WINAPI DiscoveryThreadProc(LPVOID param); @@ -116,7 +125,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 +150,17 @@ private: static CRITICAL_SECTION s_freeSmallIdLock; static std::vector<BYTE> 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; + + // Per-pad split-screen TCP connections (client-side, non-host only) + static SOCKET s_splitScreenSocket[XUSER_MAX_COUNT]; + static BYTE s_splitScreenSmallId[XUSER_MAX_COUNT]; + static HANDLE s_splitScreenRecvThread[XUSER_MAX_COUNT]; + +public: + static void ClearSocketForSmallId(BYTE smallId); }; extern bool g_Win64MultiplayerHost; @@ -150,5 +170,6 @@ extern char g_Win64MultiplayerIP[256]; extern bool g_Win64DedicatedServer; extern int g_Win64DedicatedServerPort; extern char g_Win64DedicatedServerBindIP[256]; +extern bool g_Win64DedicatedServerLanAdvertise; #endif |
