]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add a CCVar to allow from hiding admins in the reported player count. (#34406)
authorMyra <vasilis@pikachu.systems>
Wed, 15 Jan 2025 21:10:54 +0000 (22:10 +0100)
committerGitHub <noreply@github.com>
Wed, 15 Jan 2025 21:10:54 +0000 (22:10 +0100)
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
Content.Shared/CCVar/CCVars.Admin.cs

index fcf5b1c25cd7e6f9c4c91a8a12344222b5cccdea..4d84f78291ad1ad29e3ea2a211c2f30f10231f04 100644 (file)
@@ -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;
index c422a5a02a1d733ef3d07eed88726f44a98fa938..7754a6cbb8b6d2dec94a94476c47ffb79057eaec 100644 (file)
@@ -158,6 +158,13 @@ public sealed partial class CCVars
     public static readonly CVarDef<bool> AdminsCountForMaxPlayers =
         CVarDef.Create("admin.admins_count_for_max_players", false, CVar.SERVERONLY);
 
+    /// <summary>
+    /// 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.
+    /// </summary>
+    public static readonly CVarDef<bool> AdminsCountInReportedPlayerCount =
+        CVarDef.Create("admin.admins_count_in_playercount", false, CVar.SERVERONLY);
+
     /// <summary>
     ///     Determine if custom rank names are used.
     ///     If it is false, it'd use the actual rank name regardless of the individual's title.