From 40fc4992e5e2fb6805d53ba0a665f05aa040949b Mon Sep 17 00:00:00 2001 From: Myra Date: Wed, 15 Jan 2025 22:10:54 +0100 Subject: [PATCH] Add a CCVar to allow from hiding admins in the reported player count. (#34406) Good for: - Keeping admins hidden - Not confuse players seeing 84/80 players Nicely pairs up with the ``admin.admins_count_for_max_players`` ccvar --- Content.Server/GameTicking/GameTicker.StatusShell.cs | 5 ++++- Content.Shared/CCVar/CCVars.Admin.cs | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameTicking/GameTicker.StatusShell.cs b/Content.Server/GameTicking/GameTicker.StatusShell.cs index fcf5b1c25c..4d84f78291 100644 --- a/Content.Server/GameTicking/GameTicker.StatusShell.cs +++ b/Content.Server/GameTicking/GameTicker.StatusShell.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Text.Json.Nodes; using Content.Shared.CCVar; using Content.Shared.GameTicking; @@ -43,7 +44,9 @@ namespace Content.Server.GameTicking jObject["name"] = _baseServer.ServerName; jObject["map"] = _gameMapManager.GetSelectedMap()?.MapName; jObject["round_id"] = _gameTicker.RoundId; - jObject["players"] = _playerManager.PlayerCount; + jObject["players"] = _cfg.GetCVar(CCVars.AdminsCountInReportedPlayerCount) + ? _playerManager.PlayerCount + : _playerManager.PlayerCount - _adminManager.ActiveAdmins.Count(); jObject["soft_max_players"] = _cfg.GetCVar(CCVars.SoftMaxPlayers); jObject["panic_bunker"] = _cfg.GetCVar(CCVars.PanicBunkerEnabled); jObject["run_level"] = (int) _runLevel; diff --git a/Content.Shared/CCVar/CCVars.Admin.cs b/Content.Shared/CCVar/CCVars.Admin.cs index c422a5a02a..7754a6cbb8 100644 --- a/Content.Shared/CCVar/CCVars.Admin.cs +++ b/Content.Shared/CCVar/CCVars.Admin.cs @@ -158,6 +158,13 @@ public sealed partial class CCVars public static readonly CVarDef AdminsCountForMaxPlayers = CVarDef.Create("admin.admins_count_for_max_players", false, CVar.SERVERONLY); + /// + /// Should admins be hidden from the player count reported to the launcher/via api? + /// This is hub advert safe, in case that's a worry. + /// + public static readonly CVarDef AdminsCountInReportedPlayerCount = + CVarDef.Create("admin.admins_count_in_playercount", false, CVar.SERVERONLY); + /// /// Determine if custom rank names are used. /// If it is false, it'd use the actual rank name regardless of the individual's title. -- 2.51.2