]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Don't enqueue construction events without validation (#39869)
authorpathetic meowmeow <uhhadd@gmail.com>
Wed, 3 Sep 2025 21:29:50 +0000 (17:29 -0400)
committerGitHub <noreply@github.com>
Wed, 3 Sep 2025 21:29:50 +0000 (14:29 -0700)
Content.IntegrationTests/Tests/Construction/Interaction/EdgeClobbering.cs [new file with mode: 0644]
Content.Server/Construction/ConstructionSystem.Interactions.cs

diff --git a/Content.IntegrationTests/Tests/Construction/Interaction/EdgeClobbering.cs b/Content.IntegrationTests/Tests/Construction/Interaction/EdgeClobbering.cs
new file mode 100644 (file)
index 0000000..9f57814
--- /dev/null
@@ -0,0 +1,49 @@
+using Content.IntegrationTests.Tests.Interaction;
+using Content.Server.Construction.Components;
+using Content.Shared.Temperature;
+
+namespace Content.IntegrationTests.Tests.Construction.Interaction;
+
+public sealed class EdgeClobbering : InteractionTest
+{
+    [TestPrototypes]
+    private const string Prototypes = @"
+- type: constructionGraph
+  id: ExampleGraph
+  start: A
+  graph:
+  - node: A
+    edges:
+    - to: B
+      steps:
+      - tool: Anchoring
+        doAfter: 1
+    - to: C
+      steps:
+      - tool: Screwing
+        doAfter: 1
+  - node: B
+  - node: C
+
+- type: entity
+  id: ExampleEntity
+  components:
+  - type: Construction
+    graph: ExampleGraph
+    node: A
+
+    ";
+
+    [Test]
+    public async Task EnsureNoEdgeClobbering()
+    {
+        await SpawnTarget("ExampleEntity");
+        var sTarget = SEntMan.GetEntity(Target!.Value);
+
+        await InteractUsing(Screw, false);
+        SEntMan.EventBus.RaiseLocalEvent(sTarget, new OnTemperatureChangeEvent(0f, 0f, 0f));
+        await AwaitDoAfters();
+
+        Assert.That(SEntMan.GetComponent<ConstructionComponent>(sTarget).Node, Is.EqualTo("C"));
+    }
+}
index dd69fe4e13804bb24cee14949243afac42266879..3dd5a5b794bc678d13ddd7d12a38342ba8bfd767 100644 (file)
@@ -570,6 +570,10 @@ namespace Content.Server.Construction
                 handled.Handled = true;
             }
 
+            // Make sure the event passes validation before enqueuing it
+            if (HandleEvent(uid, args, true, construction) != HandleResult.Validated)
+                return;
+
             // Enqueue this event so it'll be handled in the next tick.
             // This prevents some issues that could occur from entity deletion, component deletion, etc in a handler.
             construction.InteractionQueue.Enqueue(args);