Hide some map related logs from clients (#27127)

* Hide some map related logs from clients

* #if !DEBUG

* Fix typo
This commit is contained in:
Leon Friedrich
2024-04-19 17:26:21 +12:00
committed by GitHub
parent 45df595c15
commit 8245caaf61
2 changed files with 34 additions and 11 deletions

View File

@@ -126,12 +126,15 @@ namespace Content.Client.Administration.Managers
public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false) 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) public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false)
{ {
if (_player.LocalUser == session.UserId) if (_player.LocalUser == session.UserId && (_adminData?.Active ?? includeDeAdmin))
return _adminData; return _adminData;
return null; return null;

View File

@@ -1,3 +1,4 @@
using Content.Client.Administration.Managers;
using Content.Client.Gameplay; using Content.Client.Gameplay;
using Content.Client.Lobby; using Content.Client.Lobby;
using Content.Client.RoundEnd; using Content.Client.RoundEnd;
@@ -14,7 +15,9 @@ namespace Content.Client.GameTicking.Managers
public sealed class ClientGameTicker : SharedGameTicker public sealed class ClientGameTicker : SharedGameTicker
{ {
[Dependency] private readonly IStateManager _stateManager = default!; [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; [ViewVariables] private bool _initialized;
private Dictionary<NetEntity, Dictionary<string, uint?>> _jobsAvailable = new(); private Dictionary<NetEntity, Dictionary<string, uint?>> _jobsAvailable = new();
@@ -44,8 +47,6 @@ namespace Content.Client.GameTicking.Managers
public override void Initialize() public override void Initialize()
{ {
DebugTools.Assert(!_initialized);
SubscribeNetworkEvent<TickerJoinLobbyEvent>(JoinLobby); SubscribeNetworkEvent<TickerJoinLobbyEvent>(JoinLobby);
SubscribeNetworkEvent<TickerJoinGameEvent>(JoinGame); SubscribeNetworkEvent<TickerJoinGameEvent>(JoinGame);
SubscribeNetworkEvent<TickerConnectionStatusEvent>(ConnectionStatus); SubscribeNetworkEvent<TickerConnectionStatusEvent>(ConnectionStatus);
@@ -53,14 +54,33 @@ namespace Content.Client.GameTicking.Managers
SubscribeNetworkEvent<TickerLobbyInfoEvent>(LobbyInfo); SubscribeNetworkEvent<TickerLobbyInfoEvent>(LobbyInfo);
SubscribeNetworkEvent<TickerLobbyCountdownEvent>(LobbyCountdown); SubscribeNetworkEvent<TickerLobbyCountdownEvent>(LobbyCountdown);
SubscribeNetworkEvent<RoundEndMessageEvent>(RoundEnd); SubscribeNetworkEvent<RoundEndMessageEvent>(RoundEnd);
SubscribeNetworkEvent<RequestWindowAttentionEvent>(msg => SubscribeNetworkEvent<RequestWindowAttentionEvent>(OnAttentionRequest);
{
IoCManager.Resolve<IClyde>().RequestWindowAttention();
});
SubscribeNetworkEvent<TickerLateJoinStatusEvent>(LateJoinStatus); SubscribeNetworkEvent<TickerLateJoinStatusEvent>(LateJoinStatus);
SubscribeNetworkEvent<TickerJobsAvailableEvent>(UpdateJobsAvailable); 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) private void LateJoinStatus(TickerLateJoinStatusEvent message)
@@ -137,7 +157,7 @@ namespace Content.Client.GameTicking.Managers
return; return;
//This is not ideal at all, but I don't see an immediately better fit anywhere else. //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);
} }
} }
} }