Skip to content

Commit

Permalink
conf: remove yb_logger_disable_logfile in favor of custom setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jeefo committed May 28, 2024
1 parent 06c2243 commit f97876d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
5 changes: 5 additions & 0 deletions cfg/addons/yapb/conf/custom.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ ZMInfectedTeam = T
;
EnableFakeBotFeatures = no

;
; Disables any writing activity to log files. Thus all errors and warnings just
; sent to the server console. This replaces yb_logger_disable_logfile cvar.
;
DisableLogFile = no
7 changes: 0 additions & 7 deletions cfg/addons/yapb/conf/yapb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,6 @@ yb_bind_menu_key "="
//
yb_ignore_cvars_on_changelevel "yb_quota,yb_autovacate"
//
// Disables logger to write anything to log file. Just spew content to the console.
// ---
// Default: "0", Min: "0", Max: "1"
//
yb_logger_disable_logfile "0"
//
// The value (password) for the setinfo key, if user sets correct password, he's gains access to bot commands and menus.
// ---
Expand Down
30 changes: 20 additions & 10 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

ConVar cv_bind_menu_key ("bind_menu_key", "=", "Binds specified key for opening bots menu.", false);
ConVar cv_ignore_cvars_on_changelevel ("ignore_cvars_on_changelevel", "yb_quota,yb_autovacate", "Specifies comma separated list of bot cvars, that will not be overwritten by config on changelevel.", false);
ConVar cv_logger_disable_logfile ("logger_disable_logfile", "0", "Disables logger to write anything to log file. Just spew content to the console.");

BotConfig::BotConfig () {
m_chat.resize (Chat::Count);
Expand Down Expand Up @@ -106,6 +105,9 @@ void BotConfig::loadMainConfig (bool isFirstLoad) {
cv_difficulty.set (3);
}

// preload custom config
conf.loadCustomConfig ();

// bind the correct menu key for bot menu...
if (!game.isDedicated ()) {
auto val = cv_bind_menu_key.as <StringRef> ();
Expand All @@ -114,9 +116,14 @@ void BotConfig::loadMainConfig (bool isFirstLoad) {
game.serverCommand ("bind \"%s\" \"yb menu\"", val);
}
}
static const bool disableLogWrite = conf.fetchCustom ("DisableLogFile").startsWith ("yes");

// disable logger if requested
logger.disableLogWrite (cv_logger_disable_logfile);
logger.disableLogWrite (disableLogWrite);

if (disableLogWrite) {
game.print ("Bot logging is disabled.");
}
}

void BotConfig::loadNamesConfig () {
Expand Down Expand Up @@ -671,14 +678,17 @@ void BotConfig::loadCustomConfig () {
MemFile file {};

auto setDefaults = [&] () {
m_custom["C4ModelName"] = "c4.mdl";
m_custom["AMXParachuteCvar"] = "sv_parachute";
m_custom["CustomCSDMSpawnPoint"] = "view_spawn";
m_custom["CSDMDetectCvar"] = "csdm_active";
m_custom["ZMDetectCvar"] = "zp_delay";
m_custom["ZMDelayCvar"] = "zp_delay";
m_custom["ZMInfectedTeam"] = "T";
m_custom["EnableFakeBotFeatures"] = "no";
m_custom = {
{ "C4ModelName", "c4.mdl" },
{ "AMXParachuteCvar", "sv_parachute" },
{ "CustomCSDMSpawnPoint", "view_spawn" },
{ "CSDMDetectCvar", "csdm_active" },
{ "ZMDetectCvar", "zp_delay" },
{ "ZMDelayCvar", "zp_delay" },
{ "ZMInfectedTeam", "T" },
{ "EnableFakeBotFeatures", "no" },
{ "DisableLogFile", "no" }
};
};

setDefaults ();
Expand Down

0 comments on commit f97876d

Please sign in to comment.