From 0aa974cd63f021d5d84c2d057f5bd34a921a700a Mon Sep 17 00:00:00 2001 From: s1lent Date: Sat, 22 Jun 2019 02:54:01 +0700 Subject: [PATCH] Reworked bot_quota_mode and removed bot_quota_match cvar's (Migrated to bot_quota_mode) --- regamedll/dlls/bot/cs_bot_init.cpp | 8 +++++++- regamedll/dlls/bot/cs_bot_init.h | 3 ++- regamedll/dlls/bot/cs_bot_manager.cpp | 15 +++++++++++---- regamedll/game_shared/bot/bot_util.cpp | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/regamedll/dlls/bot/cs_bot_init.cpp b/regamedll/dlls/bot/cs_bot_init.cpp index 63a087c9..9a5d5aba 100644 --- a/regamedll/dlls/bot/cs_bot_init.cpp +++ b/regamedll/dlls/bot/cs_bot_init.cpp @@ -39,7 +39,6 @@ cvar_t cv_bot_difficulty = { "bot_difficulty", "0", FCVAR_SERVER, 0. cvar_t cv_bot_debug = { "bot_debug", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_quicksave = { "bot_quicksave", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_quota = { "bot_quota", "0", FCVAR_SERVER, 0.0f, nullptr }; -cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_prefix = { "bot_prefix", "", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_allow_rogues = { "bot_allow_rogues", "1", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_allow_pistols = { "bot_allow_pistols", "1", FCVAR_SERVER, 0.0f, nullptr }; @@ -61,6 +60,9 @@ cvar_t cv_bot_profile_db = { "bot_profile_db", "BotProfile.db", FCVA #ifdef REGAMEDLL_ADD cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_quota_mode = { "bot_quota_mode", "normal", FCVAR_SERVER, 0.0f, nullptr }; +#else +// Migrated to bot_quota_mode, use "match" +cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, nullptr }; #endif void InstallBotControl() @@ -99,7 +101,11 @@ void Bot_RegisterCVars() CVAR_REGISTER(&cv_bot_debug); CVAR_REGISTER(&cv_bot_quicksave); CVAR_REGISTER(&cv_bot_quota); + +#ifndef REGAMEDLL_ADD CVAR_REGISTER(&cv_bot_quota_match); +#endif + CVAR_REGISTER(&cv_bot_prefix); CVAR_REGISTER(&cv_bot_allow_rogues); CVAR_REGISTER(&cv_bot_allow_pistols); diff --git a/regamedll/dlls/bot/cs_bot_init.h b/regamedll/dlls/bot/cs_bot_init.h index 522a062d..bdf23387 100644 --- a/regamedll/dlls/bot/cs_bot_init.h +++ b/regamedll/dlls/bot/cs_bot_init.h @@ -39,7 +39,6 @@ extern cvar_t cv_bot_difficulty; extern cvar_t cv_bot_debug; extern cvar_t cv_bot_quicksave; extern cvar_t cv_bot_quota; -extern cvar_t cv_bot_quota_match; extern cvar_t cv_bot_prefix; extern cvar_t cv_bot_allow_rogues; extern cvar_t cv_bot_allow_pistols; @@ -61,4 +60,6 @@ extern cvar_t cv_bot_profile_db; #ifdef REGAMEDLL_ADD extern cvar_t cv_bot_deathmatch; extern cvar_t cv_bot_quota_mode; +#else +extern cvar_t cv_bot_quota_match; #endif diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index 5f0a3ab6..d1d03797 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -828,15 +828,22 @@ void CCSBotManager::MaintainBotQuota() int desiredBotCount = int(cv_bot_quota.value); int occupiedBotSlots = UTIL_BotsInGame(); -#ifdef REGAMEDLL_ADD - if (Q_stricmp(cv_bot_quota_mode.string, "fill") == 0) - occupiedBotSlots += humanPlayersInGame; -#endif +#ifdef REGAMEDLL_ADD + if (FStrEq(cv_bot_quota_mode.string, "fill")) + { + desiredBotCount = Q_max(0, desiredBotCount - humanPlayersInGame); + } + else if (FStrEq(cv_bot_quota_mode.string, "match")) + { + desiredBotCount = Q_max(0, cv_bot_quota.value * humanPlayersInGame); + } +#else // #ifdef REGAMEDLL_ADD if (cv_bot_quota_match.value > 0.0) { desiredBotCount = int(humanPlayersInGame * cv_bot_quota_match.value); } +#endif // #ifdef REGAMEDLL_ADD // wait for a player to join, if necessary if (cv_bot_join_after_player.value > 0.0) diff --git a/regamedll/game_shared/bot/bot_util.cpp b/regamedll/game_shared/bot/bot_util.cpp index cfb37f8d..2cbc59cf 100644 --- a/regamedll/game_shared/bot/bot_util.cpp +++ b/regamedll/game_shared/bot/bot_util.cpp @@ -112,7 +112,7 @@ int UTIL_HumansInGame(bool ignoreSpectators) continue; #ifdef REGAMEDLL_FIXES - if (pPlayer->IsProxy()) + if (ignoreSpectators && pPlayer->IsProxy()) continue; #endif