From 7d0467863c2c628ca48bd6222c0e1786d45dc5e2 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 7 Jul 2024 01:59:56 +0300 Subject: [PATCH] engine: server: add cvar to not expose current player list, or if server has a password --- engine/server/server.h | 1 + engine/server/sv_main.c | 3 ++- engine/server/sv_query.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/engine/server/server.h b/engine/server/server.h index 9cfc7139..7847b7fd 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -468,6 +468,7 @@ extern convar_t sv_log_outofband; extern convar_t sv_allow_autoaim; extern convar_t sv_aim; extern convar_t sv_allow_testpacket; +extern convar_t sv_expose_player_list; //=========================================================== // diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index a8b658c4..39a8ebbf 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -147,8 +147,8 @@ CVAR_DEFINE_AUTO( sv_userinfo_penalty_multiplier, "2", FCVAR_ARCHIVE, "penalty t CVAR_DEFINE_AUTO( sv_userinfo_penalty_attempts, "4", FCVAR_ARCHIVE, "if max attempts count was exceeded, penalty time will be increased" ); CVAR_DEFINE_AUTO( sv_fullupdate_penalty_time, "1", FCVAR_ARCHIVE, "allow fullupdate command only once in this timewindow (set 0 to disable)" ); CVAR_DEFINE_AUTO( sv_log_outofband, "0", FCVAR_ARCHIVE, "log out of band messages, can be useful for server admins and for engine debugging" ); - CVAR_DEFINE_AUTO( sv_allow_testpacket, "1", FCVAR_ARCHIVE, "allow generating and sending a big blob of data to test maximum packet size" ); +CVAR_DEFINE_AUTO( sv_expose_player_list, "1", FCVAR_ARCHIVE, "expose player list through packets that don't require connection" ); //============================================================================ /* @@ -973,6 +973,7 @@ void SV_Init( void ) Cvar_RegisterVariable( &sv_fullupdate_penalty_time ); Cvar_RegisterVariable( &sv_log_outofband ); Cvar_RegisterVariable( &sv_allow_testpacket ); + Cvar_RegisterVariable( &sv_expose_player_list ); // when we in developer-mode automatically turn cheats on if( host_developer.value ) Cvar_SetValue( "sv_cheats", 1.0f ); diff --git a/engine/server/sv_query.c b/engine/server/sv_query.c index 488a2bbb..17b1e930 100644 --- a/engine/server/sv_query.c +++ b/engine/server/sv_query.c @@ -129,7 +129,8 @@ static void SV_SourceQuery_Players( netadr_t from ) SV_GetPlayerCount( &client_count, &bot_count ); client_count += bot_count; // bots are counted as players in this reply - if( client_count <= 0 ) + // respect players privacy + if( client_count <= 0 || !sv_expose_player_list.value || !COM_CheckStringEmpty( sv_password.string )) return; MSG_Init( &buf, "TSourceEngineQueryPlayers", answer, sizeof( answer ));