]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix misc construction bugs (#15600)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Fri, 21 Apr 2023 04:01:35 +0000 (16:01 +1200)
committerGitHub <noreply@github.com>
Fri, 21 Apr 2023 04:01:35 +0000 (14:01 +1000)
Content.Server/Construction/Completions/BuildComputer.cs
Content.Server/Construction/ConstructionSystem.Interactions.cs
Content.Shared/Construction/IGraphAction.cs
Resources/Prototypes/Recipes/Construction/Graphs/structures/girder.yml
Resources/Prototypes/Recipes/Construction/Graphs/structures/windoor.yml

index 1c9ac27e705af312e6363013baa5a1e6ebba0a98..c4ec7a1aaddccab49897dfb083911618b2d4d070 100644 (file)
@@ -14,11 +14,12 @@ namespace Content.Server.Construction.Completions
         [DataField("container")] public string Container { get; private set; } = string.Empty;
 
         // TODO use or generalize ConstructionSystem.ChangeEntity();
+        // TODO pass in node/edge & graph ID for better error logs.
         public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
         {
             if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
             {
-                Logger.Warning($"Computer entity {uid} did not have a container manager! Aborting build computer action.");
+                Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have a container manager! Aborting build computer action.");
                 return;
             }
 
@@ -26,20 +27,21 @@ namespace Content.Server.Construction.Completions
 
             if (!containerSystem.TryGetContainer(uid, Container, out var container, containerManager))
             {
-                Logger.Warning($"Computer entity {uid} did not have the specified '{Container}' container! Aborting build computer action.");
+                Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have the specified '{Container}' container! Aborting build computer action.");
                 return;
             }
 
             if (container.ContainedEntities.Count != 1)
             {
-                Logger.Warning($"Computer entity {uid} did not have exactly one item in the specified '{Container}' container! Aborting build computer action.");
+                Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} did not have exactly one item in the specified '{Container}' container! Aborting build computer action.");
+                return;
             }
 
             var board = container.ContainedEntities[0];
 
             if (!entityManager.TryGetComponent(board, out ComputerBoardComponent? boardComponent))
             {
-                Logger.Warning($"Computer entity {uid} had an invalid entity in container \"{Container}\"! Aborting build computer action.");
+                Logger.Error($"Computer entity {entityManager.ToPrettyString(uid)} had an invalid entity in container \"{Container}\"! Aborting build computer action.");
                 return;
             }
 
index fcbea8efdc1dc139e17abd00e1a0a983103c5e5c..97a912cdfe741daed494985b27b664b04d781a8e 100644 (file)
@@ -140,7 +140,7 @@ namespace Content.Server.Construction
 
             if (step == null)
             {
-                _sawmill.Warning($"Called {nameof(HandleEdge)} on entity {uid} but the current state is not valid for that!");
+                _sawmill.Warning($"Called {nameof(HandleEdge)} on entity {ToPrettyString(uid)} but the current state is not valid for that!");
                 return HandleResult.False;
             }
 
@@ -163,6 +163,10 @@ namespace Content.Server.Construction
             {
                 // Edge finished!
                 PerformActions(uid, user, edge.Completed);
+
+                if (construction.Deleted)
+                    return HandleResult.True;
+
                 construction.TargetEdgeIndex = null;
                 construction.EdgeIndex = null;
                 construction.StepIndex = 0;
@@ -470,28 +474,17 @@ namespace Content.Server.Construction
                 {
 #endif
 
-                // temporary code for debugging a grafana exception. Something is fishy with the girder graph.
-                object? prev = null;
-                var queued = string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name));
-
                 // Handle all queued interactions!
                 while (construction.InteractionQueue.TryDequeue(out var interaction))
                 {
                     if (construction.Deleted)
                     {
-                        // I suspect the error might just happen if two users try to deconstruction or otherwise modify an entity at the exact same tick?
-                        // In which case this isn't really an error, but should just be a `if (deleted) -> break`
-                        // But might as well verify this.
-
                         _sawmill.Error($"Construction component was deleted while still processing interactions." +
                             $"Entity {ToPrettyString(uid)}, graph: {construction.Graph}, " +
-                            $"Previous: {prev?.GetType()?.Name ?? "null"}, " +
                             $"Next: {interaction.GetType().Name}, " +
-                            $"Initial Queue: {queued}, " +
                             $"Remaining Queue: {string.Join(", ", construction.InteractionQueue.Select(x => x.GetType().Name))}");
                         break;
                     }
-                    prev = interaction;
 
                     // We set validation to false because we actually want to perform the interaction here.
                     HandleEvent(uid, interaction, false, construction);
index 122ef478cc70b11170f9ce145258999662abae6c..b1aed0be000f8c59db90331985afa2a94d680a19 100644 (file)
@@ -3,6 +3,7 @@
     [ImplicitDataDefinitionForInheritors]
     public interface IGraphAction
     {
+        // TODO pass in node/edge & graph ID for better error logs.
         void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager);
     }
 }
index aa48c02e884311e016a769dbc406cae6bc74a674..7a74fe9a3f2783c4c0d59d480fadee99df325e44 100644 (file)
       entity: WallSolidRust
       edges:
         - to: wall
-          completed:
-            - !type:SpawnPrototype
-              prototype: WallSolid
-              amount: 1
-            - !type:DeleteEntity {}
           steps:
             - tool: Welding
               doAfter: 5
index 434db803942ea970fa27e836446eb8b6e293346c..53caf00ba8f948de0a82de8f4a88df191bded824 100644 (file)
@@ -65,7 +65,6 @@
       - !type:SpawnPrototype
         prototype: SheetGlass1
         amount: 5
-      - !type:DeleteEntity { }
       steps:
       - tool: Screwing
         doAfter: 2
       - !type:SpawnPrototype
         prototype: SheetRGlass1
         amount: 5
-      - !type:DeleteEntity { }
       steps:
       - tool: Screwing
         doAfter: 4