Only disable panicbunker for admins with AdminFlags.Admin (#33879)
* Only disable panicbunker for admins with AdminFlags.Admin * nicer curly braces
This commit is contained in:
@@ -337,10 +337,15 @@ public sealed class AdminSystem : EntitySystem
|
|||||||
|
|
||||||
private void UpdatePanicBunker()
|
private void UpdatePanicBunker()
|
||||||
{
|
{
|
||||||
var admins = PanicBunker.CountDeadminnedAdmins
|
var hasAdmins = false;
|
||||||
? _adminManager.AllAdmins
|
foreach (var admin in _adminManager.AllAdmins)
|
||||||
: _adminManager.ActiveAdmins;
|
{
|
||||||
var hasAdmins = admins.Any();
|
if (_adminManager.HasAdminFlag(admin, AdminFlags.Admin, includeDeAdmin: PanicBunker.CountDeadminnedAdmins))
|
||||||
|
{
|
||||||
|
hasAdmins = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Fix order dependent Cvars
|
// TODO Fix order dependent Cvars
|
||||||
// Please for the sake of my sanity don't make cvars & order dependent.
|
// Please for the sake of my sanity don't make cvars & order dependent.
|
||||||
|
|||||||
@@ -31,10 +31,11 @@ namespace Content.Shared.Administration
|
|||||||
/// Checks whether this admin has an admin flag.
|
/// Checks whether this admin has an admin flag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="flag">The flags to check. Multiple flags can be specified, they must all be held.</param>
|
/// <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>
|
/// <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>
|
/// <summary>
|
||||||
|
|||||||
@@ -37,11 +37,14 @@ public interface ISharedAdminManager
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// When used by the client, this only returns accurate results for the player's own entity.
|
/// When used by the client, this only returns accurate results for the player's own entity.
|
||||||
/// </remarks>
|
/// </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>
|
/// <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);
|
var data = GetAdminData(player, includeDeAdmin);
|
||||||
return data != null && data.HasFlag(flag);
|
return data != null && data.HasFlag(flag, includeDeAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -50,11 +53,14 @@ public interface ISharedAdminManager
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// When used by the client, this only returns accurate results for the player's own session.
|
/// When used by the client, this only returns accurate results for the player's own session.
|
||||||
/// </remarks>
|
/// </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>
|
/// <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);
|
var data = GetAdminData(player, includeDeAdmin);
|
||||||
return data != null && data.HasFlag(flag);
|
return data != null && data.HasFlag(flag, includeDeAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ public sealed partial class CCVars
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not the panic bunker will enable when no admins are online.
|
/// Whether or not the panic bunker will enable when no admins are online.
|
||||||
|
/// This counts everyone with the 'Admin' AdminFlag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly CVarDef<bool> PanicBunkerEnableWithoutAdmins =
|
public static readonly CVarDef<bool> PanicBunkerEnableWithoutAdmins =
|
||||||
CVarDef.Create("game.panic_bunker.enable_without_admins", false, CVar.SERVERONLY);
|
CVarDef.Create("game.panic_bunker.enable_without_admins", false, CVar.SERVERONLY);
|
||||||
|
|||||||
Reference in New Issue
Block a user