]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix admin ghosts not being able to see items in pockets or interact with them (#31076)
authorDrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Fri, 22 Nov 2024 02:56:05 +0000 (18:56 -0800)
committerGitHub <noreply@github.com>
Fri, 22 Nov 2024 02:56:05 +0000 (03:56 +0100)
* Fix admin ghosts not being able to see items in pouches or interact with them

* fix

* oops

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Client/Inventory/StrippableBoundUserInterface.cs
Content.Shared/Interaction/SharedInteractionSystem.cs
Content.Shared/Inventory/InventorySystem.Equip.cs
Content.Shared/Inventory/InventorySystem.Relay.cs
Content.Shared/Inventory/InventoryTemplatePrototype.cs
Content.Shared/Strip/SharedStrippableSystem.cs

index 2ce07758c9641d5044f97a4e9b481191774d2f73..af7815935ddf8e8775acf4338f7392e22aafc521 100644 (file)
@@ -17,6 +17,7 @@ using Content.Shared.Inventory.VirtualItem;
 using Content.Shared.Strip.Components;
 using JetBrains.Annotations;
 using Robust.Client.GameObjects;
+using Robust.Client.Player;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Shared.Input;
@@ -29,10 +30,13 @@ namespace Content.Client.Inventory
     [UsedImplicitly]
     public sealed class StrippableBoundUserInterface : BoundUserInterface
     {
+        [Dependency] private readonly IPlayerManager _player = default!;
         [Dependency] private readonly IUserInterfaceManager _ui = default!;
+
         private readonly ExamineSystem _examine;
         private readonly InventorySystem _inv;
         private readonly SharedCuffableSystem _cuffable;
+        private readonly StrippableSystem _strippable;
 
         [ViewVariables]
         private const int ButtonSeparation = 4;
@@ -51,6 +55,8 @@ namespace Content.Client.Inventory
             _examine = EntMan.System<ExamineSystem>();
             _inv = EntMan.System<InventorySystem>();
             _cuffable = EntMan.System<SharedCuffableSystem>();
+            _strippable = EntMan.System<StrippableSystem>();
+
             _virtualHiddenEntity = EntMan.SpawnEntity(HiddenPocketEntityId, MapCoordinates.Nullspace);
         }
 
@@ -198,7 +204,8 @@ namespace Content.Client.Inventory
             var entity = container.ContainedEntity;
 
             // If this is a full pocket, obscure the real entity
-            if (entity != null && slotDef.StripHidden)
+            // this does not work for modified clients because they are still sent the real entity
+            if (entity != null && _strippable.IsStripHidden(slotDef, _player.LocalEntity))
                 entity = _virtualHiddenEntity;
 
             var button = new SlotButton(new SlotData(slotDef, container));
index 7f2ecb50f887364ac0eb13bb2b136706369f1260..2926e1d1b388b71d17b8f3db6330170c8fc687b2 100644 (file)
@@ -21,6 +21,7 @@ using Content.Shared.Physics;
 using Content.Shared.Players.RateLimiting;
 using Content.Shared.Popups;
 using Content.Shared.Storage;
+using Content.Shared.Strip;
 using Content.Shared.Tag;
 using Content.Shared.Timing;
 using Content.Shared.UserInterface;
@@ -67,6 +68,7 @@ namespace Content.Shared.Interaction
         [Dependency] private readonly IRobustRandom _random = default!;
         [Dependency] private readonly TagSystem _tagSystem = default!;
         [Dependency] private readonly SharedUserInterfaceSystem _ui = default!;
+        [Dependency] private readonly SharedStrippableSystem _strippable = default!;
         [Dependency] private readonly SharedPlayerRateLimitManager _rateLimit = default!;
         [Dependency] private readonly IConfigurationManager _cfg = default!;
         [Dependency] private readonly ISharedChatManager _chat = default!;
@@ -1321,7 +1323,7 @@ namespace Content.Shared.Interaction
             if (wearer == user)
                 return true;
 
-            if (slotDef.StripHidden)
+            if (_strippable.IsStripHidden(slotDef, user))
                 return false;
 
             return InRangeUnobstructed(user, wearer) && _containerSystem.IsInSameOrParentContainer(user, wearer);
index f089dfaf2381f2a92776179e498843049df4d75d..8158b8c2f62ca901b1f7f18ae76b6916b3eecb75 100644 (file)
@@ -10,6 +10,7 @@ using Content.Shared.Inventory.Events;
 using Content.Shared.Item;
 using Content.Shared.Movement.Systems;
 using Content.Shared.Popups;
+using Content.Shared.Strip;
 using Content.Shared.Strip.Components;
 using Content.Shared.Whitelist;
 using Robust.Shared.Audio.Systems;
@@ -32,6 +33,7 @@ public abstract partial class InventorySystem
     [Dependency] private readonly IGameTiming _gameTiming = default!;
     [Dependency] private readonly SharedTransformSystem _transform = default!;
     [Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
+    [Dependency] private readonly SharedStrippableSystem _strippable = default!;
 
     [ValidatePrototypeId<ItemSizePrototype>]
     private const string PocketableItemSize = "Small";
index 9573f9b43d9df6dbfb54e23206666d09946df4c1..d431195a816621ca2e13840b83d232bf01a6c41c 100644 (file)
@@ -114,7 +114,7 @@ public partial class InventorySystem
         var enumerator = new InventorySlotEnumerator(component);
         while (enumerator.NextItem(out var item, out var slotDef))
         {
-            if (!slotDef.StripHidden || args.User == uid)
+            if (!_strippable.IsStripHidden(slotDef, args.User) || args.User == uid)
                 RaiseLocalEvent(item, ev);
         }
     }
index a4d77767e371431358980c0a26d17680b4798fa8..91accec8c93ee4c68c51ea39ba112485b368004f 100644 (file)
@@ -1,4 +1,5 @@
 using System.Numerics;
+using Content.Shared.Strip;
 using Content.Shared.Whitelist;
 using Robust.Shared.Prototypes;
 
@@ -39,6 +40,10 @@ public sealed partial class SlotDefinition
     [DataField("displayName", required: true)]
     public string DisplayName { get; private set; } = string.Empty;
 
+    /// <summary>
+    ///     Whether or not this slot will have its item hidden in the strip menu, and block interactions.
+    ///     <seealso cref="SharedStrippableSystem.IsStripHidden"/>
+    /// </summary>
     [DataField("stripHidden")] public bool StripHidden { get; private set; }
 
     /// <summary>
index 7afe503275a1d2bab0313bf65fc044e2c66f6e05..e4b31debc666f9bc011e8127d030e7b9fdfd91c4 100644 (file)
@@ -10,6 +10,7 @@ using Content.Shared.Hands.Components;
 using Content.Shared.Hands.EntitySystems;
 using Content.Shared.IdentityManagement;
 using Content.Shared.Interaction;
+using Content.Shared.Interaction.Components;
 using Content.Shared.Interaction.Events;
 using Content.Shared.Inventory;
 using Content.Shared.Inventory.VirtualItem;
@@ -294,7 +295,7 @@ public abstract class SharedStrippableSystem : EntitySystem
 
         if (!stealth)
         {
-            if (slotDef.StripHidden)
+            if (IsStripHidden(slotDef, user))
                 _popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", ("slot", slot)), target, target, PopupType.Large);
             else
                 _popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner", ("user", Identity.Entity(user, EntityManager)), ("item", item)), target, target, PopupType.Large);
@@ -660,4 +661,15 @@ public abstract class SharedStrippableSystem : EntitySystem
         if (args.CanDrop)
             args.Handled = true;
     }
+
+    public bool IsStripHidden(SlotDefinition definition, EntityUid? viewer)
+    {
+        if (!definition.StripHidden)
+            return false;
+
+        if (viewer == null)
+            return true;
+
+        return !HasComp<BypassInteractionChecksComponent>(viewer);
+    }
 }