]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Invalid species fallback on spawn/profile validation (#14675)
authorFlipp Syder <76629141+vulppine@users.noreply.github.com>
Wed, 15 Mar 2023 04:47:40 +0000 (21:47 -0700)
committerGitHub <noreply@github.com>
Wed, 15 Mar 2023 04:47:40 +0000 (23:47 -0500)
* if a player's profile has an invalid species, station spawning will always try to fallback to the default humanoid species

* validation always ensures that if a species can't be indexed, the species falls back to the default species

Content.Server/Station/Systems/StationSpawningSystem.cs
Content.Shared/Preferences/HumanoidCharacterProfile.cs

index 3c13bce8a68710b3fc4ce06a0ce964f1c8cc5c4b..c8186223d18fedc45634d84fb7ab12fe01d79cde 100644 (file)
@@ -105,9 +105,12 @@ public sealed class StationSpawningSystem : EntitySystem
             return jobEntity;
         }
 
-        var entity = EntityManager.SpawnEntity(
-            _prototypeManager.Index<SpeciesPrototype>(profile?.Species ?? HumanoidAppearanceSystem.DefaultSpecies).Prototype,
-            coordinates);
+        if (!_prototypeManager.TryIndex(profile?.Species ?? HumanoidAppearanceSystem.DefaultSpecies, out SpeciesPrototype? species))
+        {
+            species = _prototypeManager.Index<SpeciesPrototype>(HumanoidAppearanceSystem.DefaultSpecies);
+        }
+
+        var entity = EntityManager.SpawnEntity(species.Prototype, coordinates);
 
         if (job?.StartingGear != null)
         {
index ecacf14a096fd91870a58d01774aa7c2fd84f562..7bcdfaf6c7e3c1e092010e864df208b9bf8e5ce7 100644 (file)
@@ -354,7 +354,11 @@ namespace Content.Shared.Preferences
         {
             var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
 
-            prototypeManager.TryIndex<SpeciesPrototype>(Species, out var speciesPrototype);
+            if (!prototypeManager.TryIndex<SpeciesPrototype>(Species, out var speciesPrototype))
+            {
+                Species = SharedHumanoidAppearanceSystem.DefaultSpecies;
+                speciesPrototype = prototypeManager.Index<SpeciesPrototype>(Species);
+            }
 
             var sex = Sex switch
             {