Add admin logs for shuttle call/recall

This commit is contained in:
DrSmugleaf
2021-11-22 21:31:50 +01:00
parent 37e7da0e42
commit af6353da46
5 changed files with 36 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ namespace Content.Server.Administration.Commands
// ReSharper disable once ConvertIfStatementToSwitchStatement // ReSharper disable once ConvertIfStatementToSwitchStatement
if (args.Length == 1 && TimeSpan.TryParseExact(args[0], Localization.TimeSpanMinutesFormats, loc.DefaultCulture, out var timeSpan)) if (args.Length == 1 && TimeSpan.TryParseExact(args[0], Localization.TimeSpanMinutesFormats, loc.DefaultCulture, out var timeSpan))
{ {
EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(timeSpan, false); EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(timeSpan, shell.Player?.AttachedEntity, false);
} }
else if (args.Length == 1) else if (args.Length == 1)
{ {
@@ -31,7 +31,7 @@ namespace Content.Server.Administration.Commands
} }
else else
{ {
EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(false); EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(shell.Player?.AttachedEntity, false);
} }
} }
} }
@@ -45,7 +45,7 @@ namespace Content.Server.Administration.Commands
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
EntitySystem.Get<RoundEndSystem>().CancelRoundEndCountdown(false); EntitySystem.Get<RoundEndSystem>().CancelRoundEndCountdown(shell.Player?.AttachedEntity, false);
} }
} }
} }

View File

@@ -90,11 +90,11 @@ namespace Content.Server.Communications
switch (obj.Message) switch (obj.Message)
{ {
case CommunicationsConsoleCallEmergencyShuttleMessage _: case CommunicationsConsoleCallEmergencyShuttleMessage _:
RoundEndSystem.RequestRoundEnd(); RoundEndSystem.RequestRoundEnd(obj.Session.AttachedEntity);
break; break;
case CommunicationsConsoleRecallEmergencyShuttleMessage _: case CommunicationsConsoleRecallEmergencyShuttleMessage _:
RoundEndSystem.CancelRoundEndCountdown(); RoundEndSystem.CancelRoundEndCountdown(obj.Session.AttachedEntity);
break; break;
case CommunicationsConsoleAnnounceMessage msg: case CommunicationsConsoleAnnounceMessage msg:
if (!CanAnnounce()) if (!CanAnnounce())
@@ -104,7 +104,7 @@ namespace Content.Server.Communications
_announceCooldownEndedTokenSource.Cancel(); _announceCooldownEndedTokenSource.Cancel();
_announceCooldownEndedTokenSource = new CancellationTokenSource(); _announceCooldownEndedTokenSource = new CancellationTokenSource();
LastAnnounceTime = _gameTiming.CurTime; LastAnnounceTime = _gameTiming.CurTime;
Timer.Spawn(AnnounceCooldown, () => UpdateBoundInterface(), _announceCooldownEndedTokenSource.Token); Timer.Spawn(AnnounceCooldown, UpdateBoundInterface, _announceCooldownEndedTokenSource.Token);
UpdateBoundInterface(); UpdateBoundInterface();
var message = msg.Message.Length <= 256 ? msg.Message.Trim() : $"{msg.Message.Trim().Substring(0, 256)}..."; var message = msg.Message.Length <= 256 ? msg.Message.Trim() : $"{msg.Message.Trim().Substring(0, 256)}...";

View File

@@ -1,8 +1,11 @@
using System; using System;
using System.Threading; using System.Threading;
using Content.Server.Administration.Logs;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Shared.Administration.Logs;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Robust.Server.Player;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -18,6 +21,8 @@ namespace Content.Server.RoundEnd
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly AdminLogSystem _adminLog = default!;
public const float RestartRoundTime = 20f; public const float RestartRoundTime = 20f;
private CancellationTokenSource _roundEndCancellationTokenSource = new(); private CancellationTokenSource _roundEndCancellationTokenSource = new();
@@ -74,12 +79,12 @@ namespace Content.Server.RoundEnd
Timer.Spawn(CallCooldown, () => OnCallCooldownEnded?.Invoke(), _callCooldownEndedTokenSource.Token); Timer.Spawn(CallCooldown, () => OnCallCooldownEnded?.Invoke(), _callCooldownEndedTokenSource.Token);
} }
public void RequestRoundEnd(bool checkCooldown = true) public void RequestRoundEnd(IEntity? requester = null, bool checkCooldown = true)
{ {
RequestRoundEnd(RoundEndCountdownTime, checkCooldown); RequestRoundEnd(RoundEndCountdownTime, requester, checkCooldown);
} }
public void RequestRoundEnd(TimeSpan countdownTime, bool checkCooldown = true) public void RequestRoundEnd(TimeSpan countdownTime, IEntity? requester = null, bool checkCooldown = true)
{ {
if (IsRoundEndCountdownStarted) if (IsRoundEndCountdownStarted)
return; return;
@@ -89,6 +94,15 @@ namespace Content.Server.RoundEnd
return; return;
} }
if (requester != null)
{
_adminLog.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called by {requester}");
}
else
{
_adminLog.Add(LogType.ShuttleCalled, LogImpact.High, $"Shuttle called");
}
IsRoundEndCountdownStarted = true; IsRoundEndCountdownStarted = true;
_chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station")); _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station"));
@@ -103,7 +117,7 @@ namespace Content.Server.RoundEnd
OnRoundEndCountdownStarted?.Invoke(); OnRoundEndCountdownStarted?.Invoke();
} }
public void CancelRoundEndCountdown( bool checkCooldown = true) public void CancelRoundEndCountdown(IEntity? requester = null, bool checkCooldown = true)
{ {
if (!IsRoundEndCountdownStarted) if (!IsRoundEndCountdownStarted)
return; return;
@@ -113,6 +127,15 @@ namespace Content.Server.RoundEnd
return; return;
} }
if (requester != null)
{
_adminLog.Add(LogType.ShuttleRecalled, LogImpact.High, $"Shuttle recalled by {requester}");
}
else
{
_adminLog.Add(LogType.ShuttleRecalled, LogImpact.High, $"Shuttle recalled");
}
IsRoundEndCountdownStarted = false; IsRoundEndCountdownStarted = false;
_chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-recalled-announcement"), Loc.GetString("Station")); _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-recalled-announcement"), Loc.GetString("Station"));

View File

@@ -141,7 +141,7 @@ namespace Content.Server.StationEvents.Events
public virtual void Shutdown() public virtual void Shutdown()
{ {
EntitySystem.Get<AdminLogSystem>() EntitySystem.Get<AdminLogSystem>()
.Add(LogType.EventAnnounced, $"Event shutdown: {Name}"); .Add(LogType.EventStopped, $"Event shutdown: {Name}");
if (EndAnnouncement != null) if (EndAnnouncement != null)
{ {

View File

@@ -12,4 +12,6 @@ public enum LogType
EventStarted = 6, EventStarted = 6,
EventRan = 6, EventRan = 6,
EventStopped = 7, EventStopped = 7,
ShuttleCalled = 8,
ShuttleRecalled = 9,
} }