bot: disable fake bot features by default (ref #575)

This commit is contained in:
jeefo 2024-05-24 14:17:37 +03:00 committed by jeefo
commit b72f8a2ef9
9 changed files with 104 additions and 32 deletions

View file

@ -72,6 +72,9 @@ void Game::levelInitialize (edict_t *entities, int max) {
// execute main config
conf.loadMainConfig ();
// ensure the server admin is confident about features he's using
game.ensureHealthyGameEnvironment ();
// load map-specific config
conf.loadMapSpecificConfig ();
@ -1010,6 +1013,9 @@ void Game::slowFrame () {
// refresh bomb origin in case some plugin moved it out
graph.setBombOrigin ();
// ensure the server admin is confident about features he's using
game.ensureHealthyGameEnvironment ();
// update next update time
m_halfSecondFrame = nextUpdate * 0.25f + time ();
}
@ -1150,6 +1156,44 @@ void Game::printBotVersion () {
ctrl.msg ("\n%s v%s successfully loaded for game: Counter-Strike %s.\n\tFlags: %s.\n", product.name, product.version, gameVersionStr, botRuntimeFlags.empty () ? "None" : String::join (botRuntimeFlags, ", "));
}
void Game::ensureHealthyGameEnvironment () {
if (!isDedicated ()) {
return; // listen servers doesn't care about it at all
}
// magic string that's enable's the features
constexpr auto kAllowHash = StringRef::fnv1a32 ("i'm confident for what i'm doing");
// fetch custom variable, so fake features are explicitly enabled
static auto enableFakeFeatures = StringRef::fnv1a32 (conf.fetchCustom ("EnableFakeBotFeatures").chars ());
// if string matches, do not affect the cvars
if (enableFakeFeatures == kAllowHash) {
return;
}
// disable fake latency
if (cv_show_latency.as <int> () > 1) {
cv_show_latency.set (0);
game.print ("Cvar \"%s_show_latency\" reverted to peaceful value.", product.cmdPri);
}
// disable fake avatars
if (cv_show_avatars) {
cv_show_avatars.set (0);
game.print ("Cvar \"%s_show_avatars\" reverted to peaceful value.", product.cmdPri);
}
// disable fake queries
if (cv_enable_query_hook) {
cv_enable_query_hook.set (0);
game.print ("Cvar \"%s_enable_query_hook\" reverted to peaceful value.", product.cmdPri);
}
}
void LightMeasure::initializeLightstyles () {
// this function initializes lighting information...