]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix various errors/exceptions (#22841)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Fri, 22 Dec 2023 07:26:08 +0000 (02:26 -0500)
committerGitHub <noreply@github.com>
Fri, 22 Dec 2023 07:26:08 +0000 (00:26 -0700)
* Fix entity storage localization

* Fix HumanoidAppearanceComponent resolve

* Fix null reference exceptions

* Fix duplicate key error

* Fix artifact error spam

* actually maybe this is what its meant to do

* Fix entities playing sounds on deletion

Content.Server/Medical/DefibrillatorSystem.cs
Content.Server/Shuttles/Systems/DockingSystem.cs
Content.Server/Worldgen/Systems/Debris/DebrisFeaturePlacerSystem.cs
Content.Server/Xenoarchaeology/Equipment/Components/ActiveArtifactAnalyzerComponent.cs
Content.Server/Xenoarchaeology/Equipment/Components/ArtifactAnalyzerComponent.cs
Content.Server/Xenoarchaeology/Equipment/Systems/ArtifactAnalyzerSystem.cs
Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
Content.Shared/Weapons/Reflect/SharedReflectSystem.cs

index f85ad8d1bf6f994e694c81fbd6ea317967a7612e..12391d724f3f3e5bffb574ec479d2fbc259758d7 100644 (file)
@@ -77,7 +77,8 @@ public sealed class DefibrillatorSystem : EntitySystem
 
     private void OnPowerCellSlotEmpty(EntityUid uid, DefibrillatorComponent component, ref PowerCellSlotEmptyEvent args)
     {
-        TryDisable(uid, component);
+        if (!TerminatingOrDeleted(uid))
+            TryDisable(uid, component);
     }
 
     private void OnAfterInteract(EntityUid uid, DefibrillatorComponent component, AfterInteractEvent args)
@@ -139,6 +140,7 @@ public sealed class DefibrillatorSystem : EntitySystem
 
         component.Enabled = false;
         _appearance.SetData(uid, ToggleVisuals.Toggled, false);
+
         _audio.PlayPvs(component.PowerOffSound, uid);
         return true;
     }
index f765ed69769d31e02c4fb0ec21d4ace4d9fce601..778d24437609a24f6893108a9e397f3c092b4d83 100644 (file)
@@ -459,45 +459,24 @@ namespace Content.Server.Shuttles.Systems
             if (dock.DockedWith == null)
                 return;
 
-            if (TryComp<DoorBoltComponent>(dockUid, out var airlockA))
-            {
-                _bolts.SetBoltsWithAudio(dockUid, airlockA, false);
-            }
-
-            if (TryComp<DoorBoltComponent>(dock.DockedWith, out var airlockB))
-            {
-                _bolts.SetBoltsWithAudio(dock.DockedWith.Value, airlockB, false);
-            }
-
-            if (TryComp(dockUid, out DoorComponent? doorA))
-            {
-                if (_doorSystem.TryClose(dockUid, doorA))
-                {
-                    doorA.ChangeAirtight = true;
-                }
-            }
+            OnUndock(dockUid, dock.DockedWith.Value);
+            OnUndock(dock.DockedWith.Value, dockUid);
+            Cleanup(dockUid, dock);
+        }
 
-            if (TryComp(dock.DockedWith, out DoorComponent? doorB))
-            {
-                if (_doorSystem.TryClose(dock.DockedWith.Value, doorB))
-                {
-                    doorB.ChangeAirtight = true;
-                }
-            }
+        private void OnUndock(EntityUid dockUid, EntityUid other)
+        {
+            if (TerminatingOrDeleted(dockUid))
+                return;
 
-            if (LifeStage(dockUid) < EntityLifeStage.Terminating)
-            {
-                var recentlyDocked = EnsureComp<RecentlyDockedComponent>(dockUid);
-                recentlyDocked.LastDocked = dock.DockedWith.Value;
-            }
+            if (TryComp<DoorBoltComponent>(dockUid, out var airlock))
+                _bolts.SetBoltsWithAudio(dockUid, airlock, false);
 
-            if (TryComp(dock.DockedWith.Value, out MetaDataComponent? meta) && meta.EntityLifeStage < EntityLifeStage.Terminating)
-            {
-                var recentlyDocked = EnsureComp<RecentlyDockedComponent>(dock.DockedWith.Value);
-                recentlyDocked.LastDocked = dock.DockedWith.Value;
-            }
+            if (TryComp(dockUid, out DoorComponent? door) && _doorSystem.TryClose(dockUid, door))
+                door.ChangeAirtight = true;
 
-            Cleanup(dockUid, dock);
+            var recentlyDocked = EnsureComp<RecentlyDockedComponent>(dockUid);
+            recentlyDocked.LastDocked = other;
         }
     }
 }
index 65af0b68cb76189713a4e75a05b786bd2c9b89db..47ee6f62149adb92ea6abbf4225244a446f2d881 100644 (file)
@@ -8,6 +8,7 @@ using Robust.Server.GameObjects;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Random;
+using Robust.Shared.Utility;
 
 namespace Content.Server.Worldgen.Systems.Debris;
 
