]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add admin alerts (#13589)
authorChief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
Thu, 23 Mar 2023 15:10:49 +0000 (10:10 -0500)
committerGitHub <noreply@github.com>
Thu, 23 Mar 2023 15:10:49 +0000 (11:10 -0400)
Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
Content.Client/UserInterface/Systems/Chat/Controls/ChannelFilterPopup.xaml.cs
Content.Server/AME/AMENodeGroup.cs
Content.Server/AME/Components/AMEControllerComponent.cs
Content.Server/Administration/Systems/AdminSystem.cs
Content.Server/Chat/Managers/ChatManager.cs
Content.Server/Chat/Managers/IChatManager.cs
Content.Shared/Chat/ChatChannel.cs
Content.Shared/Chat/ChatChannelExtensions.cs
Resources/Locale/en-US/chat/ui/chat-box.ftl

index efc9929cc0e2651ffbaa61a0c38e544c96e22f40..64d9b05a32079f184084a05ee72ab28edb805691 100644 (file)
@@ -496,6 +496,7 @@ public sealed class ChatUIController : UIController
         if (_admin.HasFlag(AdminFlags.Admin))
         {
             FilterableChannels |= ChatChannel.Admin;
+            FilterableChannels |= ChatChannel.AdminAlert;
             FilterableChannels |= ChatChannel.AdminChat;
             CanSendChannels |= ChatSelectChannel.Admin;
         }
index 92149bfb80c9855f8edb3e8bdf9a31265c4fcdf5..4a3b9aa568eec180204cc1cceefb2780e8872cd5 100644 (file)
@@ -20,6 +20,7 @@ public sealed partial class ChannelFilterPopup : Popup
         ChatChannel.OOC,
         ChatChannel.Dead,
         ChatChannel.Admin,
+        ChatChannel.AdminAlert,
         ChatChannel.AdminChat,
         ChatChannel.Server
     };
index f0527966d9775d1ab141732c9f22a4ea9cbba403..7a347ffb6fae2e2f34026a87b0528bdacac13bd1 100644 (file)
@@ -1,5 +1,7 @@
 using System.Linq;
+using Content.Server.Administration.Systems;
 using Content.Server.AME.Components;
+using Content.Server.Chat.Managers;
 using Content.Server.Explosion.EntitySystems;
 using Content.Server.NodeContainer.NodeGroups;
 using Content.Server.NodeContainer.Nodes;
@@ -27,6 +29,8 @@ namespace Content.Server.AME
 
         [Dependency] private readonly IEntityManager _entMan = default!;
 
+        [Dependency] private readonly IChatManager _chat = default!;
+
         public AMEControllerComponent? MasterController => _masterController;
 
         private readonly List<AMEShieldComponent> _cores = new();
@@ -133,10 +137,21 @@ namespace Content.Server.AME
                     if (instability != 0)
                     {
                         overloading = true;
+                        var integrityCheck = 100;
                         foreach(AMEShieldComponent core in _cores)
                         {
+                            var oldIntegrity = core.CoreIntegrity;
                             core.CoreIntegrity -= instability;
+
+                            if (oldIntegrity > 95
+                                && core.CoreIntegrity <= 95
+                                && core.CoreIntegrity < integrityCheck)
+                                integrityCheck = core.CoreIntegrity;
                         }
+
+                        // Admin alert
+                        if (integrityCheck != 100 && _masterController != null)
+                            _chat.SendAdminAlert($"AME overloading: {_entMan.ToPrettyString(_masterController.Owner)}");
                     }
                 }
                 // Note the float conversions. The maths will completely fail if not done using floats.
index 032486c82e458409778deeced4a7a7a7c2dd4e63..1a398a5eb5580803e5561f87f2677979880b019d 100644 (file)
@@ -1,5 +1,7 @@
 using System.Linq;
 using Content.Server.Administration.Logs;
+using Content.Server.Administration.Systems;
+using Content.Server.Chat.Managers;
 using Content.Server.Mind.Components;
 using Content.Server.NodeContainer;
 using Content.Server.Power.Components;
@@ -20,6 +22,7 @@ namespace Content.Server.AME.Components
         [Dependency] private readonly IEntityManager _entities = default!;
         [Dependency] private readonly IEntitySystemManager _sysMan = default!;
         [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+        [Dependency] private readonly IChatManager _chat = default!;
 
         [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(AMEControllerUiKey.Key);
         private bool _injecting;
@@ -183,6 +186,10 @@ namespace Content.Server.AME.Components
 
                 if (msg.Button == UiButton.ToggleInjection)
                     _adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{_entities.ToPrettyString(mindComponent.Owner):player} has set the AME to {humanReadableState}");
+
+                // Admin alert
+                if (GetCoreCount() * 2 == InjectionAmount - 2 && msg.Button == UiButton.IncreaseFuel)
+                    _chat.SendAdminAlert(player, $"increased AME over safe limit to {InjectionAmount}", mindComponent);
             }
 
             GetAMENodeGroup()?.UpdateCoreVisuals();
index 9de05e952d3dc2c8f8c33742964eca0a7b586f84..48751e02c6af52165bebd283e851bd9e0daab985 100644 (file)
@@ -83,6 +83,15 @@ namespace Content.Server.Administration.Systems
             }
         }
 
