diff --git a/Core/DedicatedServer.cpp b/Core/DedicatedServer.cpp index ba9d4d2..1b63b73 100644 --- a/Core/DedicatedServer.cpp +++ b/Core/DedicatedServer.cpp @@ -64,6 +64,9 @@ bool DedicatedServer::init() extern bool g_ServerAdvertiseLAN; g_ServerAdvertiseLAN = m_properties.advertiseLan; + extern int g_ServerMaxPlayers; + g_ServerMaxPlayers = m_properties.maxPlayers; + extern char g_ServerBindAddress[256]; if (!m_properties.serverIp.empty()) { diff --git a/Core/ServerProperties.cpp b/Core/ServerProperties.cpp index 23799c0..22a8f76 100644 --- a/Core/ServerProperties.cpp +++ b/Core/ServerProperties.cpp @@ -79,6 +79,7 @@ bool ServerProperties::load(const wstring& path) difficulty = getInt(L"difficulty", 2); maxPlayers = getInt(L"max-players", 8); if (maxPlayers < 1) maxPlayers = 1; + if (maxPlayers > 32) maxPlayers = 32; pvp = getBool(L"pvp", true); trustPlayers = getBool(L"trust-players", true); fireSpreads = getBool(L"fire-spreads", true); diff --git a/Linux/PosixNetLayer.cpp b/Linux/PosixNetLayer.cpp index 6de5b61..ceeff79 100644 --- a/Linux/PosixNetLayer.cpp +++ b/Linux/PosixNetLayer.cpp @@ -73,6 +73,7 @@ char g_Win64MultiplayerIP[256] = "127.0.0.1"; bool g_ServerAdvertiseLAN = true; char g_ServerBindAddress[256] = ""; +int g_ServerMaxPlayers = MINECRAFT_NET_MAX_PLAYERS; static void InitMutex(pthread_mutex_t* m) { @@ -560,7 +561,7 @@ void* WinsockNetLayer::AcceptThreadProc(void* /*param*/) assignedSmallId = s_freeSmallIds.back(); s_freeSmallIds.pop_back(); } - else if (s_nextSmallId < MINECRAFT_NET_MAX_PLAYERS) + else if (s_nextSmallId < g_ServerMaxPlayers) { assignedSmallId = s_nextSmallId++; } @@ -799,7 +800,7 @@ bool WinsockNetLayer::StartAdvertising(int gamePort, const wchar_t *hostName, un for (int i = 0; i < 31 && hostName[i] != L'\0'; i++) s_advertiseData.hostName[i] = (uint16_t)hostName[i]; s_advertiseData.playerCount = 1; - s_advertiseData.maxPlayers = MINECRAFT_NET_MAX_PLAYERS; + s_advertiseData.maxPlayers = g_ServerMaxPlayers; s_advertiseData.gameHostSettings = gameSettings; s_advertiseData.texturePackParentId = texPackId; s_advertiseData.subTexturePackId = subTexId; diff --git a/Linux/PosixNetLayer.h b/Linux/PosixNetLayer.h index 5e151a3..d66e247 100644 --- a/Linux/PosixNetLayer.h +++ b/Linux/PosixNetLayer.h @@ -25,7 +25,7 @@ typedef int SOCKET; inline int closesocket(SOCKET s) { return close(s); } #define WIN64_NET_DEFAULT_PORT 25565 -#define WIN64_NET_MAX_CLIENTS 7 +#define WIN64_NET_MAX_CLIENTS 31 #define WIN64_NET_RECV_BUFFER_SIZE 65536 #define WIN64_NET_MAX_PACKET_SIZE (3 * 1024 * 1024) #define WIN64_LAN_DISCOVERY_PORT 25566