Prevent sv_maxbots + sv_maxclients from reaching MAX_CLIENTS

This commit is contained in:
smallmodel 2023-08-19 19:35:20 +02:00
parent d22cda594f
commit a30f78e834
No known key found for this signature in database
GPG key ID: A96F163ED4891440

View file

@ -602,6 +602,15 @@ void CVAR_Init(void)
g_rankedserver = gi.Cvar_Get("g_rankedserver", "0", 0);
g_spectatefollow_firstperson = gi.Cvar_Get("g_spectatefollow_firstperson", "0", 0);
if (maxclients->integer + sv_maxbots->integer > MAX_CLIENTS) {
unsigned int lowered;
lowered = MAX_CLIENTS - maxclients->integer;
gi.cvar_set("sv_maxbots", va("%d", lowered));
gi.Printf("sv_maxbots reached max clients, lowering the value to %u\n", lowered);
}
if (sv_numbots->integer > sv_maxbots->integer) {
gi.Printf("numbots overflow, setting to %d\n", sv_maxbots->integer);
gi.cvar_set("sv_numbots", sv_maxbots->string);