+        public PlayerInfo? GetCachedPlayerInfo(NetUserId? netUserId)
+        {
+            if (netUserId == null)
+                return null;
+
+            _playerList.TryGetValue(netUserId.Value, out var value);
+            return value ?? null;
+        }
+
         private void OnIdentityChanged(IdentityChangedEvent ev)
         {
             if (!TryComp<ActorComponent>(ev.CharacterEntity, out var actor))
index 3432321b315c6f002271856cb557c7b813680459..90924188b265646233cb955a61aa9694a406d694 100644 (file)
@@ -1,6 +1,8 @@
 using System.Linq;
 using Content.Server.Administration.Logs;
 using Content.Server.Administration.Managers;
+using Content.Server.Administration.Systems;
+using Content.Server.Mind.Components;
 using Content.Server.MoMMI;
 using Content.Server.Preferences.Managers;
 using Content.Server.Station.Systems;
@@ -39,6 +41,7 @@ namespace Content.Server.Chat.Managers
         [Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
         [Dependency] private readonly IConfigurationManager _configurationManager = default!;
         [Dependency] private readonly INetConfigurationManager _netConfigManager = default!;
+        [Dependency] private readonly IEntityManager _entityManager = default!;
 
         /// <summary>
         /// The maximum length a player-sent message can be sent
@@ -103,6 +106,31 @@ namespace Content.Server.Chat.Managers
             _adminLogger.Add(LogType.Chat, LogImpact.Low, $"Admin announcement: {message}");
         }
 
+        public void SendAdminAlert(string message)
+        {
+            var clients = _adminManager.ActiveAdmins.Select(p => p.ConnectedClient);
+
+            var wrappedMessage = Loc.GetString("chat-manager-send-admin-announcement-wrap-message",
+                ("adminChannelName", Loc.GetString("chat-manager-admin-channel-name")), ("message", FormattedMessage.EscapeText(message)));
+
+            ChatMessageToMany(ChatChannel.AdminAlert, message, wrappedMessage, default, false, true, clients);
+        }
+
+        public void SendAdminAlert(EntityUid player, string message, MindComponent? mindComponent = null)
+        {
+            if(mindComponent == null && !_entityManager.TryGetComponent(player, out mindComponent))
+            {
+                SendAdminAlert(message);
+                return;
+            }
+
+            var adminSystem = _entityManager.System<AdminSystem>();
+            var antag = mindComponent.Mind!.UserId != null
+                        && (adminSystem.GetCachedPlayerInfo(mindComponent.Mind!.UserId.Value)?.Antag ?? false);
+
+            SendAdminAlert($"{mindComponent.Mind!.Session?.Name}{(antag ? " (ANTAG)" : "")} {message}");
+        }
+
         public void SendHookOOC(string sender, string message)
         {
             if (!_oocEnabled && _configurationManager.GetCVar(CCVars.DisablingOOCDisablesRelay))
index b860da96244ee952e131449442280187b7295582..6d74f76422b2b6948efb488c182f7223b0a9cf20 100644 (file)
@@ -1,3 +1,4 @@
+using Content.Server.Mind.Components;
 using Content.Shared.Chat;
 using Robust.Server.Player;
 using Robust.Shared.Network;
@@ -22,6 +23,8 @@ namespace Content.Server.Chat.Managers
 
         void SendHookOOC(string sender, string message);
         void SendAdminAnnouncement(string message);
+        void SendAdminAlert(string message);
+        void SendAdminAlert(EntityUid player, string message, MindComponent? mindComponent = null);
 
         void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat,
             INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0);
index 3ea6435908586438fbe1a1f236dbe668416407ca..a80deda37a9998b99861b2934919c036355c241f 100644 (file)
@@ -64,15 +64,20 @@ namespace Content.Shared.Chat
         /// </summary>
         Admin = 1 << 10,
 
+        /// <summary>
+        ///     Admin alerts, messages likely of elevated importance to admins
+        /// </summary>
+        AdminAlert = 1 << 11,
+
         /// <summary>
         ///     Admin chat
         /// </summary>
-        AdminChat = 1 << 11,
+        AdminChat = 1 << 12,
 
         /// <summary>
         ///     Unspecified.
         /// </summary>
-        Unspecified = 1 << 12,
+        Unspecified = 1 << 13,
 
         /// <summary>
         ///     Channels considered to be IC.
index 505f032331207ad0f544bb215512ece326d558a8..9b707a53a0e22540df4c4fbf7d2d5b0049bd5836 100644 (file)
@@ -12,6 +12,7 @@ public static class ChatChannelExtensions
             ChatChannel.OOC => Color.LightSkyBlue,
             ChatChannel.Dead => Color.MediumPurple,
             ChatChannel.Admin => Color.Red,
+            ChatChannel.AdminAlert => Color.Red,
             ChatChannel.AdminChat => Color.HotPink,
             ChatChannel.Whisper => Color.DarkGray,
             _ => Color.LightGray
index 29b3403aa39cd31dea07097379f2e99a8dd1b83c..ddf52d8be8a42b2121a3644670cd524c770fa5db 100644 (file)
@@ -14,6 +14,7 @@ hud-chatbox-select-channel-Visual = Actions
 hud-chatbox-select-channel-Radio = Radio
 
 hud-chatbox-channel-Admin = Admin Misc
+hud-chatbox-channel-AdminAlert = Admin Alert
 hud-chatbox-channel-AdminChat = Admin Chat
 hud-chatbox-channel-Dead = Dead
 hud-chatbox-channel-Emotes = Emotes