Add round ID to status HTTP API (#21904)

* added round_id

* Update Content.Server/GameTicking/GameTicker.StatusShell.cs

Co-authored-by: 0x6273 <0x40@keemail.me>

---------

Co-authored-by: Moony <moony@hellomouse.net>
Co-authored-by: 0x6273 <0x40@keemail.me>
This commit is contained in:
Simon
2023-11-26 20:54:43 +01:00
committed by GitHub
parent 64343c289d
commit 14b8762bf3

View File

@@ -1,5 +1,6 @@
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Robust.Server.ServerStatus; using Robust.Server.ServerStatus;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
@@ -22,6 +23,10 @@ namespace Content.Server.GameTicking
/// For access to CVars in status responses. /// For access to CVars in status responses.
/// </summary> /// </summary>
[Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IConfigurationManager _cfg = default!;
/// <summary>
/// For access to the round ID in status responses.
/// </summary>
[Dependency] private readonly SharedGameTicker _gameTicker = default!;
private void InitializeStatusShell() private void InitializeStatusShell()
{ {
@@ -35,6 +40,7 @@ namespace Content.Server.GameTicking
{ {
jObject["name"] = _baseServer.ServerName; jObject["name"] = _baseServer.ServerName;
jObject["map"] = _gameMapManager.GetSelectedMap()?.MapName; jObject["map"] = _gameMapManager.GetSelectedMap()?.MapName;
jObject["round_id"] = _gameTicker.RoundId;
jObject["players"] = _playerManager.PlayerCount; jObject["players"] = _playerManager.PlayerCount;
jObject["soft_max_players"] = _cfg.GetCVar(CCVars.SoftMaxPlayers); jObject["soft_max_players"] = _cfg.GetCVar(CCVars.SoftMaxPlayers);
jObject["run_level"] = (int) _runLevel; jObject["run_level"] = (int) _runLevel;