From f724b9ea7d6de609b587fcd1453b1e7d338a5016 Mon Sep 17 00:00:00 2001 From: Whatstone <166147148+whatston3@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:21:28 -0400 Subject: [PATCH] Make LP Bravo and Pirate Cove admin-only warp points. (#2120) * Admin-only warp points * Remove unused admin dependency --- Content.Server/Ghost/GhostSystem.cs | 23 +++++++++++++++++-- Content.Server/Warps/WarpPointComponent.cs | 8 +++++++ Content.Shared/Ghost/SharedGhostSystem.cs | 7 ++++++ .../_NF/Entities/Markers/warp_point.yml | 2 ++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index ce8b574c4e1..9d545cbd6fb 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Administration.Logs; +using Content.Server.Administration.Managers; // Frontier using Content.Server.Chat.Managers; using Content.Server.GameTicking; using Content.Server.Ghost.Components; @@ -62,6 +63,7 @@ public sealed class GhostSystem : SharedGhostSystem [Dependency] private readonly SharedMindSystem _mind = default!; [Dependency] private readonly GameTicker _gameTicker = default!; [Dependency] private readonly DamageableSystem _damageable = default!; + [Dependency] private readonly IAdminManager _admin = default!; // Frontier private EntityQuery _ghostQuery; private EntityQuery _physicsQuery; @@ -292,7 +294,10 @@ private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventA return; } - var response = new GhostWarpsResponseEvent(GetPlayerWarps(entity).Concat(GetLocationWarps()).ToList()); + // Frontier: get admin status for entity. + bool isAdmin = _admin.IsAdmin(entity); + + var response = new GhostWarpsResponseEvent(GetPlayerWarps(entity).Concat(GetLocationWarps(isAdmin)).ToList()); // Frontier: add isAdmin RaiseNetworkEvent(response, args.SenderSession.Channel); } @@ -313,6 +318,17 @@ private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, Entit return; } + // Frontier: check admin status when warping to admin-only warp points + if (_admin.IsAdmin(attached) && + TryComp(target, out var warpPoint) && + warpPoint.AdminOnly) + { + Log.Warning($"User {args.SenderSession.Name} tried to warp to an admin-only warp point: {msg.Target}"); + _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(attached):player} tried to warp to admin warp point {EntityManager.ToPrettyString(msg.Target)}"); + return; + } + // End Frontier + WarpTo(attached, target); } @@ -346,12 +362,15 @@ private void WarpTo(EntityUid uid, EntityUid target) _physics.SetLinearVelocity(uid, Vector2.Zero, body: physics); } - private IEnumerable GetLocationWarps() + private IEnumerable GetLocationWarps(bool isAdmin) // Frontier: add isAdmin { var allQuery = AllEntityQuery(); while (allQuery.MoveNext(out var uid, out var warp)) { + if (warp.AdminOnly && !isAdmin) // Frontier: skip admin-only warp points if not an admin + continue; // Frontier + yield return new GhostWarp(GetNetEntity(uid), warp.Location ?? Name(uid), true); } } diff --git a/Content.Server/Warps/WarpPointComponent.cs b/Content.Server/Warps/WarpPointComponent.cs index 86ab8a7826e..4876a55a7ab 100644 --- a/Content.Server/Warps/WarpPointComponent.cs +++ b/Content.Server/Warps/WarpPointComponent.cs @@ -21,5 +21,13 @@ public sealed partial class WarpPointComponent : Component [ViewVariables(VVAccess.ReadWrite)] [DataField("useStationName")] public bool UseStationName; + + /// + /// Frontier - If true, warp point can only be used by admins + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("adminOnly")] + public bool AdminOnly; + // End Frontier } } diff --git a/Content.Shared/Ghost/SharedGhostSystem.cs b/Content.Shared/Ghost/SharedGhostSystem.cs index 6e62bee1310..756d69b2b47 100644 --- a/Content.Shared/Ghost/SharedGhostSystem.cs +++ b/Content.Shared/Ghost/SharedGhostSystem.cs @@ -97,6 +97,13 @@ public GhostWarp(NetEntity entity, string displayName, bool isWarpPoint) /// Whether this warp represents a warp point or a player /// public bool IsWarpPoint { get; } + + // Frontier: warp point hiding + /// + /// Whether this warp requires admin access to warp to + /// + public bool AdminOnly { get; } + // End Frontier } /// diff --git a/Resources/Prototypes/_NF/Entities/Markers/warp_point.yml b/Resources/Prototypes/_NF/Entities/Markers/warp_point.yml index e4506bf0254..f603bb160d7 100644 --- a/Resources/Prototypes/_NF/Entities/Markers/warp_point.yml +++ b/Resources/Prototypes/_NF/Entities/Markers/warp_point.yml @@ -34,6 +34,7 @@ components: - type: WarpPoint location: "Listening Point: Bravo" + adminOnly: true - type: entity id: WarpPointNFLodge @@ -124,6 +125,7 @@ components: - type: WarpPoint location: Pirate's Cove + adminOnly: true - type: entity id: WarpPointNFGrifty