diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 90924188b2..8f62ca4758 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -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; diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index f88989051f..bd821f2937 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -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}"); + } } /// diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 74584c1835..a5d5b37d24 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -604,6 +604,12 @@ namespace Content.Shared.CCVar public static readonly CVarDef AdminAnnounceLogout = CVarDef.Create("admin.announce_logout", true, CVar.SERVERONLY); + /// + /// Minimum explosion intensity to create an admin alert message. -1 to disable the alert. + /// + public static readonly CVarDef AdminAlertExplosionMinIntensity = + CVarDef.Create("admin.alert.explosion_min_intensity", 60, CVar.SERVERONLY); + /* * Explosions */