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

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