From c76414362d0b8b4598447df00e63b3c10da7874c Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Sat, 5 Mar 2022 10:58:30 +0100 Subject: [PATCH] Account for graph actions being able to delete the entity in ChangeNode. Fixes an exception that occurs if a node action deletes a construction. --- Content.Server/Construction/ConstructionSystem.Graph.cs | 4 ++++ .../Construction/ConstructionSystem.Interactions.cs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Content.Server/Construction/ConstructionSystem.Graph.cs b/Content.Server/Construction/ConstructionSystem.Graph.cs index d1467da430..21fbd560bd 100644 --- a/Content.Server/Construction/ConstructionSystem.Graph.cs +++ b/Content.Server/Construction/ConstructionSystem.Graph.cs @@ -140,6 +140,10 @@ namespace Content.Server.Construction if(performActions) PerformActions(uid, userUid, node.Actions); + // An action might have deleted the entity... Account for this. + if (!Exists(uid)) + return false; + // ChangeEntity will handle the pathfinding update. if (node.Entity is {} newEntity && ChangeEntity(uid, userUid, newEntity, construction) != null) return true; diff --git a/Content.Server/Construction/ConstructionSystem.Interactions.cs b/Content.Server/Construction/ConstructionSystem.Interactions.cs index 8d5d2bbaa8..3b7f670644 100644 --- a/Content.Server/Construction/ConstructionSystem.Interactions.cs +++ b/Content.Server/Construction/ConstructionSystem.Interactions.cs @@ -403,7 +403,7 @@ namespace Content.Server.Construction foreach (var action in actions) { // If an action deletes the entity, we stop performing actions. - if (!EntityManager.EntityExists(uid)) + if (!Exists(uid)) break; action.PerformAction(uid, userUid, EntityManager);