From 6af4a4d9b8494228dbcc9e5e6037fb7dbe6f9649 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Mon, 14 Apr 2025 02:09:56 +1000 Subject: [PATCH] Fix user interface interaction validation (#36480) --- .../Interaction/SharedInteractionSystem.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 9a2706d8a0..00246bafcd 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -106,7 +106,9 @@ namespace Content.Shared.Interaction _uiQuery = GetEntityQuery(); SubscribeLocalEvent(HandleUserInterfaceRangeCheck); - SubscribeLocalEvent(OnBoundInterfaceInteractAttempt); + + // TODO make this a broadcast event subscription again when engine has updated. + SubscribeLocalEvent(OnBoundInterfaceInteractAttempt); SubscribeAllEvent(HandleInteractInventorySlotEvent); @@ -151,12 +153,15 @@ namespace Content.Shared.Interaction /// /// Check that the user that is interacting with the BUI is capable of interacting and can access the entity. /// - private void OnBoundInterfaceInteractAttempt(Entity ent, ref BoundUserInterfaceMessageAttempt ev) + private void OnBoundInterfaceInteractAttempt(Entity ent, ref BoundUserInterfaceMessageAttempt ev) { + _uiQuery.TryComp(ev.Target, out var aUiComp); if (!_actionBlockerSystem.CanInteract(ev.Actor, ev.Target)) { // We permit ghosts to open uis unless explicitly blocked - if (ev.Message is not OpenBoundInterfaceMessage || !HasComp(ev.Actor) || ent.Comp.BlockSpectators) + if (ev.Message is not OpenBoundInterfaceMessage + || !HasComp(ev.Actor) + || aUiComp?.BlockSpectators == true) { ev.Cancel(); return; @@ -174,14 +179,16 @@ namespace Content.Shared.Interaction return; } + if (aUiComp == null) + return; - if (ent.Comp.SingleUser && ent.Comp.CurrentSingleUser != null && ent.Comp.CurrentSingleUser != ev.Actor) + if (aUiComp.SingleUser && aUiComp.CurrentSingleUser != null && aUiComp.CurrentSingleUser != ev.Actor) { ev.Cancel(); return; } - if (ent.Comp.RequiresComplex && !_actionBlockerSystem.CanComplexInteract(ev.Actor)) + if (aUiComp.RequiresComplex && !_actionBlockerSystem.CanComplexInteract(ev.Actor)) ev.Cancel(); } -- 2.51.2