diff --git a/Content.Client/Administration/Managers/ClientAdminManager.cs b/Content.Client/Administration/Managers/ClientAdminManager.cs index 67d847fe51..66c8b8a063 100644 --- a/Content.Client/Administration/Managers/ClientAdminManager.cs +++ b/Content.Client/Administration/Managers/ClientAdminManager.cs @@ -4,6 +4,7 @@ using Robust.Client.Console; using Robust.Client.Player; using Robust.Shared.ContentPack; using Robust.Shared.Network; +using Robust.Shared.Players; using Robust.Shared.Utility; namespace Content.Client.Administration.Managers @@ -121,5 +122,13 @@ namespace Content.Client.Administration.Managers ? _adminData : null; } + + public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false) + { + if (_player.LocalPlayer?.UserId == session.UserId) + return _adminData; + + return null; + } } } diff --git a/Content.Client/Commands/ZoomCommand.cs b/Content.Client/Commands/ZoomCommand.cs index 83a04a241b..2b8cdcbca9 100644 --- a/Content.Client/Commands/ZoomCommand.cs +++ b/Content.Client/Commands/ZoomCommand.cs @@ -64,7 +64,7 @@ public sealed class ZoomCommand : IConsoleCommand if (_entManager.TryGetComponent(player, out var content)) { - _entManager.System().RequestZoom(player.Value, zoom, content); + _entManager.System().RequestZoom(player.Value, zoom, true, content); return; } diff --git a/Content.Client/Movement/Systems/ContentEyeSystem.cs b/Content.Client/Movement/Systems/ContentEyeSystem.cs index 5c65f3f124..afc2363cd6 100644 --- a/Content.Client/Movement/Systems/ContentEyeSystem.cs +++ b/Content.Client/Movement/Systems/ContentEyeSystem.cs @@ -10,7 +10,7 @@ public sealed class ContentEyeSystem : SharedContentEyeSystem { [Dependency] private readonly IPlayerManager _player = default!; - public void RequestZoom(EntityUid uid, Vector2 zoom, ContentEyeComponent? content = null) + public void RequestZoom(EntityUid uid, Vector2 zoom, bool ignoreLimit, ContentEyeComponent? content = null) { if (!Resolve(uid, ref content, false)) return; @@ -18,6 +18,7 @@ public sealed class ContentEyeSystem : SharedContentEyeSystem RaisePredictiveEvent(new RequestTargetZoomEvent() { TargetZoom = zoom, + IgnoreLimit = ignoreLimit, }); } diff --git a/Content.Server/Administration/Managers/AdminManager.cs b/Content.Server/Administration/Managers/AdminManager.cs index 0265e51ae7..c89c47fa95 100644 --- a/Content.Server/Administration/Managers/AdminManager.cs +++ b/Content.Server/Administration/Managers/AdminManager.cs @@ -49,14 +49,14 @@ namespace Content.Server.Administration.Managers private readonly AdminCommandPermissions _commandPermissions = new(); private readonly AdminCommandPermissions _toolshedCommandPermissions = new(); - public bool IsAdmin(IPlayerSession session, bool includeDeAdmin = false) + public bool IsAdmin(ICommonSession session, bool includeDeAdmin = false) { return GetAdminData(session, includeDeAdmin) != null; } - public AdminData? GetAdminData(IPlayerSession session, bool includeDeAdmin = false) + public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false) { - if (_admins.TryGetValue(session, out var reg) && (reg.Data.Active || includeDeAdmin)) + if (_admins.TryGetValue((IPlayerSession)session, out var reg) && (reg.Data.Active || includeDeAdmin)) { return reg.Data; } diff --git a/Content.Server/Administration/Managers/IAdminManager.cs b/Content.Server/Administration/Managers/IAdminManager.cs index f5aa9da23e..eeed5cc36e 100644 --- a/Content.Server/Administration/Managers/IAdminManager.cs +++ b/Content.Server/Administration/Managers/IAdminManager.cs @@ -29,36 +29,6 @@ namespace Content.Server.Administration.Managers /// IEnumerable AllAdmins { get; } - /// - /// Checks if a player is an admin. - /// - /// The player to check. - /// - /// Whether to return admin data for admins that are current de-adminned. - /// - /// true if the player is an admin, false otherwise. - bool IsAdmin(IPlayerSession session, bool includeDeAdmin = false); - - /// - /// Gets the admin data for a player, if they are an admin. - /// - /// The player to get admin data for. - /// - /// Whether to return admin data for admins that are current de-adminned. - /// - /// if the player is not an admin. - AdminData? GetAdminData(IPlayerSession session, bool includeDeAdmin = false); - - /// - /// See if a player has an admin flag. - /// - /// True if the player is and admin and has the specified flags. - bool HasAdminFlag(IPlayerSession player, AdminFlags flag) - { - var data = GetAdminData(player); - return data != null && data.HasFlag(flag); - } - /// /// De-admins an admin temporarily so they are effectively a normal player. /// diff --git a/Content.Shared/Administration/Managers/ISharedAdminManager.cs b/Content.Shared/Administration/Managers/ISharedAdminManager.cs index 34a1a41676..7e01c81433 100644 --- a/Content.Shared/Administration/Managers/ISharedAdminManager.cs +++ b/Content.Shared/Administration/Managers/ISharedAdminManager.cs @@ -1,3 +1,5 @@ +using Robust.Shared.Players; + namespace Content.Shared.Administration.Managers; /// @@ -16,6 +18,18 @@ 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. + /// + /// + /// When used by the client, this only returns accurate results for the player's own session. + /// + /// + /// Whether to return admin data for admins that are current de-adminned. + /// + /// if the player is not an admin. + AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false); /// /// See if a player has an admin flag. @@ -29,6 +43,19 @@ public interface ISharedAdminManager var data = GetAdminData(player); return data != null && data.HasFlag(flag); } + + /// + /// See if a player has an admin flag. + /// + /// + /// When used by the client, this only returns accurate results for the player's own session. + /// + /// True if the player is and admin and has the specified flags. + bool HasAdminFlag(ICommonSession player, AdminFlags flag) + { + var data = GetAdminData(player); + return data != null && data.HasFlag(flag); + } /// /// Checks if a player is an admin. @@ -44,4 +71,19 @@ public interface ISharedAdminManager { return GetAdminData(uid, includeDeAdmin) != null; } + + /// + /// Checks if a player is an admin. + /// + /// + /// When used by the client, this only returns accurate results for the player's own session. + /// + /// + /// Whether to return admin data for admins that are current de-adminned. + /// + /// true if the player is an admin, false otherwise. + bool IsAdmin(ICommonSession session, bool includeDeAdmin = false) + { + return GetAdminData(session, includeDeAdmin) != null; + } } diff --git a/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs b/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs index 4bfe1c22b5..95b5c272d3 100644 --- a/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs +++ b/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs @@ -1,4 +1,5 @@ using System.Numerics; +using Content.Shared.Administration; using Content.Shared.Administration.Managers; using Content.Shared.Ghost; using Content.Shared.Input; @@ -82,8 +83,10 @@ public abstract class SharedContentEyeSystem : EntitySystem private void OnContentZoomRequest(RequestTargetZoomEvent msg, EntitySessionEventArgs args) { + var ignoreLimit = msg.IgnoreLimit && _admin.HasAdminFlag(args.SenderSession, AdminFlags.Debug); + if (TryComp(args.SenderSession.AttachedEntity, out var content)) - SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, eye: content); + SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, ignoreLimit, eye: content); } private void OnRequestFov(RequestFovEvent msg, EntitySessionEventArgs args) @@ -149,6 +152,7 @@ public abstract class SharedContentEyeSystem : EntitySystem public sealed class RequestTargetZoomEvent : EntityEventArgs { public Vector2 TargetZoom; + public bool IgnoreLimit; } ///