Adds detailed logging to AME and PA interactions (#10170)

This commit is contained in:
Júlio César Ueti
2022-07-30 23:47:42 -03:00
committed by GitHub
parent da1969b5b8
commit d30c3b0bbc
2 changed files with 30 additions and 2 deletions

View File

@@ -1,8 +1,11 @@
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Server.Mind.Components;
using Content.Server.NodeContainer;
using Content.Server.Power.Components;
using Content.Server.UserInterface;
using Content.Shared.AME;
using Content.Shared.Database;
using Content.Shared.Hands.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -16,6 +19,7 @@ namespace Content.Server.AME.Components
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(AMEControllerUiKey.Key);
private bool _injecting;
@@ -167,6 +171,19 @@ namespace Content.Server.AME.Components
break;
}
// Logging
_entities.TryGetComponent(player, out MindComponent? mindComponent);
if (mindComponent != null)
{
var humanReadableState = _injecting ? "Inject" : "Not inject";
if (msg.Button == UiButton.IncreaseFuel || msg.Button == UiButton.DecreaseFuel)
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entities.ToPrettyString(mindComponent.Owner):player} has set the AME to inject {InjectionAmount} while set to {humanReadableState}");
if (msg.Button == UiButton.ToggleInjection)
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entities.ToPrettyString(mindComponent.Owner):player} has set the AME to {humanReadableState}");
}
GetAMENodeGroup()?.UpdateCoreVisuals();
UpdateUserInterface();

View File

@@ -1,12 +1,16 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Content.Server.Administration.Logs;
using Content.Server.Mind.Components;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.UserInterface;
using Content.Shared.Database;
// using Content.Server.WireHacking;
using Content.Shared.Singularity.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Map;
using Robust.Shared.Utility;
// using static Content.Shared.Wires.SharedWiresComponent;
@@ -25,6 +29,7 @@ namespace Content.Server.ParticleAccelerator.Components
{
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[ViewVariables]
private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ParticleAcceleratorControlBoxUiKey.Key);
@@ -143,7 +148,7 @@ namespace Content.Server.ParticleAccelerator.Components
break;
case ParticleAcceleratorSetPowerStateMessage stateMessage:
SetStrength(stateMessage.State);
SetStrength(stateMessage.State, obj.Session);
break;
case ParticleAcceleratorRescanPartsMessage _:
@@ -501,7 +506,7 @@ namespace Content.Server.ParticleAccelerator.Components
UpdatePartVisualStates();
}
public void SetStrength(ParticleAcceleratorPowerState state)
public void SetStrength(ParticleAcceleratorPowerState state, IPlayerSession? playerSession = null)
{
if (_wireStrengthCut)
{
@@ -517,6 +522,12 @@ namespace Content.Server.ParticleAccelerator.Components
UpdateAppearance();
UpdatePartVisualStates();
// Logging
_entMan.TryGetComponent(playerSession?.AttachedEntity, out MindComponent? mindComponent);
var humanReadableState = _isEnabled ? "Turned On" : "Turned Off";
if(mindComponent != null && state == MaxPower)
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entMan.ToPrettyString(mindComponent.Owner):player} has set the strength of the Particle Accelerator to a dangerous level while the PA was {humanReadableState}");
if (_isEnabled)
{
UpdatePowerDraw();