Fix crash when getting server status

- Adds _roundStartDateTime field to GameTicker, the UTC time when the round started.
This commit is contained in:
Vera Aguilera Puerto
2021-06-20 17:38:05 +02:00
parent f7b89daa74
commit 5b41d3328e
2 changed files with 10 additions and 1 deletions

View File

@@ -89,6 +89,7 @@ namespace Content.Server.GameTicking
readyPlayers = _playersInLobby.Keys.ToList(); readyPlayers = _playersInLobby.Keys.ToList();
} }
_roundStartDateTime = DateTime.UtcNow;
RunLevel = GameRunLevel.InRound; RunLevel = GameRunLevel.InRound;
RoundLengthMetric.Set(0); RoundLengthMetric.Set(0);

View File

@@ -1,6 +1,8 @@
using System;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Robust.Server.ServerStatus; using Robust.Server.ServerStatus;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameTicking namespace Content.Server.GameTicking
{ {
@@ -11,6 +13,12 @@ namespace Content.Server.GameTicking
/// </summary> /// </summary>
private readonly object _statusShellLock = new(); private readonly object _statusShellLock = new();
/// <summary>
/// Round start time in UTC, for status shell purposes.
/// </summary>
[ViewVariables]
private DateTime _roundStartDateTime;
private void InitializeStatusShell() private void InitializeStatusShell()
{ {
IoCManager.Resolve<IStatusHost>().OnStatusRequest += GetStatusResponse; IoCManager.Resolve<IStatusHost>().OnStatusRequest += GetStatusResponse;
@@ -26,7 +34,7 @@ namespace Content.Server.GameTicking
jObject["run_level"] = (int) _runLevel; jObject["run_level"] = (int) _runLevel;
if (_runLevel >= GameRunLevel.InRound) if (_runLevel >= GameRunLevel.InRound)
{ {
jObject["round_start_time"] = _roundStartTime.ToString("o"); jObject["round_start_time"] = _roundStartDateTime.ToString("o");
} }
} }
} }