Fix admin logs always causing an exception on first batch. (#6356)

This commit is contained in:
Pieter-Jan Briers
2022-02-28 11:21:29 +01:00
committed by GitHub
parent eaee0a8a4c
commit eeef210ae4

View File

@@ -108,6 +108,7 @@ public sealed partial class AdminLogSystem : SharedAdminLogSystem
} }
SubscribeLocalEvent<RoundStartingEvent>(RoundStarting); SubscribeLocalEvent<RoundStartingEvent>(RoundStarting);
SubscribeLocalEvent<GameRunLevelChangedEvent>(RunLevelChanged);
} }
public override async void Shutdown() public override async void Shutdown()
@@ -232,8 +233,14 @@ public sealed partial class AdminLogSystem : SharedAdminLogSystem
private void RoundStarting(RoundStartingEvent ev) private void RoundStarting(RoundStartingEvent ev)
{ {
Interlocked.Exchange(ref _currentLogId, 0);
CacheNewRound(); CacheNewRound();
}
private void RunLevelChanged(GameRunLevelChangedEvent ev)
{
if (ev.New == GameRunLevel.PreRoundLobby)
{
Interlocked.Exchange(ref _currentLogId, 0);
if (_metricsEnabled) if (_metricsEnabled)
{ {
@@ -242,6 +249,7 @@ public sealed partial class AdminLogSystem : SharedAdminLogSystem
LogsSent.Set(0); LogsSent.Set(0);
} }
} }
}
private async void Add(LogType type, LogImpact impact, string message, JsonDocument json, HashSet<Guid> players, Dictionary<int, string?> entities) private async void Add(LogType type, LogImpact impact, string message, JsonDocument json, HashSet<Guid> players, Dictionary<int, string?> entities)
{ {