From 23bfc3e89abf010dbd53d1b1228a0319b47c06fc Mon Sep 17 00:00:00 2001 From: Edo Date: Sun, 16 Apr 2023 12:09:47 +0200 Subject: [PATCH] [Bots]: Fix (#932) --- src/Components/Modules/Bots.cpp | 25 ++++++++++++++++++++++++- src/Components/Modules/Bots.hpp | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Bots.cpp b/src/Components/Modules/Bots.cpp index f53c61cb..a5686140 100644 --- a/src/Components/Modules/Bots.cpp +++ b/src/Components/Modules/Bots.cpp @@ -379,9 +379,26 @@ namespace Components 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() { - if (!sv_replaceBots->current.enabled) + if (!sv_replaceBots->current.enabled && !IsFull()) { return; } @@ -440,6 +457,12 @@ namespace Components return; } + if (IsFull()) + { + Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Server is full.\n"); + return; + } + std::size_t count = 1; if (params->size() > 1) diff --git a/src/Components/Modules/Bots.hpp b/src/Components/Modules/Bots.hpp index f2e7642c..0fe3d883 100644 --- a/src/Components/Modules/Bots.hpp +++ b/src/Components/Modules/Bots.hpp @@ -33,5 +33,7 @@ namespace Components static void G_SelectWeaponIndex_Hk(); static int SV_GetClientPing_Hk(int clientNum); + + static bool IsFull(); }; }