]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Action bugfixes (#21321)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Sun, 29 Oct 2023 08:10:30 +0000 (19:10 +1100)
committerGitHub <noreply@github.com>
Sun, 29 Oct 2023 08:10:30 +0000 (19:10 +1100)
Content.Shared/Actions/ActionContainerSystem.cs
Content.Shared/Actions/SharedActionsSystem.cs

index 86d50e3989a943b1aeac02fd11a95c4311ea0fcb..d7c02ffd6328ae3d0548e324503f7d516df6ad6c 100644 (file)
@@ -213,6 +213,9 @@ public sealed class ActionContainerSystem : EntitySystem
 
     private void OnShutdown(EntityUid uid, ActionsContainerComponent component, ComponentShutdown args)
     {
+        if (_timing.ApplyingState && component.NetSyncEnabled)
+            return; // The game state should handle the container removal & action deletion.
+
         component.Container.Shutdown();
     }
 
index 00a17ace250988b5284707624f29cfaee4434734..7384ab30b17092c916483b5512f2a0fe9466645d 100644 (file)
@@ -36,6 +36,8 @@ public abstract class SharedActionsSystem : EntitySystem
         SubscribeLocalEvent<ActionsComponent, DidUnequipEvent>(OnDidUnequip);
         SubscribeLocalEvent<ActionsComponent, DidUnequipHandEvent>(OnHandUnequipped);
 
+        SubscribeLocalEvent<ActionsComponent, ComponentShutdown>(OnShutdown);
+
         SubscribeLocalEvent<ActionsComponent, ComponentGetState>(OnActionsGetState);
 
         SubscribeLocalEvent<InstantActionComponent, ComponentGetState>(OnInstantGetState);
@@ -49,6 +51,14 @@ public abstract class SharedActionsSystem : EntitySystem
         SubscribeAllEvent<RequestPerformActionEvent>(OnActionRequest);
     }
 
+    private void OnShutdown(EntityUid uid, ActionsComponent component, ComponentShutdown args)
+    {
+        foreach (var act in component.Actions)
+        {
+            RemoveAction(uid, act, component);
+        }
+    }
+
     private void OnInstantGetState(EntityUid uid, InstantActionComponent component, ref ComponentGetState args)
     {
         args.State = new InstantActionComponentState(component, EntityManager);
@@ -611,7 +621,10 @@ public abstract class SharedActionsSystem : EntitySystem
 
         if (action.AttachedEntity != performer)
         {
-            Log.Error($"Attempted to remove an action {ToPrettyString(actionId)} from an entity that it was never attached to: {ToPrettyString(performer)}");
+            DebugTools.Assert(!Resolve(performer, ref comp, false) || !comp.Actions.Contains(actionId.Value));
+
+            if (!GameTiming.ApplyingState)
+                Log.Error($"Attempted to remove an action {ToPrettyString(actionId)} from an entity that it was never attached to: {ToPrettyString(performer)}");
             return;
         }