]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Hide some map related logs from clients (#27127)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Fri, 19 Apr 2024 05:26:21 +0000 (17:26 +1200)
committerGitHub <noreply@github.com>
Fri, 19 Apr 2024 05:26:21 +0000 (15:26 +1000)
* Hide some map related logs from clients

* #if !DEBUG

* Fix typo

Content.Client/Administration/Managers/ClientAdminManager.cs
Content.Client/GameTicking/Managers/ClientGameTicker.cs

index fdd62fb6a2ddf42d9b46a22fd1d5ae56bda47b06..0f740c810459a80f58e56ec04c8dac1d998b88ce 100644 (file)
@@ -126,12 +126,15 @@ namespace Content.Client.Administration.Managers
 
         public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false)
         {
-            return uid == _player.LocalEntity ? _adminData : null;
+            if (uid == _player.LocalEntity && (_adminData?.Active ?? includeDeAdmin))
+                return _adminData;
+
+            return null;
         }
 
         public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false)
         {
-            if (_player.LocalUser == session.UserId)
+            if (_player.LocalUser == session.UserId && (_adminData?.Active ?? includeDeAdmin))
                 return _adminData;
 
             return null;
index df709e944461cae21d7bee9d7c0f00e65ab32b3d..f62f99c6dfb21f230f8397be34278863ce8268e2 100644 (file)
@@ -1,3 +1,4 @@
+using Content.Client.Administration.Managers;
 using Content.Client.Gameplay;
 using Content.Client.Lobby;
 using Content.Client.RoundEnd;
@@ -14,7 +15,9 @@ namespace Content.Client.GameTicking.Managers
     public sealed class ClientGameTicker : SharedGameTicker
     {
         [Dependency] private readonly IStateManager _stateManager = default!;
-        [Dependency] private readonly IEntityManager _entityManager = default!;
+        [Dependency] private readonly IClientAdminManager _admin = default!;
+        [Dependency] private readonly IClyde _clyde = default!;
+        [Dependency] private readonly SharedMapSystem _map = default!;
 
         [ViewVariables] private bool _initialized;
         private Dictionary<NetEntity, Dictionary<string, uint?>>  _jobsAvailable = new();
@@ -44,8 +47,6 @@ namespace Content.Client.GameTicking.Managers
 
         public override void Initialize()
         {
-            DebugTools.Assert(!_initialized);
-
             SubscribeNetworkEvent<TickerJoinLobbyEvent>(JoinLobby);
             SubscribeNetworkEvent<TickerJoinGameEvent>(JoinGame);
             SubscribeNetworkEvent<TickerConnectionStatusEvent>(ConnectionStatus);
@@ -53,14 +54,33 @@ namespace Content.Client.GameTicking.Managers
             SubscribeNetworkEvent<TickerLobbyInfoEvent>(LobbyInfo);
             SubscribeNetworkEvent<TickerLobbyCountdownEvent>(LobbyCountdown);
             SubscribeNetworkEvent<RoundEndMessageEvent>(RoundEnd);
-            SubscribeNetworkEvent<RequestWindowAttentionEvent>(msg =>
-            {
-                IoCManager.Resolve<IClyde>().RequestWindowAttention();
-            });
+            SubscribeNetworkEvent<RequestWindowAttentionEvent>(OnAttentionRequest);
             SubscribeNetworkEvent<TickerLateJoinStatusEvent>(LateJoinStatus);
             SubscribeNetworkEvent<TickerJobsAvailableEvent>(UpdateJobsAvailable);
 
-            _initialized = true;
+            _admin.AdminStatusUpdated += OnAdminUpdated;
+            OnAdminUpdated();
+        }
+
+        public override void Shutdown()
+        {
+            _admin.AdminStatusUpdated -= OnAdminUpdated;
+            base.Shutdown();
+        }
+
+        private void OnAdminUpdated()
+        {
+            // Hide some map/grid related logs from clients. This is to try prevent some easy metagaming by just
+            // reading the console. E.g., logs like this one could leak the nuke station/grid:
+            // > Grid NT-Arrivals 1101 (122/n25896) changed parent. Old parent: map 10 (121/n25895). New parent: FTL (123/n26470)
+#if !DEBUG
+            _map.Log.Level = _admin.IsAdmin() ? LogLevel.Info : LogLevel.Warning;
+#endif
+        }
+
+        private void OnAttentionRequest(RequestWindowAttentionEvent ev)
+        {
+            _clyde.RequestWindowAttention();
         }
 
         private void LateJoinStatus(TickerLateJoinStatusEvent message)
@@ -137,7 +157,7 @@ namespace Content.Client.GameTicking.Managers
                 return;
 
             //This is not ideal at all, but I don't see an immediately better fit anywhere else.
-            _window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, _entityManager);
+            _window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, EntityManager);
         }
     }
 }