]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Maybe fix invalid loadout prototypes (#28734)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sat, 8 Jun 2024 18:48:09 +0000 (04:48 +1000)
committerGitHub <noreply@github.com>
Sat, 8 Jun 2024 18:48:09 +0000 (14:48 -0400)
* Maybe fix invalid loadout prototypes

So if we have existing data SetDefault is not normally called iirc. So what I think is happening is that if we have old loadout groups that get saved to DB and loaded these get dropped entirely and nothing is used to replace the group unless the person specifically looks at their loadout.

Need someone affected to send me their loadout to confirm it's fixed.

* Better fix

Content.Shared/Preferences/HumanoidCharacterProfile.cs
Content.Shared/Preferences/Loadouts/RoleLoadout.cs

index 3ee162fe725137ea041aea6e9b5e853549767d2f..fd95848d2c6b76a194ef3d68c03e72988d42924e 100644 (file)
@@ -467,10 +467,10 @@ namespace Content.Shared.Preferences
             var configManager = collection.Resolve<IConfigurationManager>();
             var prototypeManager = collection.Resolve<IPrototypeManager>();
 
-            if (!prototypeManager.TryIndex<SpeciesPrototype>(Species, out var speciesPrototype) || speciesPrototype.RoundStart == false)
+            if (!prototypeManager.TryIndex(Species, out var speciesPrototype) || speciesPrototype.RoundStart == false)
             {
                 Species = SharedHumanoidAppearanceSystem.DefaultSpecies;
-                speciesPrototype = prototypeManager.Index<SpeciesPrototype>(Species);
+                speciesPrototype = prototypeManager.Index(Species);
             }
 
             var sex = Sex switch
index 18c3501ea61e1d25a3d80572d1514ef648fe9a21..5f8e24621a979ecd6061f7f199028e4e100a8d5f 100644 (file)
@@ -59,6 +59,16 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
             return;
         }
 
+        // In some instances we might not have picked up a new group for existing data.
+        foreach (var groupProto in roleProto.Groups)
+        {
+            if (SelectedLoadouts.ContainsKey(groupProto))
+                continue;
+
+            // Data will get set below.
+            SelectedLoadouts[groupProto] = new List<Loadout>();
+        }
+
         // Reset points to recalculate.
         Points = roleProto.Points;
 
@@ -156,6 +166,7 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
     /// <summary>
     /// Resets the selected loadouts to default if no data is present.
     /// </summary>
+    /// <param name="force">Clear existing data first</param>
     public void SetDefault(IPrototypeManager protoManager, bool force = false)
     {
         if (force)