From d6dd2ea8bc95388ffc127325865d52a53751349a Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Wed, 18 Sep 2024 23:29:28 -0400 Subject: [PATCH] Fix SpawnAndDeleteAllEntities (#932) # Description After doing an archaological exploration of the fucking SpawnAndDeleteAllEntities test fail, I eventually tracked down the bug to an issue where InternalEncryptionKeySpawner is randomly being handed a Null EntityUid which was Null Forgiven to make the compiler shut up. The actual EntityUid factually cannot be null during ordinary operation, except for the dumbass race condition provided by TestSpawnAndDeleteAllEntities. --- Content.Server/Silicon/IPC/InternalEncryptionKeySpawner.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Content.Server/Silicon/IPC/InternalEncryptionKeySpawner.cs b/Content.Server/Silicon/IPC/InternalEncryptionKeySpawner.cs index 7f5d216c92f..5f799a102e7 100644 --- a/Content.Server/Silicon/IPC/InternalEncryptionKeySpawner.cs +++ b/Content.Server/Silicon/IPC/InternalEncryptionKeySpawner.cs @@ -2,7 +2,6 @@ using Content.Shared.Radio.Components; using Content.Shared.Containers; using Robust.Shared.Containers; -using Content.Server.Cargo.Components; namespace Content.Server.Silicon.IPC; public sealed partial class InternalEncryptionKeySpawner : EntitySystem @@ -10,7 +9,11 @@ public sealed partial class InternalEncryptionKeySpawner : EntitySystem [Dependency] private readonly SharedContainerSystem _container = default!; public void TryInsertEncryptionKey(EntityUid target, StartingGearPrototype startingGear, IEntityManager entityManager) { - if (!TryComp(target, out var keyHolderComp) +#pragma warning disable CS8073 + if (target == null // target can be null during race conditions intentionally created by awful tests. +#pragma warning restore CS8073 + || !TryComp(target, out var keyHolderComp) + || keyHolderComp is null || !startingGear.Equipment.TryGetValue("ears", out var earEquipString) || string.IsNullOrEmpty(earEquipString)) return;