]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix starting gear without PDAs (#24463)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Wed, 24 Jan 2024 00:02:24 +0000 (19:02 -0500)
committerGitHub <noreply@github.com>
Wed, 24 Jan 2024 00:02:24 +0000 (11:02 +1100)
* fix starting gear without PDAs

* legacy as shit

Content.Server/Station/Systems/StationSpawningSystem.cs

index 9beccd06df445589203ca1c5aa04d42970d5251b..7e19b5f362d544f6d1eb29fb6e1ddb2f4f16a8c3 100644 (file)
@@ -182,10 +182,13 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
         if (!InventorySystem.TryGetSlotEntity(entity, "id", out var idUid))
             return;
 
-        if (!EntityManager.TryGetComponent(idUid, out PdaComponent? pdaComponent) || !TryComp<IdCardComponent>(pdaComponent.ContainedId, out var card))
+        var cardId = idUid.Value;
+        if (TryComp<PdaComponent>(idUid, out var pdaComponent) && pdaComponent.ContainedId != null)
+            cardId = pdaComponent.ContainedId.Value;
+
+        if (!TryComp<IdCardComponent>(cardId, out var card))
             return;
 
-        var cardId = pdaComponent.ContainedId.Value;
         _cardSystem.TryChangeFullName(cardId, characterName, card);
         _cardSystem.TryChangeJobTitle(cardId, jobPrototype.LocalizedName, card);
 
@@ -203,7 +206,8 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
 
         _accessSystem.SetAccessToJob(cardId, jobPrototype, extendedAccess);
 
-        _pdaSystem.SetOwner(idUid.Value, pdaComponent, characterName);
+        if (pdaComponent != null)
+            _pdaSystem.SetOwner(idUid.Value, pdaComponent, characterName);
     }