@@ -162,6 +163,12 @@ public sealed class DebrisFeaturePlacerSystem : BaseWorldSystem
         var failures = 0; // Avoid severe log spam.
         foreach (var point in points)
         {
+            if (component.OwnedDebris.TryGetValue(point, out var existing))
+            {
+                DebugTools.Assert(Exists(existing));
+                continue;
+            }
+
             var pointDensity = _noiseIndex.Evaluate(uid, densityChannel, WorldGen.WorldToChunkCoords(point));
             if (pointDensity == 0 && component.DensityClip || _random.Prob(component.RandomCancellationChance))
                 continue;
index 6bd20b2bf4f5349a0e2b23c2a297d0c7f446b657..7d3fe6a2f00d32379003745276d3e56b7fdc6804 100644 (file)
@@ -1,5 +1,4 @@
-using Robust.Shared.Audio;
-using Robust.Shared.Serialization.TypeSerializers.Implementations;
+using Robust.Shared.Serialization.TypeSerializers.Implementations;
 
 namespace Content.Server.Xenoarchaeology.Equipment.Components;
 
@@ -19,6 +18,6 @@ public sealed partial class ActiveArtifactAnalyzerComponent : Component
     /// <summary>
     /// What is being scanned?
     /// </summary>
-    [ViewVariables]
+    [DataField]
     public EntityUid Artifact;
 }
index cea3b9fbf85b491e9db741df915a1666abc15806..07096c59af613bb6e8e47b355f4ef020409025d4 100644 (file)
@@ -52,7 +52,7 @@ public sealed partial class ArtifactAnalyzerComponent : Component
     public SoundSpecifier ScanFinishedSound = new SoundPathSpecifier("/Audio/Machines/scan_finish.ogg");
 
     #region Analysis Data
-    [ViewVariables]
+    [DataField]
     public EntityUid? LastAnalyzedArtifact;
 
     [ViewVariables]
index 63095c7827013bef8425dd2ebd0d3c1c3e1410c6..17e801cc1895267278e866964dd18de436aa5337 100644 (file)
@@ -195,7 +195,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
         var canScan = false;
         var canPrint = false;
         var points = 0;
-        if (component.AnalyzerEntity != null && TryComp<ArtifactAnalyzerComponent>(component.AnalyzerEntity, out var analyzer))
+        if (TryComp<ArtifactAnalyzerComponent>(component.AnalyzerEntity, out var analyzer))
         {
             artifact = analyzer.LastAnalyzedArtifact;
             msg = GetArtifactScanMessage(analyzer);
@@ -438,9 +438,14 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
 
     private void OnItemRemoved(EntityUid uid, ArtifactAnalyzerComponent component, ref ItemRemovedEvent args)
     {
+        // Scanners shouldn't give permanent remove vision to an artifact, and the scanned artifact doesn't have any
+        // component to track analyzers that have scanned it for removal if the artifact gets deleted.
+        // So we always clear this on removal.
+        component.LastAnalyzedArtifact = null;
+
         // cancel the scan if the artifact moves off the analyzer
         CancelScan(args.OtherEntity);
-        if (component.Console != null && Exists(component.Console))
+        if (Exists(component.Console))
             UpdateUserInterface(component.Console.Value);
     }
 
index a61470bfdfb5987db52df6327faa7f4f4f7d9241..02e29549d4883ad19b44dcd819bf6d5d2762633a 100644 (file)
@@ -67,13 +67,13 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
         bool permanent = false,
         HumanoidAppearanceComponent? humanoid = null)
     {
-        if (!Resolve(uid, ref humanoid))
+        if (!Resolve(uid, ref humanoid, false))
             return;
 
         var dirty = false;
         SetLayerVisibility(uid, humanoid, layer, visible, permanent, ref dirty);
         if (dirty)
-            Dirty(humanoid);
+            Dirty(uid, humanoid);
     }
 
     /// <summary>
index 5c98cb011bb5e93f37172073d6f57f27b7227462..43939b29f95afd033ee5d91ebbeb88743d1c14ce 100644 (file)
@@ -787,7 +787,7 @@ public abstract class SharedStorageSystem : EntitySystem
 
         if (!_sharedHandsSystem.CanDrop(player, toInsert.Value, hands))
         {
-            _popupSystem.PopupClient(Loc.GetString("comp-storage-cant-drop"), uid, player);
+            _popupSystem.PopupClient(Loc.GetString("comp-storage-cant-drop", ("entity", toInsert.Value)), uid, player);
             return false;
         }
 
index 4986f9a3414b8fad6e918738290b8758d60fa609..b9dead823194dfb906f2941b6a9aba2f63191838 100644 (file)
@@ -121,7 +121,7 @@ public abstract class SharedReflectSystem : EntitySystem
 
         if (Resolve(projectile, ref projectileComp, false))
         {
-            _adminLogger.Add(LogType.BulletHit, LogImpact.Medium, $"{ToPrettyString(user)} reflected {ToPrettyString(projectile)} from {ToPrettyString(projectileComp.Weapon!.Value)} shot by {projectileComp.Shooter!.Value}");
+            _adminLogger.Add(LogType.BulletHit, LogImpact.Medium, $"{ToPrettyString(user)} reflected {ToPrettyString(projectile)} from {ToPrettyString(projectileComp.Weapon)} shot by {projectileComp.Shooter}");
 
             projectileComp.Shooter = user;
             projectileComp.Weapon = user;