Skip to content

Commit

Permalink
Fix SpawnAndDeleteAllEntities (#932)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
VMSolidus authored and Remuchi committed Oct 19, 2024
1 parent 40487f8 commit cab5cf0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Content.Server/Silicon/IPC/InternalEncryptionKeySpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
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
{
[Dependency] private readonly SharedContainerSystem _container = default!;
public void TryInsertEncryptionKey(EntityUid target, StartingGearPrototype startingGear, IEntityManager entityManager)
{
if (!TryComp<EncryptionKeyHolderComponent>(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<EncryptionKeyHolderComponent>(target, out var keyHolderComp)
|| keyHolderComp is null
|| !startingGear.Equipment.TryGetValue("ears", out var earEquipString)
|| string.IsNullOrEmpty(earEquipString))
return;
Expand Down

0 comments on commit cab5cf0

Please sign in to comment.