From eeef210ae4b49400794e6286753576cf43c6728d Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Mon, 28 Feb 2022 11:21:29 +0100 Subject: [PATCH] Fix admin logs always causing an exception on first batch. (#6356) --- .../Administration/Logs/AdminLogSystem.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Content.Server/Administration/Logs/AdminLogSystem.cs b/Content.Server/Administration/Logs/AdminLogSystem.cs index 89b0734f64..9b4c114065 100644 --- a/Content.Server/Administration/Logs/AdminLogSystem.cs +++ b/Content.Server/Administration/Logs/AdminLogSystem.cs @@ -108,6 +108,7 @@ public sealed partial class AdminLogSystem : SharedAdminLogSystem } SubscribeLocalEvent(RoundStarting); + SubscribeLocalEvent(RunLevelChanged); } public override async void Shutdown() @@ -232,14 +233,21 @@ public sealed partial class AdminLogSystem : SharedAdminLogSystem private void RoundStarting(RoundStartingEvent ev) { - Interlocked.Exchange(ref _currentLogId, 0); CacheNewRound(); + } - if (_metricsEnabled) + private void RunLevelChanged(GameRunLevelChangedEvent ev) + { + if (ev.New == GameRunLevel.PreRoundLobby) { - PreRoundQueueCapReached.Set(0); - QueueCapReached.Set(0); - LogsSent.Set(0); + Interlocked.Exchange(ref _currentLogId, 0); + + if (_metricsEnabled) + { + PreRoundQueueCapReached.Set(0); + QueueCapReached.Set(0); + LogsSent.Set(0); + } } }