]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix debug asserts in WoolySystem and UdderSystem (#35314)
authorTayrtahn <tayrtahn@gmail.com>
Thu, 8 May 2025 07:55:41 +0000 (03:55 -0400)
committerGitHub <noreply@github.com>
Thu, 8 May 2025 07:55:41 +0000 (09:55 +0200)
Content.Shared/Animals/UdderSystem.cs
Content.Shared/Animals/WoolySystem.cs

index 177fbab2f2a3ae97432158adb928cbc26535514a..90cc717321d467172b5db03c4aa1252bf35a5f6a 100644 (file)
@@ -8,6 +8,7 @@ using Content.Shared.Nutrition.EntitySystems;
 using Content.Shared.Popups;
 using Content.Shared.Udder;
 using Content.Shared.Verbs;
+using Robust.Shared.Containers;
 using Robust.Shared.Timing;
 
 namespace Content.Shared.Animals;
@@ -31,6 +32,7 @@ public sealed class UdderSystem : EntitySystem
         SubscribeLocalEvent<UdderComponent, MapInitEvent>(OnMapInit);
         SubscribeLocalEvent<UdderComponent, GetVerbsEvent<AlternativeVerb>>(AddMilkVerb);
         SubscribeLocalEvent<UdderComponent, MilkingDoAfterEvent>(OnDoAfter);
+        SubscribeLocalEvent<UdderComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
     }
 
     private void OnMapInit(EntityUid uid, UdderComponent component, MapInitEvent args)
@@ -38,6 +40,16 @@ public sealed class UdderSystem : EntitySystem
         component.NextGrowth = _timing.CurTime + component.GrowthDelay;
     }
 
+    private void OnEntRemoved(Entity<UdderComponent> entity, ref EntRemovedFromContainerMessage args)
+    {
+        // Make sure the removed entity was our contained solution
+        if (entity.Comp.Solution == null || args.Entity != entity.Comp.Solution.Value.Owner)
+            return;
+
+        // Cleared our cached reference to the solution entity
+        entity.Comp.Solution = null;
+    }
+
     public override void Update(float frameTime)
     {
         base.Update(frameTime);
index b7e0f52982cab95588d89f5eb5356eb34a64c785..172e3b56e14470d99d060a2fa6e013a679567fa2 100644 (file)
@@ -3,6 +3,7 @@ using Content.Shared.Mobs.Systems;
 using Content.Shared.Nutrition;
 using Content.Shared.Nutrition.Components;
 using Content.Shared.Nutrition.EntitySystems;
+using Robust.Shared.Containers;
 using Robust.Shared.Timing;
 
 namespace Content.Shared.Animals;
@@ -24,6 +25,7 @@ public sealed class WoolySystem : EntitySystem
 
         SubscribeLocalEvent<WoolyComponent, BeforeFullyEatenEvent>(OnBeforeFullyEaten);
         SubscribeLocalEvent<WoolyComponent, MapInitEvent>(OnMapInit);
+        SubscribeLocalEvent<WoolyComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
     }
 
     private void OnMapInit(EntityUid uid, WoolyComponent component, MapInitEvent args)
@@ -31,6 +33,16 @@ public sealed class WoolySystem : EntitySystem
         component.NextGrowth = _timing.CurTime + component.GrowthDelay;
     }
 
+    private void OnEntRemoved(Entity<WoolyComponent> entity, ref EntRemovedFromContainerMessage args)
+    {
+        // Make sure the removed entity was our contained solution
+        if (entity.Comp.Solution == null || args.Entity != entity.Comp.Solution.Value.Owner)
+            return;
+
+        // Clear our cached reference to the solution entity
+        entity.Comp.Solution = null;
+    }
+
     public override void Update(float frameTime)
     {
         base.Update(frameTime);