diff --git a/Content.Server/Administration/Systems/AdminSystem.cs b/Content.Server/Administration/Systems/AdminSystem.cs index ce18a1e4f7263a..620880360359f8 100644 --- a/Content.Server/Administration/Systems/AdminSystem.cs +++ b/Content.Server/Administration/Systems/AdminSystem.cs @@ -337,10 +337,15 @@ private void OnBabyJailMaxOverallMinutesChanged(int minutes) 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. diff --git a/Content.Shared/Administration/AdminData.cs b/Content.Shared/Administration/AdminData.cs index 229edbcd4c365b..bad36f78c57e49 100644 --- a/Content.Shared/Administration/AdminData.cs +++ b/Content.Shared/Administration/AdminData.cs @@ -31,10 +31,11 @@ public sealed class AdminData /// Checks whether this admin has an admin flag. /// /// The flags to check. Multiple flags can be specified, they must all be held. + /// If true then also count flags even if the admin has de-adminned. /// False if this admin is not or does not have all the flags specified. - public bool HasFlag(AdminFlags flag) + public bool HasFlag(AdminFlags flag, bool includeDeAdmin = false) { - return Active && (Flags & flag) == flag; + return (includeDeAdmin || Active) && (Flags & flag) == flag; } /// diff --git a/Content.Shared/Administration/Managers/ISharedAdminManager.cs b/Content.Shared/Administration/Managers/ISharedAdminManager.cs index 22d918d4a33ca2..f24d7f37d9ad3d 100644 --- a/Content.Shared/Administration/Managers/ISharedAdminManager.cs +++ b/Content.Shared/Administration/Managers/ISharedAdminManager.cs @@ -18,7 +18,7 @@ public interface ISharedAdminManager /// /// if the player is not an admin. AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false); - + /// /// Gets the admin data for a player, if they are an admin. /// @@ -37,24 +37,30 @@ public interface ISharedAdminManager /// /// When used by the client, this only returns accurate results for the player's own entity. /// + /// + /// Whether to check flags even for admins that are current de-adminned. + /// /// True if the player is and admin and has the specified flags. - 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); } - + /// /// See if a player has an admin flag. /// /// /// When used by the client, this only returns accurate results for the player's own session. /// + /// + /// Whether to check flags even for admins that are current de-adminned. + /// /// True if the player is and admin and has the specified flags. - 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); } /// @@ -71,7 +77,7 @@ bool IsAdmin(EntityUid uid, bool includeDeAdmin = false) { return GetAdminData(uid, includeDeAdmin) != null; } - + /// /// Checks if a player is an admin. /// diff --git a/Content.Shared/CCVar/CCVars.Game.cs b/Content.Shared/CCVar/CCVars.Game.cs index 19092055e39f46..d74b46c7cccb8c 100644 --- a/Content.Shared/CCVar/CCVars.Game.cs +++ b/Content.Shared/CCVar/CCVars.Game.cs @@ -154,6 +154,7 @@ public static readonly CVarDef /// /// Whether or not the panic bunker will enable when no admins are online. + /// This counts everyone with the 'Admin' AdminFlag. /// public static readonly CVarDef PanicBunkerEnableWithoutAdmins = CVarDef.Create("game.panic_bunker.enable_without_admins", false, CVar.SERVERONLY);