From cb768d2aa5ffe3e4658941c9c40eb531e67adc52 Mon Sep 17 00:00:00 2001 From: metalgearsloth Date: Thu, 18 Jun 2026 17:21:47 +1000 Subject: [PATCH] Raise a BUI message on any input The bound wrapper is internal only and I don't want these filtered out by UI validation. --- Robust.Server/GameObjects/EntitySystems/InputSystem.cs | 4 ++-- .../Components/UserInterface/UserInterfaceComponent.cs | 9 +++++++++ .../GameObjects/Systems/SharedUserInterfaceSystem.cs | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Robust.Server/GameObjects/EntitySystems/InputSystem.cs b/Robust.Server/GameObjects/EntitySystems/InputSystem.cs index 57a5ab2a15..5c844ba1c1 100644 --- a/Robust.Server/GameObjects/EntitySystems/InputSystem.cs +++ b/Robust.Server/GameObjects/EntitySystems/InputSystem.cs @@ -38,7 +38,7 @@ namespace Robust.Server.GameObjects private void InputMessageHandler(InputCmdMessage message, EntitySessionEventArgs eventArgs) { - if (!(message is FullInputCmdMessage msg)) + if (message is not FullInputCmdMessage msg) return; //Client Sanitization: out of bounds functionID @@ -46,7 +46,7 @@ namespace Robust.Server.GameObjects return; //Client Sanitization: bad enum key state value - if (!Enum.IsDefined(typeof(BoundKeyState), msg.State)) + if (!Enum.IsDefined(msg.State)) return; var session = eventArgs.SenderSession; diff --git a/Robust.Shared/GameObjects/Components/UserInterface/UserInterfaceComponent.cs b/Robust.Shared/GameObjects/Components/UserInterface/UserInterfaceComponent.cs index b44986238e..1e6f890be2 100644 --- a/Robust.Shared/GameObjects/Components/UserInterface/UserInterfaceComponent.cs +++ b/Robust.Shared/GameObjects/Components/UserInterface/UserInterfaceComponent.cs @@ -160,6 +160,15 @@ namespace Robust.Shared.GameObjects public readonly BoundUserInterfaceMessage Message = message; } + /// + /// Raised whenever the server receives a BUI wrap message from a client for a valid interface. + /// + [ByRefEvent] + public readonly record struct BoundUserInterfaceMessageReceivedEvent( + EntityUid Actor, + EntityUid Target, + Enum UiKey); + [NetSerializable, Serializable] public abstract class BoundUserInterfaceState { diff --git a/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs b/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs index 7012d65c72..5b07899cce 100644 --- a/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs +++ b/Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs @@ -107,6 +107,9 @@ public abstract partial class SharedUserInterfaceSystem : EntitySystem return; } + var received = new BoundUserInterfaceMessageReceivedEvent(sender, uid, msg.UiKey); + RaiseLocalEvent(ref received); + // If it's not an open message check we're even a subscriber. if (msg.Message is not OpenBoundInterfaceMessage && (!uiComp.Actors.TryGetValue(msg.UiKey, out var actors) ||