]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add teleporter logs (#13375)
authorChief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
Fri, 17 Feb 2023 00:27:43 +0000 (18:27 -0600)
committerGitHub <noreply@github.com>
Fri, 17 Feb 2023 00:27:43 +0000 (01:27 +0100)
Content.Client/Teleportation/PortalSystem.cs [new file with mode: 0644]
Content.Server/Teleportation/HandTeleporterSystem.cs
Content.Server/Teleportation/PortalSystem.cs [new file with mode: 0644]
Content.Shared.Database/LogType.cs
Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs
Content.Shared/Teleportation/Systems/SharedPortalSystem.cs [moved from Content.Shared/Teleportation/Systems/PortalSystem.cs with 95% similarity]

diff --git a/Content.Client/Teleportation/PortalSystem.cs b/Content.Client/Teleportation/PortalSystem.cs
new file mode 100644 (file)
index 0000000..c8a51d6
--- /dev/null
@@ -0,0 +1,7 @@
+using Content.Shared.Teleportation.Systems;
+
+namespace Content.Client.Teleportation;
+
+public sealed class PortalSystem : SharedPortalSystem
+{
+}
index 78be228d2ee4ec5bb9834f6cc2cc256a691de1d2..12dddf2f54c345948df8f07ef649e1e9662ad853 100644 (file)
@@ -1,5 +1,7 @@
 using System.Threading;
+using Content.Server.Administration.Logs;
 using Content.Server.DoAfter;
+using Content.Shared.Database;
 using Content.Shared.Interaction.Events;
 using Content.Shared.Teleportation.Components;
 using Content.Shared.Teleportation.Systems;
@@ -12,6 +14,7 @@ namespace Content.Server.Teleportation;
 /// </summary>
 public sealed class HandTeleporterSystem : EntitySystem
 {
+    [Dependency] private readonly IAdminLogManager _adminLogger = default!;
     [Dependency] private readonly LinkedEntitySystem _link = default!;
     [Dependency] private readonly AudioSystem _audio = default!;
     [Dependency] private readonly DoAfterSystem _doafter = default!;
@@ -98,6 +101,7 @@ public sealed class HandTeleporterSystem : EntitySystem
             var timeout = EnsureComp<PortalTimeoutComponent>(user);
             timeout.EnteredPortal = null;
             component.FirstPortal = Spawn(component.FirstPortalPrototype, Transform(user).Coordinates);
+            _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(user):player} opened {ToPrettyString(component.FirstPortal.Value)} at {Transform(component.FirstPortal.Value).Coordinates} using {ToPrettyString(uid)}");
             _audio.PlayPvs(component.NewPortalSound, uid);
         }
         else if (component.SecondPortal == null)
@@ -105,11 +109,21 @@ public sealed class HandTeleporterSystem : EntitySystem
             var timeout = EnsureComp<PortalTimeoutComponent>(user);
             timeout.EnteredPortal = null;
             component.SecondPortal = Spawn(component.SecondPortalPrototype, Transform(user).Coordinates);
+            _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(user):player} opened {ToPrettyString(component.SecondPortal.Value)} at {Transform(component.SecondPortal.Value).Coordinates} linked to {ToPrettyString(component.FirstPortal!.Value)} using {ToPrettyString(uid)}");
             _link.TryLink(component.FirstPortal!.Value, component.SecondPortal.Value, true);
             _audio.PlayPvs(component.NewPortalSound, uid);
         }
         else
         {
+            // Logging
+            var portalStrings = "";
+            portalStrings += ToPrettyString(component.FirstPortal!.Value);
+            if (portalStrings != "")
+                portalStrings += " and ";
+            portalStrings += ToPrettyString(component.SecondPortal!.Value);
+            if (portalStrings != "")
+                _adminLogger.Add(LogType.EntityDelete, LogImpact.Low, $"{ToPrettyString(user):player} closed {portalStrings} with {ToPrettyString(uid)}");
+
             // Clear both portals
             QueueDel(component.FirstPortal!.Value);
             QueueDel(component.SecondPortal!.Value);
diff --git a/Content.Server/Teleportation/PortalSystem.cs b/Content.Server/Teleportation/PortalSystem.cs
new file mode 100644 (file)
index 0000000..1730a48
--- /dev/null
@@ -0,0 +1,20 @@
+using Content.Server.Mind.Components;
+using Content.Shared.Administration.Logs;
+using Content.Shared.Database;
+using Content.Shared.Teleportation.Systems;
+using Robust.Shared.Map;
+
+namespace Content.Server.Teleportation;
+
+public sealed class PortalSystem : SharedPortalSystem
+{
+    [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
+
+    // TODO Move to shared
+    protected override void LogTeleport(EntityUid portal, EntityUid subject, EntityCoordinates source,
+        EntityCoordinates target)
+    {
+        if (HasComp<MindComponent>(subject))
+            _adminLogger.Add(LogType.Teleport, LogImpact.Low, $"{ToPrettyString(subject):player} teleported via {ToPrettyString(portal)} from {source} to {target}");
+    }
+}
index ffb5cd84ed3fd61700e611b3c4b5937469056b66..073002f06b243808de872f94abbc767803bba408 100644 (file)
@@ -83,4 +83,6 @@ public enum LogType
     AdminMessage = 78,
     Anomaly = 79,
     WireHacking = 80,
+    Teleport = 81,
+    EntityDelete = 82,
 }
index bf05e83e8e12df48602d1f51d63fb992abbecd64..165e136505b282cf2da59679e72e732c682622e7 100644 (file)
@@ -7,7 +7,7 @@ namespace Content.Shared.Teleportation.Systems;
 /// <summary>
 ///     Handles symmetrically linking two entities together, and removing links properly.
 ///     This does not do anything on its own (outside of deleting entities that have 0 links, if that option is true)
-///     Systems can do whatever they please with the linked entities, such as <see cref="PortalSystem"/>.
+///     Systems can do whatever they please with the linked entities, such as <see cref="SharedPortalSystem"/>.
 /// </summary>
 public sealed class LinkedEntitySystem : EntitySystem
 {
similarity index 95%
rename from Content.Shared/Teleportation/Systems/PortalSystem.cs
rename to Content.Shared/Teleportation/Systems/SharedPortalSystem.cs
index 497730da596ff9a20d60d903730515931d3f445a..6523ce575e4684dcca53ef6da70731d7a5d528cc 100644 (file)
@@ -16,7 +16,7 @@ namespace Content.Shared.Teleportation.Systems;
 /// <summary>
 /// This handles teleporting entities through portals, and creating new linked portals.
 /// </summary>
-public sealed class PortalSystem : EntitySystem
+public abstract class SharedPortalSystem : EntitySystem
 {
     [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly INetManager _netMan = default!;
@@ -153,9 +153,16 @@ public sealed class PortalSystem : EntitySystem
             projectile.IgnoreShooter = false;
         }
 
+        LogTeleport(portal, subject, Transform(subject).Coordinates, target);
+
         Transform(subject).Coordinates = target;
 
         _audio.PlayPredicted(departureSound, portal, subject);
         _audio.PlayPredicted(arrivalSound, subject, subject);
     }
+
+    protected virtual void LogTeleport(EntityUid portal, EntityUid subject, EntityCoordinates source,
+        EntityCoordinates target)
+    {
+    }
 }