From 507688c74579444ae5333ce8db0a08669f54e420 Mon Sep 17 00:00:00 2001 From: Saint146 Date: Fri, 3 Feb 2017 14:55:00 +0500 Subject: [PATCH] Added cvar bot_quota_mode (#103) --- regamedll/dlls/bot/cs_bot_init.cpp | 2 ++ regamedll/dlls/bot/cs_bot_manager.cpp | 10 +++++++--- regamedll/game_shared/bot/bot_util.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/bot/cs_bot_init.cpp b/regamedll/dlls/bot/cs_bot_init.cpp index f817fdf3..419150a4 100644 --- a/regamedll/dlls/bot/cs_bot_init.cpp +++ b/regamedll/dlls/bot/cs_bot_init.cpp @@ -39,6 +39,7 @@ cvar_t cv_bot_profile_db = { "bot_profile_db", "BotProfile.db", FCVAR_SERVER, 0. #ifdef REGAMEDLL_ADD cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.0f, NULL }; +cvar_t cv_bot_quota_mode = { "bot_quota_mode", "normal", FCVAR_SERVER, 0.0f, NULL }; #endif void InstallBotControl() @@ -98,6 +99,7 @@ void Bot_RegisterCVars() #ifdef REGAMEDLL_ADD CVAR_REGISTER(&cv_bot_deathmatch); + CVAR_REGISTER(&cv_bot_quota_mode); #endif } diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index 511bd070..16714325 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -860,7 +860,11 @@ void CCSBotManager::MaintainBotQuota() return; int desiredBotCount = int(cv_bot_quota.value); - int botsInGame = UTIL_BotsInGame(); + int occupiedBotSlots = UTIL_BotsInGame(); +#ifdef REGAMEDLL_ADD + if (Q_stricmp(cv_bot_quota_mode.string, "fill") == 0) + occupiedBotSlots += humanPlayersInGame; +#endif if (cv_bot_quota_match.value > 0.0) { @@ -881,7 +885,7 @@ void CCSBotManager::MaintainBotQuota() desiredBotCount = Q_min(desiredBotCount, gpGlobals->maxClients - totalHumansInGame); // add bots if necessary - if (desiredBotCount > botsInGame) + if (desiredBotCount > occupiedBotSlots) { // don't try to add a bot if all teams are full if (!CSGameRules()->TeamFull(TERRORIST) || !CSGameRules()->TeamFull(CT)) @@ -894,7 +898,7 @@ void CCSBotManager::MaintainBotQuota() } } } - else if (desiredBotCount < botsInGame) + else if (desiredBotCount < occupiedBotSlots) { // kick a bot to maintain quota diff --git a/regamedll/game_shared/bot/bot_util.h b/regamedll/game_shared/bot/bot_util.h index 12c2b3c2..85a0c76e 100644 --- a/regamedll/game_shared/bot/bot_util.h +++ b/regamedll/game_shared/bot/bot_util.h @@ -210,6 +210,7 @@ extern cvar_t cv_bot_profile_db; #ifdef REGAMEDLL_ADD extern cvar_t cv_bot_deathmatch; +extern cvar_t cv_bot_quota_mode; #endif #define IS_ALIVE true