]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add admin alerts for explosions (#15786)
authorChief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
Thu, 27 Apr 2023 18:55:16 +0000 (13:55 -0500)
committerGitHub <noreply@github.com>
Thu, 27 Apr 2023 18:55:16 +0000 (11:55 -0700)
Content.Server/Chat/Managers/ChatManager.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Content.Shared/CCVar/CCVars.cs

index 90924188b265646233cb955a61aa9694a406d694..8f62ca47588220989d8238ef346b0e18fd3601ed 100644 (file)
@@ -118,7 +118,8 @@ namespace Content.Server.Chat.Managers
 
         public void SendAdminAlert(EntityUid player, string message, MindComponent? mindComponent = null)
         {
-            if(mindComponent == null && !_entityManager.TryGetComponent(player, out mindComponent))
+            if((mindComponent == null && !_entityManager.TryGetComponent(player, out mindComponent))
+               || mindComponent.Mind == null)
             {
                 SendAdminAlert(message);
                 return;
index f88989051f72203c24e0e73604d68fb560889056..bd821f293706dd19a37b6e263f7399f5e09945a2 100644 (file)
@@ -1,10 +1,12 @@
 using System.Linq;
 using Content.Server.Administration.Logs;
 using Content.Server.Atmos.Components;
+using Content.Server.Chat.Managers;
 using Content.Server.Explosion.Components;
 using Content.Server.NodeContainer.EntitySystems;
 using Content.Server.NPC.Pathfinding;
 using Content.Shared.Camera;
+using Content.Shared.CCVar;
 using Content.Shared.Damage;
 using Content.Shared.Database;
 using Content.Shared.Explosion;
@@ -38,6 +40,7 @@ public sealed partial class ExplosionSystem : EntitySystem
     [Dependency] private readonly PathfindingSystem _pathfindingSystem = default!;
     [Dependency] private readonly SharedCameraRecoilSystem _recoilSystem = default!;
     [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+    [Dependency] private readonly IChatManager _chat = default!;
     [Dependency] private readonly ThrowingSystem _throwingSystem = default!;
     [Dependency] private readonly PVSOverrideSystem _pvsSys = default!;
     [Dependency] private readonly SharedTransformSystem _transformSystem = default!;
@@ -227,11 +230,18 @@ public sealed partial class ExplosionSystem : EntitySystem
             return;
 
         if (user == null)
+        {
             _adminLogger.Add(LogType.Explosion, LogImpact.High,
                 $"{ToPrettyString(uid):entity} exploded ({typeId}) at {pos.Coordinates:coordinates} with intensity {totalIntensity} slope {slope}");
+        }
         else
+        {
             _adminLogger.Add(LogType.Explosion, LogImpact.High,
                 $"{ToPrettyString(user.Value):user} caused {ToPrettyString(uid):entity} to explode ({typeId}) at {pos.Coordinates:coordinates} with intensity {totalIntensity} slope {slope}");
+            var alertMinExplosionIntensity = _cfg.GetCVar(CCVars.AdminAlertExplosionMinIntensity);
+            if (alertMinExplosionIntensity > -1 && totalIntensity >= alertMinExplosionIntensity)
+                _chat.SendAdminAlert(user.Value, $"caused {ToPrettyString(uid)} to explode ({typeId}:{totalIntensity}) at {pos.Coordinates:coordinates}");
+        }
     }
 
     /// <summary>
index 74584c1835d51a14932e7e8fead848145bb706c4..a5d5b37d245867cf87e75ed732447dadc4357d67 100644 (file)
@@ -604,6 +604,12 @@ namespace Content.Shared.CCVar
         public static readonly CVarDef<bool> AdminAnnounceLogout =
             CVarDef.Create("admin.announce_logout", true, CVar.SERVERONLY);
 
+        /// <summary>
+        ///     Minimum explosion intensity to create an admin alert message. -1 to disable the alert.
+        /// </summary>
+        public static readonly CVarDef<int> AdminAlertExplosionMinIntensity =
+            CVarDef.Create("admin.alert.explosion_min_intensity", 60, CVar.SERVERONLY);
+
         /*
          * Explosions
          */