[Bots]: Fix (#932)

This commit is contained in:
Edo 2023-04-16 12:09:47 +02:00 committed by GitHub
parent 9401543a13
commit 23bfc3e89a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -379,9 +379,26 @@ namespace Components
return Game::svs_clients[clientNum].ping; return Game::svs_clients[clientNum].ping;
} }
bool Bots::IsFull()
{
auto i = 0;
while (i < *Game::svs_clientCount)
{
if (Game::svs_clients[i].header.state == Game::CS_FREE)
{
// Free slot was found
break;
}
++i;
}
return i == *Game::svs_clientCount;
}
void Bots::SV_DirectConnect_Full_Check() void Bots::SV_DirectConnect_Full_Check()
{ {
if (!sv_replaceBots->current.enabled) if (!sv_replaceBots->current.enabled && !IsFull())
{ {
return; return;
} }
@ -440,6 +457,12 @@ namespace Components
return; return;
} }
if (IsFull())
{
Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Server is full.\n");
return;
}
std::size_t count = 1; std::size_t count = 1;
if (params->size() > 1) if (params->size() > 1)

View File

@ -33,5 +33,7 @@ namespace Components
static void G_SelectWeaponIndex_Hk(); static void G_SelectWeaponIndex_Hk();
static int SV_GetClientPing_Hk(int clientNum); static int SV_GetClientPing_Hk(int clientNum);
static bool IsFull();
}; };
} }