mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 19:01:13 +03:00
# Conflicts: # .github/workflows/publish.yml # Content.Server/GameTicking/GameTicker.RoundFlow.cs # Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs # Resources/Prototypes/Datasets/tips.yml # Resources/Prototypes/Maps/barratry.yml # Resources/ServerInfo/Gameplay.txt # Resources/ServerInfo/Guidebook/Antagonist/MinorAntagonists.xml # Resources/ServerInfo/Guidebook/Engineering/Power.xml # Resources/ServerInfo/Guidebook/Engineering/Singularity.xml # Resources/ServerInfo/Guidebook/Jobs.xml # Resources/ServerInfo/Guidebook/Science/MachineUpgrading.xml # Resources/Textures/Clothing/Mask/bat.rsi/meta.json # Resources/Textures/Clothing/Mask/bear.rsi/meta.json # Resources/Textures/Clothing/Mask/bee.rsi/meta.json # Resources/Textures/Clothing/Mask/breath.rsi/meta.json # Resources/Textures/Clothing/Mask/clown.rsi/meta.json # Resources/Textures/Clothing/Mask/cluwne.rsi/meta.json # Resources/Textures/Clothing/Mask/ert.rsi/meta.json # Resources/Textures/Clothing/Mask/fox.rsi/meta.json # Resources/Textures/Clothing/Mask/gas.rsi/meta.json # Resources/Textures/Clothing/Mask/gascaptain.rsi/meta.json # Resources/Textures/Clothing/Mask/gascentcom.rsi/meta.json # Resources/Textures/Clothing/Mask/gasexplorer.rsi/meta.json # Resources/Textures/Clothing/Mask/gassecurity.rsi/meta.json # Resources/Textures/Clothing/Mask/gassyndicate.rsi/meta.json # Resources/Textures/Clothing/Mask/jackal.rsi/meta.json # Resources/Textures/Clothing/Mask/joy.rsi/meta.json # Resources/Textures/Clothing/Mask/medical.rsi/meta.json # Resources/Textures/Clothing/Mask/medicalsecurity.rsi/meta.json # Resources/Textures/Clothing/Mask/merc.rsi/meta.json # Resources/Textures/Clothing/Mask/mime.rsi/meta.json # Resources/Textures/Clothing/Mask/muzzle.rsi/meta.json # Resources/Textures/Clothing/Mask/rat.rsi/meta.json # Resources/Textures/Clothing/Mask/raven.rsi/meta.json # Resources/Textures/Clothing/Mask/sadmime.rsi/meta.json # Resources/Textures/Clothing/Mask/scaredmime.rsi/meta.json # Resources/Textures/Clothing/Mask/sexyclown.rsi/meta.json # Resources/Textures/Clothing/Mask/sexymime.rsi/meta.json # Resources/Textures/Clothing/Mask/squadron.rsi/meta.json # Resources/Textures/Clothing/Mask/sterile.rsi/meta.json # Resources/Textures/Clothing/Mask/swat.rsi/meta.json
66 lines
2.5 KiB
C#
66 lines
2.5 KiB
C#
using System.Text.Json.Nodes;
|
|
using Content.Corvax.Interfaces.Server;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.GameTicking;
|
|
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!;
|
|
/// <summary>
|
|
/// For access to the round ID in status responses.
|
|
/// </summary>
|
|
[Dependency] private readonly SharedGameTicker _gameTicker = default!;
|
|
|
|
private void InitializeStatusShell()
|
|
{
|
|
IoCManager.Resolve<IStatusHost>().OnStatusRequest += GetStatusResponse;
|
|
}
|
|
|
|
private void GetStatusResponse(JsonNode jObject)
|
|
{
|
|
var preset = CurrentPreset ?? Preset;
|
|
|
|
// 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["round_id"] = _gameTicker.RoundId;
|
|
jObject["players"] = players; // Corvax-Queue
|
|
jObject["soft_max_players"] = _cfg.GetCVar(CCVars.SoftMaxPlayers);
|
|
jObject["panic_bunker"] = _cfg.GetCVar(CCVars.PanicBunkerEnabled);
|
|
jObject["run_level"] = (int) _runLevel;
|
|
if (preset != null)
|
|
jObject["preset"] = Loc.GetString(preset.ModeTitle);
|
|
if (_runLevel >= GameRunLevel.InRound)
|
|
{
|
|
jObject["round_start_time"] = _roundStartDateTime.ToString("o");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|