From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Fri, 19 Apr 2024 05:26:21 +0000 (+1200) Subject: Hide some map related logs from clients (#27127) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=8245caaf613b8acbb045c14ceff1d9affa30e5b4;p=space-station-14.git Hide some map related logs from clients (#27127) * Hide some map related logs from clients * #if !DEBUG * Fix typo --- diff --git a/Content.Client/Administration/Managers/ClientAdminManager.cs b/Content.Client/Administration/Managers/ClientAdminManager.cs index fdd62fb6a2..0f740c8104 100644 --- a/Content.Client/Administration/Managers/ClientAdminManager.cs +++ b/Content.Client/Administration/Managers/ClientAdminManager.cs @@ -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; diff --git a/Content.Client/GameTicking/Managers/ClientGameTicker.cs b/Content.Client/GameTicking/Managers/ClientGameTicker.cs index df709e9444..f62f99c6df 100644 --- a/Content.Client/GameTicking/Managers/ClientGameTicker.cs +++ b/Content.Client/GameTicking/Managers/ClientGameTicker.cs @@ -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> _jobsAvailable = new(); @@ -44,8 +47,6 @@ namespace Content.Client.GameTicking.Managers public override void Initialize() { - DebugTools.Assert(!_initialized); - SubscribeNetworkEvent(JoinLobby); SubscribeNetworkEvent(JoinGame); SubscribeNetworkEvent(ConnectionStatus); @@ -53,14 +54,33 @@ namespace Content.Client.GameTicking.Managers SubscribeNetworkEvent(LobbyInfo); SubscribeNetworkEvent(LobbyCountdown); SubscribeNetworkEvent(RoundEnd); - SubscribeNetworkEvent(msg => - { - IoCManager.Resolve().RequestWindowAttention(); - }); + SubscribeNetworkEvent(OnAttentionRequest); SubscribeNetworkEvent(LateJoinStatus); SubscribeNetworkEvent(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); } } }