]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Only disable panicbunker for admins with AdminFlags.Admin (#33879)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Wed, 18 Dec 2024 13:15:04 +0000 (14:15 +0100)
committerGitHub <noreply@github.com>
Wed, 18 Dec 2024 13:15:04 +0000 (14:15 +0100)
* Only disable panicbunker for admins with AdminFlags.Admin

* nicer curly braces

Content.Server/Administration/Systems/AdminSystem.cs
Content.Shared/Administration/AdminData.cs
Content.Shared/Administration/Managers/ISharedAdminManager.cs
Content.Shared/CCVar/CCVars.Game.cs

index ce18a1e4f7263a5577b6cb7347072f61cca0c93c..620880360359f8546cb970a9316b68b5a063dcf0 100644 (file)
@@ -337,10 +337,15 @@ public sealed class AdminSystem : EntitySystem
 
     private void UpdatePanicBunker()
     {
-        var admins = PanicBunker.CountDeadminnedAdmins
-            ? _adminManager.AllAdmins
-            : _adminManager.ActiveAdmins;
-        var hasAdmins = admins.Any();
+        var hasAdmins = false;
+        foreach (var admin in _adminManager.AllAdmins)
+        {
+            if (_adminManager.HasAdminFlag(admin, AdminFlags.Admin, includeDeAdmin: PanicBunker.CountDeadminnedAdmins))
+            {
+                hasAdmins = true;
+                break;
+            }
+        }
 
         // TODO Fix order dependent Cvars
         // Please for the sake of my sanity don't make cvars & order dependent.
index 229edbcd4c365bd4a9674eb36d3901f1ce5026d5..bad36f78c57e4984a87e2e1fee61c06f7e3d7c85 100644 (file)
@@ -31,10 +31,11 @@ namespace Content.Shared.Administration
         ///     Checks whether this admin has an admin flag.
         /// </summary>
         /// <param name="flag">The flags to check. Multiple flags can be specified, they must all be held.</param>
+        /// <param name="includeDeAdmin">If true then also count flags even if the admin has de-adminned.</param>
         /// <returns>False if this admin is not <see cref="Active"/> or does not have all the flags specified.</returns>
-        public bool HasFlag(AdminFlags flag)
+        public bool HasFlag(AdminFlags flag, bool includeDeAdmin = false)
         {
-            return Active && (Flags & flag) == flag;
+            return (includeDeAdmin || Active) && (Flags & flag) == flag;
         }
 
         /// <summary>
index 22d918d4a33ca28fc2e5b16e8f08d18cda547e65..f24d7f37d9ad3d7b4937b14c1895d634ec4fb65f 100644 (file)
@@ -18,7 +18,7 @@ public interface ISharedAdminManager
     /// </param>
     /// <returns><see langword="null" /> if the player is not an admin.</returns>
     AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false);
-    
+
     /// <summary>
     ///     Gets the admin data for a player, if they are an admin.
     /// </summary>
@@ -37,24 +37,30 @@ public interface ISharedAdminManager
     /// <remarks>
     ///     When used by the client, this only returns accurate results for the player's own entity.
     /// </remarks>
+    /// <param name="includeDeAdmin">
+    ///     Whether to check flags even for admins that are current de-adminned.
+    /// </param>
     /// <returns>True if the player is and admin and has the specified flags.</returns>
-    bool HasAdminFlag(EntityUid player, AdminFlags flag)
+    bool HasAdminFlag(EntityUid player, AdminFlags flag, bool includeDeAdmin = false)
     {
-        var data = GetAdminData(player);
-        return data != null && data.HasFlag(flag);
+        var data = GetAdminData(player, includeDeAdmin);
+        return data != null && data.HasFlag(flag, includeDeAdmin);
     }
-    
+
     /// <summary>
     ///     See if a player has an admin flag.
     /// </summary>
     /// <remarks>
     ///     When used by the client, this only returns accurate results for the player's own session.
     /// </remarks>
+    /// <param name="includeDeAdmin">
+    ///     Whether to check flags even for admins that are current de-adminned.
+    /// </param>
     /// <returns>True if the player is and admin and has the specified flags.</returns>
-    bool HasAdminFlag(ICommonSession player, AdminFlags flag)
+    bool HasAdminFlag(ICommonSession player, AdminFlags flag, bool includeDeAdmin = false)
     {
-        var data = GetAdminData(player);
-        return data != null && data.HasFlag(flag);
+        var data = GetAdminData(player, includeDeAdmin);
+        return data != null && data.HasFlag(flag, includeDeAdmin);
     }
 
     /// <summary>
@@ -71,7 +77,7 @@ public interface ISharedAdminManager
     {
         return GetAdminData(uid, includeDeAdmin) != null;
     }
-    
+
     /// <summary>
     ///     Checks if a player is an admin.
     /// </summary>
index 19092055e39f46e16830e5372b0f466fb31f41ef..d74b46c7cccb8cfaa66f8c7cba7d3734a0ba49d5 100644 (file)
@@ -154,6 +154,7 @@ public sealed partial class CCVars
 
         /// <summary>
         ///     Whether or not the panic bunker will enable when no admins are online.
+        ///     This counts everyone with the 'Admin' AdminFlag.
         /// </summary>
         public static readonly CVarDef<bool> PanicBunkerEnableWithoutAdmins =
             CVarDef.Create("game.panic_bunker.enable_without_admins", false, CVar.SERVERONLY);