Skip to content

Commit

Permalink
Set ticker on PostInject
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyyapril committed Jan 5, 2025
1 parent 0bd63fd commit 1489f9e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Content.Server/Administration/ServerApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ public sealed partial class ServerApi : IPostInjectInit

private string _token = string.Empty;
private ISawmill _sawmill = default!;
private GameTicker _ticker = default!;

void IPostInjectInit.PostInject()
{
_sawmill = _logManager.GetSawmill("serverApi");
_ticker = _entityManager.System<GameTicker>();

// Get
RegisterActorHandler(HttpMethod.Get, "/admin/info", InfoHandler);
Expand Down Expand Up @@ -215,8 +217,7 @@ private async Task ActionForcePreset(IStatusHandlerContext context, Actor actor)

await RunOnMainThread(async () =>
{
var ticker = _entitySystemManager.GetEntitySystem<GameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
if (_ticker.RunLevel != GameRunLevel.PreRoundLobby)
{
await RespondError(
context,
Expand All @@ -226,7 +227,7 @@ await RespondError(
return;
}

var preset = ticker.FindGamePreset(body.PresetId);
var preset = _ticker.FindGamePreset(body.PresetId);
if (preset == null)
{
await RespondError(
Expand All @@ -237,7 +238,7 @@ await RespondError(
return;
}

ticker.SetGamePreset(preset);
_ticker.SetGamePreset(preset);
_sawmill.Info($"Forced the game to start with preset {body.PresetId} by {FormatLogActor(actor)}.");

await RespondOk(context);
Expand Down

0 comments on commit 1489f9e

Please sign in to comment.