]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix starting gear (#27008)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Tue, 16 Apr 2024 14:44:16 +0000 (00:44 +1000)
committerGitHub <noreply@github.com>
Tue, 16 Apr 2024 14:44:16 +0000 (00:44 +1000)
Slight blunder on the loadout prototype being used and all the names aligning means playtesting didn't catch it earlier.

Ideally player spawning code wouldn't have sucked so I could add tests like I wanted but it is what it is.

Content.Server/Station/Systems/StationSpawningSystem.cs

index 3a3ab31d44bff8328282f9818858b976962066cf..e0c98ee32000e7b14b9931320cdc87da98d51a46 100644 (file)
@@ -189,7 +189,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
         // Run loadouts after so stuff like storage loadouts can get
         var jobLoadout = LoadoutSystem.GetJobPrototype(prototype?.ID);
 
-        if (_prototypeManager.TryIndex(jobLoadout, out RoleLoadoutPrototype? loadoutProto))
+        if (_prototypeManager.TryIndex(jobLoadout, out RoleLoadoutPrototype? roleProto))
         {
             RoleLoadout? loadout = null;
             profile?.Loadouts.TryGetValue(jobLoadout, out loadout);
@@ -202,12 +202,23 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem
             }
 
             // Order loadout selections by the order they appear on the prototype.
-            foreach (var group in loadout.SelectedLoadouts.OrderBy(x => loadoutProto.Groups.FindIndex(e => e == x.Key)))
+            foreach (var group in loadout.SelectedLoadouts.OrderBy(x => roleProto.Groups.FindIndex(e => e == x.Key)))
             {
                 foreach (var items in group.Value)
                 {
+                    if (!_prototypeManager.TryIndex(items.Prototype, out var loadoutProto))
+                    {
+                        Log.Error($"Unable to find loadout prototype for {items.Prototype}");
+                        continue;
+                    }
+
+                    if (!_prototypeManager.TryIndex(loadoutProto.Equipment, out var startingGear))
+                    {
+                        Log.Error($"Unable to find starting gear {loadoutProto.Equipment} for loadout {loadoutProto}");
+                        continue;
+                    }
+
                     // Handle any extra data here.
-                    var startingGear = _prototypeManager.Index<StartingGearPrototype>(items.Prototype);
                     EquipStartingGear(entity.Value, startingGear);
                 }
             }