mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-11-08 20:14:16 +03:00
# Conflicts: # .github/workflows/publish.yml # Content.Packaging/ContentPackaging.cs # Content.Server/Chat/Managers/ChatManager.cs # Content.Server/GameTicking/GameTicker.StatusShell.cs # Resources/Audio/Weapons/Guns/Gunshots/license.txt # Resources/Prototypes/Roles/Jobs/Security/senior_officer.yml # Resources/Textures/Structures/Doors/Airlocks/Glass/syndicate.rsi/closed.png # Resources/Textures/Structures/Doors/Airlocks/Glass/syndicate.rsi/closing.png # Resources/Textures/Structures/Doors/Airlocks/Glass/syndicate.rsi/open.png # Resources/Textures/Structures/Doors/Airlocks/Glass/syndicate.rsi/opening.png # Resources/Textures/Structures/Doors/Airlocks/Standard/syndicate.rsi/closed.png # Resources/Textures/Structures/Doors/Airlocks/Standard/syndicate.rsi/closing.png # Resources/Textures/Structures/Doors/Airlocks/Standard/syndicate.rsi/open.png # Resources/Textures/Structures/Doors/Airlocks/Standard/syndicate.rsi/opening.png
55 lines
2 KiB
C#
55 lines
2 KiB
C#
using System.Text.Json.Nodes;
|
|
using Content.Corvax.Interfaces.Server;
|
|
using Content.Shared.CCVar;
|
|
using Robust.Server.ServerStatus;
|
|
using Robust.Shared.Configuration;
|
|
|
|
namespace Content.Server.GameTicking
|
|
{
|
|
public sealed partial class GameTicker
|
|
{
|
|
/// <summary>
|
|
/// Used for thread safety, given <see cref="IStatusHost.OnStatusRequest"/> is called from another thread.
|
|
/// </summary>
|
|
private readonly object _statusShellLock = new();
|
|
|
|
/// <summary>
|
|
/// Round start time in UTC, for status shell purposes.
|
|
/// </summary>
|
|
[ViewVariables]
|
|
private DateTime _roundStartDateTime;
|
|
|
|
/// <summary>
|
|
/// For access to CVars in status responses.
|
|
/// </summary>
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
|
|
private void InitializeStatusShell()
|
|
{
|
|
IoCManager.Resolve<IStatusHost>().OnStatusRequest += GetStatusResponse;
|
|
}
|
|
|
|
private void GetStatusResponse(JsonNode jObject)
|
|
{
|
|
// This method is raised from another thread, so this better be thread safe!
|
|
lock (_statusShellLock)
|
|
{
|
|
// Corvax-Queue-Start
|
|
var players = IoCManager.Instance?.TryResolveType<IServerJoinQueueManager>(out var joinQueueManager) ?? false
|
|
? joinQueueManager.ActualPlayersCount
|
|
: _playerManager.PlayerCount;
|
|
// Corvax-Queue-End
|
|
|
|
jObject["name"] = _baseServer.ServerName;
|
|
jObject["map"] = _gameMapManager.GetSelectedMap()?.MapName;
|
|
jObject["players"] = players; // Corvax-Queue
|
|
jObject["soft_max_players"] = _cfg.GetCVar(CCVars.SoftMaxPlayers);
|
|
jObject["run_level"] = (int) _runLevel;
|
|
if (_runLevel >= GameRunLevel.InRound)
|
|
{
|
|
jObject["round_start_time"] = _roundStartDateTime.ToString("o");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|