diff --git a/Content.Server/Clothing/Systems/LoadoutSystem.cs b/Content.Server/Clothing/Systems/LoadoutSystem.cs index 91826188994..e39dd65f523 100644 --- a/Content.Server/Clothing/Systems/LoadoutSystem.cs +++ b/Content.Server/Clothing/Systems/LoadoutSystem.cs @@ -34,10 +34,15 @@ public sealed class LoadoutSystem : EntitySystem [Dependency] private readonly ISerializationManager _serialization = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IComponentFactory _componentFactory = default!; + [Dependency] private readonly ILogManager _log = default!; + + private ISawmill _sawmill = default!; public override void Initialize() { + _sawmill = _log.GetSawmill("loadouts"); + SubscribeLocalEvent(OnPlayerSpawnComplete); } @@ -89,6 +94,16 @@ public void ApplyCharacterLoadout( foreach (var loadout in allLoadouts) { + if (loadout.Item1 == EntityUid.Invalid + || !HasComp(loadout.Item1) + || Deleted(loadout.Item1)) + { + _sawmill.Warning($"Loadout {loadout.Item2.LoadoutName} failed to load properly, deleting."); + EntityManager.QueueDeleteEntity(loadout.Item1); + + continue; + } + var loadoutProto = _protoMan.Index(loadout.Item2.LoadoutName); if (loadoutProto.CustomName && loadout.Item2.CustomName != null) _meta.SetEntityName(loadout.Item1, loadout.Item2.CustomName);