From 3cfd81450310f06f0c4a297c30d3f8a702bfc314 Mon Sep 17 00:00:00 2001 From: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> Date: Sun, 15 Jan 2023 15:14:46 -0600 Subject: [PATCH] Add logging for hacking (#12861) --- Content.Server/Access/AccessWireAction.cs | 8 ++++++ .../ArcadeInvincibilityWireActions.cs | 5 ++++ .../WireActions/ArcadeOverflowWireAction.cs | 5 ++++ .../Monitor/WireActions/AirAlarmPanicWire.cs | 8 ++++++ .../WireActions/AtmosAlarmableAlarmWire.cs | 8 ++++++ .../WireActions/DoorBoltLightWireAction.cs | 8 ++++++ .../Doors/WireActions/DoorBoltWireAction.cs | 8 ++++++ .../Doors/WireActions/DoorSafetyWireAction.cs | 8 ++++++ .../Doors/WireActions/DoorTimingWireAction.cs | 8 ++++++ Content.Server/Power/PowerWireAction.cs | 8 ++++++ .../VendingMachineEjectItemWireAction.cs | 8 ++++++ Content.Server/Wires/BaseToggleWireAction.cs | 3 ++ Content.Server/Wires/BaseWireAction.cs | 28 +++++++++++++++++-- Content.Server/Wires/DummyWireAction.cs | 21 ++++++++++++-- 14 files changed, 128 insertions(+), 6 deletions(-) diff --git a/Content.Server/Access/AccessWireAction.cs b/Content.Server/Access/AccessWireAction.cs index 56aef4840c..0f40de544a 100644 --- a/Content.Server/Access/AccessWireAction.cs +++ b/Content.Server/Access/AccessWireAction.cs @@ -13,6 +13,11 @@ public sealed class AccessWireAction : BaseWireAction [DataField("name")] private string _text = "ACC"; + protected override string Text + { + get => _text; + set => _text = value; + } [DataField("pulseTimeout")] private int _pulseTimeout = 30; @@ -39,6 +44,7 @@ public sealed class AccessWireAction : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var access)) { WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key); @@ -50,6 +56,7 @@ public sealed class AccessWireAction : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var access)) { access.Enabled = true; @@ -60,6 +67,7 @@ public sealed class AccessWireAction : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var access)) { access.Enabled = false; diff --git a/Content.Server/Arcade/WireActions/ArcadeInvincibilityWireActions.cs b/Content.Server/Arcade/WireActions/ArcadeInvincibilityWireActions.cs index 7b783e5655..36f6d51a91 100644 --- a/Content.Server/Arcade/WireActions/ArcadeInvincibilityWireActions.cs +++ b/Content.Server/Arcade/WireActions/ArcadeInvincibilityWireActions.cs @@ -9,6 +9,11 @@ namespace Content.Server.Arcade; public sealed class ArcadePlayerInvincibleWireAction : BaseToggleWireAction { private string _text = "MNGR"; + protected override string Text + { + get => _text; + set => _text = value; + } private Color _color = Color.Purple; public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthManager; diff --git a/Content.Server/Arcade/WireActions/ArcadeOverflowWireAction.cs b/Content.Server/Arcade/WireActions/ArcadeOverflowWireAction.cs index 0a42d67eb6..a673a3622d 100644 --- a/Content.Server/Arcade/WireActions/ArcadeOverflowWireAction.cs +++ b/Content.Server/Arcade/WireActions/ArcadeOverflowWireAction.cs @@ -10,6 +10,11 @@ public sealed class ArcadeOverflowWireAction : BaseToggleWireAction { private Color _color = Color.Red; private string _text = "LMTR"; + protected override string Text + { + get => _text; + set => _text = value; + } public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthLimiter; diff --git a/Content.Server/Atmos/Monitor/WireActions/AirAlarmPanicWire.cs b/Content.Server/Atmos/Monitor/WireActions/AirAlarmPanicWire.cs index 4021e81978..0991cb691e 100644 --- a/Content.Server/Atmos/Monitor/WireActions/AirAlarmPanicWire.cs +++ b/Content.Server/Atmos/Monitor/WireActions/AirAlarmPanicWire.cs @@ -11,6 +11,11 @@ namespace Content.Server.Atmos.Monitor; public sealed class AirAlarmPanicWire : BaseWireAction { private string _text = "PANC"; + protected override string Text + { + get => _text; + set => _text = value; + } private Color _color = Color.Red; private AirAlarmSystem _airAlarmSystem = default!; @@ -42,6 +47,7 @@ public sealed class AirAlarmPanicWire : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var devNet)) { _airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false); @@ -52,6 +58,7 @@ public sealed class AirAlarmPanicWire : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var devNet) && EntityManager.TryGetComponent(wire.Owner, out var alarm) && alarm.CurrentMode == AirAlarmMode.Panic) @@ -65,6 +72,7 @@ public sealed class AirAlarmPanicWire : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var devNet)) { _airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false); diff --git a/Content.Server/Atmos/Monitor/WireActions/AtmosAlarmableAlarmWire.cs b/Content.Server/Atmos/Monitor/WireActions/AtmosAlarmableAlarmWire.cs index 70d0b80f96..61168e5d3f 100644 --- a/Content.Server/Atmos/Monitor/WireActions/AtmosAlarmableAlarmWire.cs +++ b/Content.Server/Atmos/Monitor/WireActions/AtmosAlarmableAlarmWire.cs @@ -15,6 +15,11 @@ public sealed class AtmosMonitorDeviceNetWire : BaseWireAction private bool _alarmOnPulse = false; private string _text = "NETW"; + protected override string Text + { + get => _text; + set => _text = value; + } private Color _color = Color.Orange; private AtmosAlarmableSystem _atmosAlarmableSystem = default!; @@ -52,6 +57,7 @@ public sealed class AtmosMonitorDeviceNetWire : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var monitor)) { monitor.IgnoreAlarms = true; @@ -62,6 +68,7 @@ public sealed class AtmosMonitorDeviceNetWire : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var monitor)) { monitor.IgnoreAlarms = false; @@ -72,6 +79,7 @@ public sealed class AtmosMonitorDeviceNetWire : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); if (_alarmOnPulse) { _atmosAlarmableSystem.ForceAlert(wire.Owner, AtmosAlarmType.Danger); diff --git a/Content.Server/Doors/WireActions/DoorBoltLightWireAction.cs b/Content.Server/Doors/WireActions/DoorBoltLightWireAction.cs index ad9151442a..7538c384f2 100644 --- a/Content.Server/Doors/WireActions/DoorBoltLightWireAction.cs +++ b/Content.Server/Doors/WireActions/DoorBoltLightWireAction.cs @@ -13,6 +13,11 @@ public sealed class DoorBoltLightWireAction : BaseWireAction [DataField("name")] private string _text = "BLIT"; + protected override string Text + { + get => _text; + set => _text = value; + } public override StatusLightData? GetStatusLightData(Wire wire) { @@ -34,6 +39,7 @@ public sealed class DoorBoltLightWireAction : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { door.BoltLightsVisible = false; @@ -44,6 +50,7 @@ public sealed class DoorBoltLightWireAction : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { door.BoltLightsVisible = true; @@ -54,6 +61,7 @@ public sealed class DoorBoltLightWireAction : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { door.BoltLightsVisible = !door.BoltLightsEnabled; diff --git a/Content.Server/Doors/WireActions/DoorBoltWireAction.cs b/Content.Server/Doors/WireActions/DoorBoltWireAction.cs index 4ac6753c37..32d4c31533 100644 --- a/Content.Server/Doors/WireActions/DoorBoltWireAction.cs +++ b/Content.Server/Doors/WireActions/DoorBoltWireAction.cs @@ -13,6 +13,11 @@ public sealed class DoorBoltWireAction : BaseWireAction [DataField("name")] private string _text = "BOLT"; + protected override string Text + { + get => _text; + set => _text = value; + } public override StatusLightData? GetStatusLightData(Wire wire) { @@ -36,6 +41,7 @@ public sealed class DoorBoltWireAction : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { door.BoltWireCut = true; @@ -48,6 +54,7 @@ public sealed class DoorBoltWireAction : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) door.BoltWireCut = false; @@ -56,6 +63,7 @@ public sealed class DoorBoltWireAction : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { if (IsPowered(wire.Owner)) diff --git a/Content.Server/Doors/WireActions/DoorSafetyWireAction.cs b/Content.Server/Doors/WireActions/DoorSafetyWireAction.cs index 706a4f3ec1..241c628ddf 100644 --- a/Content.Server/Doors/WireActions/DoorSafetyWireAction.cs +++ b/Content.Server/Doors/WireActions/DoorSafetyWireAction.cs @@ -13,6 +13,11 @@ public sealed class DoorSafetyWireAction : BaseWireAction [DataField("name")] private string _text = "SAFE"; + protected override string Text + { + get => _text; + set => _text = value; + } [DataField("timeout")] private int _timeout = 30; @@ -38,6 +43,7 @@ public sealed class DoorSafetyWireAction : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key); @@ -49,6 +55,7 @@ public sealed class DoorSafetyWireAction : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { door.Safety = true; @@ -59,6 +66,7 @@ public sealed class DoorSafetyWireAction : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { door.Safety = false; diff --git a/Content.Server/Doors/WireActions/DoorTimingWireAction.cs b/Content.Server/Doors/WireActions/DoorTimingWireAction.cs index 51dc41bd81..8cd3e5e399 100644 --- a/Content.Server/Doors/WireActions/DoorTimingWireAction.cs +++ b/Content.Server/Doors/WireActions/DoorTimingWireAction.cs @@ -13,6 +13,11 @@ public sealed class DoorTimingWireAction : BaseWireAction [DataField("name")] private string _text = "TIMR"; + protected override string Text + { + get => _text; + set => _text = value; + } [DataField("timeout")] private int _timeout = 30; @@ -47,6 +52,7 @@ public sealed class DoorTimingWireAction : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key); @@ -58,6 +64,7 @@ public sealed class DoorTimingWireAction : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { door.AutoCloseDelayModifier = 1f; @@ -68,6 +75,7 @@ public sealed class DoorTimingWireAction : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out var door)) { door.AutoCloseDelayModifier = 0.5f; diff --git a/Content.Server/Power/PowerWireAction.cs b/Content.Server/Power/PowerWireAction.cs index 85409c9775..d228fb3781 100644 --- a/Content.Server/Power/PowerWireAction.cs +++ b/Content.Server/Power/PowerWireAction.cs @@ -16,6 +16,11 @@ public sealed class PowerWireAction : BaseWireAction [DataField("name")] private string _text = "POWR"; + protected override string Text + { + get => _text; + set => _text = value; + } [DataField("pulseTimeout")] private int _pulseTimeout = 30; @@ -200,6 +205,7 @@ public sealed class PowerWireAction : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (!TrySetElectrocution(user, wire)) return false; @@ -212,6 +218,7 @@ public sealed class PowerWireAction : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (!TrySetElectrocution(user, wire)) return false; @@ -228,6 +235,7 @@ public sealed class PowerWireAction : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); WiresSystem.TryCancelWireAction(wire.Owner, PowerWireActionKey.ElectrifiedCancel); var electrocuted = !TrySetElectrocution(user, wire, true); diff --git a/Content.Server/VendingMachines/VendingMachineEjectItemWireAction.cs b/Content.Server/VendingMachines/VendingMachineEjectItemWireAction.cs index 48f491d6c9..3a674cea65 100644 --- a/Content.Server/VendingMachines/VendingMachineEjectItemWireAction.cs +++ b/Content.Server/VendingMachines/VendingMachineEjectItemWireAction.cs @@ -11,6 +11,11 @@ public sealed class VendingMachineEjectItemWireAction : BaseWireAction private Color _color = Color.Red; private string _text = "VEND"; + protected override string Text + { + get => _text; + set => _text = value; + } public override object? StatusKey { get; } = EjectWireKey.StatusKey; public override StatusLightData? GetStatusLightData(Wire wire) @@ -40,6 +45,7 @@ public sealed class VendingMachineEjectItemWireAction : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending)) { _vendingMachineSystem.SetShooting(wire.Owner, true, vending); @@ -50,6 +56,7 @@ public sealed class VendingMachineEjectItemWireAction : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending)) { _vendingMachineSystem.SetShooting(wire.Owner, false, vending); @@ -60,6 +67,7 @@ public sealed class VendingMachineEjectItemWireAction : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); _vendingMachineSystem.EjectRandom(wire.Owner, true); return true; diff --git a/Content.Server/Wires/BaseToggleWireAction.cs b/Content.Server/Wires/BaseToggleWireAction.cs index da83e170e8..21886a1d09 100644 --- a/Content.Server/Wires/BaseToggleWireAction.cs +++ b/Content.Server/Wires/BaseToggleWireAction.cs @@ -29,6 +29,7 @@ public abstract class BaseToggleWireAction : BaseWireAction public override bool Cut(EntityUid user, Wire wire) { + base.Cut(user, wire); ToggleValue(wire.Owner, false); if (TimeoutKey != null) @@ -41,6 +42,7 @@ public abstract class BaseToggleWireAction : BaseWireAction public override bool Mend(EntityUid user, Wire wire) { + base.Mend(user, wire); ToggleValue(wire.Owner, true); return true; @@ -48,6 +50,7 @@ public abstract class BaseToggleWireAction : BaseWireAction public override bool Pulse(EntityUid user, Wire wire) { + base.Pulse(user, wire); ToggleValue(wire.Owner, !GetValue(wire.Owner)); if (TimeoutKey != null) diff --git a/Content.Server/Wires/BaseWireAction.cs b/Content.Server/Wires/BaseWireAction.cs index c41c19fb09..8990acf6d8 100644 --- a/Content.Server/Wires/BaseWireAction.cs +++ b/Content.Server/Wires/BaseWireAction.cs @@ -1,5 +1,7 @@ using Content.Server.Power.Components; using Content.Server.Power.EntitySystems; +using Content.Shared.Administration.Logs; +using Content.Shared.Database; using Content.Shared.Wires; namespace Content.Server.Wires; @@ -7,6 +9,13 @@ namespace Content.Server.Wires; /// public abstract class BaseWireAction : IWireAction { + private ISharedAdminLogManager _adminLogger = default!; + protected virtual string Text + { + get => GetType().Name.Replace("WireAction", ""); + set { } + } + public IEntityManager EntityManager = default!; public WiresSystem WiresSystem = default!; @@ -17,14 +26,27 @@ public abstract class BaseWireAction : IWireAction public virtual void Initialize() { EntityManager = IoCManager.Resolve(); + _adminLogger = IoCManager.Resolve(); WiresSystem = EntityManager.EntitySysManager.GetEntitySystem(); } public virtual bool AddWire(Wire wire, int count) => count == 1; - public abstract bool Cut(EntityUid user, Wire wire); - public abstract bool Mend(EntityUid user, Wire wire); - public abstract bool Pulse(EntityUid user, Wire wire); + public virtual bool Cut(EntityUid user, Wire wire) + { + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user):player} cut {wire.Color.Name()} {Text} in {EntityManager.ToPrettyString(wire.Owner)}"); + return false; + } + public virtual bool Mend(EntityUid user, Wire wire) + { + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user):player} mended {wire.Color.Name()} {Text} in {EntityManager.ToPrettyString(wire.Owner)}"); + return false; + } + public virtual bool Pulse(EntityUid user, Wire wire) + { + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user):player} pulsed {wire.Color.Name()} {Text} in {EntityManager.ToPrettyString(wire.Owner)}"); + return false; + } public virtual void Update(Wire wire) { return; diff --git a/Content.Server/Wires/DummyWireAction.cs b/Content.Server/Wires/DummyWireAction.cs index 4e771b54d3..cbb7f69fbc 100644 --- a/Content.Server/Wires/DummyWireAction.cs +++ b/Content.Server/Wires/DummyWireAction.cs @@ -15,9 +15,24 @@ public sealed class DummyWireAction : BaseWireAction public override StatusLightData? GetStatusLightData(Wire wire) => null; public override bool AddWire(Wire wire, int count) => true; - public override bool Cut(EntityUid user, Wire wire) => true; - public override bool Mend(EntityUid user, Wire wire) => true; - public override bool Pulse(EntityUid user, Wire wire) => true; + + public override bool Cut(EntityUid user, Wire wire) + { + base.Cut(user, wire); + return true; + } + + public override bool Mend(EntityUid user, Wire wire) + { + base.Mend(user, wire); + return true; + } + + public override bool Pulse(EntityUid user, Wire wire) + { + base.Pulse(user, wire); + return true; + } // doesn't matter if you get any information off of this, // if you really want to mess with dummy wires, you should