fix: lan max players

This commit is contained in:
NOTPIES 2026-03-16 00:02:49 -03:00
parent 98794efd06
commit 521fc55e87
4 changed files with 14 additions and 5 deletions

View file

@ -57,7 +57,8 @@ PlayerList::PlayerList(MinecraftServer *server)
//int viewDistance = server->settings->getInt(L"view-distance", 10);
#ifdef _DEDICATED_SERVER
maxPlayers = server->settings->getInt(L"max-players", 8);
extern int g_ServerMaxPlayers;
maxPlayers = g_ServerMaxPlayers;
#elif defined(_WINDOWS64)
maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
#else
@ -132,13 +133,13 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
DWORD playerIndex = 0;
{
bool usedIndexes[MINECRAFT_NET_MAX_PLAYERS];
ZeroMemory( &usedIndexes, MINECRAFT_NET_MAX_PLAYERS * sizeof(bool) );
bool usedIndexes[32];
ZeroMemory( &usedIndexes, 32 * sizeof(bool) );
for(AUTO_VAR(it, players.begin()); it < players.end(); ++it)
{
usedIndexes[ (int)(*it)->getPlayerIndex() ] = true;
}
for(unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i)
for(unsigned int i = 0; i < (unsigned int)maxPlayers; ++i)
{
if(!usedIndexes[i])
{

View file

@ -59,7 +59,11 @@ char g_Win64MultiplayerIP[256] = "127.0.0.1";
bool g_ServerAdvertiseLAN = true;
char g_ServerBindAddress[256] = "";
#ifdef _DEDICATED_SERVER
int g_ServerMaxPlayers = MINECRAFT_NET_MAX_PLAYERS;
#else
int g_ServerMaxPlayers = 8;
#endif
bool WinsockNetLayer::Initialize()
{

@ -1 +1 @@
Subproject commit db5a8c90898c094e04ba85aeea12028ccf76b088
Subproject commit d611a6fdba2d64107faf33d03b223d14055e8a08

View file

@ -29,8 +29,12 @@ const int MINECRAFT_NET_MAX_PLAYERS = 4;
#ifndef XUSER_MAX_COUNT
const int XUSER_MAX_COUNT = 4;
#endif
#if defined(_DEDICATED_SERVER) || defined(_WINDOWS64)
const int MINECRAFT_NET_MAX_PLAYERS = 32;
#else
const int MINECRAFT_NET_MAX_PLAYERS = 8;
#endif
#endif