Validate some SpeciesPrototype fields (#35965)

* Convert SpeciesPrototype strings to ProtoIds

* Simplify protoman indexing calls
This commit is contained in:
Tayrtahn
2025-03-20 16:15:30 -04:00
committed by GitHub
parent ecf22daff7
commit b780b74bbd
5 changed files with 19 additions and 17 deletions

View File

@@ -62,7 +62,7 @@ namespace Content.Shared.Humanoid.Markings
string species)
{
var speciesProto = _prototypeManager.Index<SpeciesPrototype>(species);
var onlyWhitelisted = _prototypeManager.Index<MarkingPointsPrototype>(speciesProto.MarkingPoints).OnlyWhitelisted;
var onlyWhitelisted = _prototypeManager.Index(speciesProto.MarkingPoints).OnlyWhitelisted;
var res = new Dictionary<string, MarkingPrototype>();
foreach (var (key, marking) in MarkingsByCategory(category))
@@ -125,7 +125,7 @@ namespace Content.Shared.Humanoid.Markings
string species, Sex sex)
{
var speciesProto = _prototypeManager.Index<SpeciesPrototype>(species);
var onlyWhitelisted = _prototypeManager.Index<MarkingPointsPrototype>(speciesProto.MarkingPoints).OnlyWhitelisted;
var onlyWhitelisted = _prototypeManager.Index(speciesProto.MarkingPoints).OnlyWhitelisted;
var res = new Dictionary<string, MarkingPrototype>();
foreach (var (key, marking) in MarkingsByCategory(category))
@@ -197,7 +197,7 @@ namespace Content.Shared.Humanoid.Markings
IoCManager.Resolve(ref prototypeManager);
var speciesProto = prototypeManager.Index<SpeciesPrototype>(species);
var onlyWhitelisted = prototypeManager.Index<MarkingPointsPrototype>(speciesProto.MarkingPoints).OnlyWhitelisted;
var onlyWhitelisted = prototypeManager.Index(speciesProto.MarkingPoints).OnlyWhitelisted;
if (!TryGetMarking(marking, out var prototype))
{
@@ -228,7 +228,7 @@ namespace Content.Shared.Humanoid.Markings
IoCManager.Resolve(ref prototypeManager);
var speciesProto = prototypeManager.Index<SpeciesPrototype>(species);
var onlyWhitelisted = prototypeManager.Index<MarkingPointsPrototype>(speciesProto.MarkingPoints).OnlyWhitelisted;
var onlyWhitelisted = prototypeManager.Index(speciesProto.MarkingPoints).OnlyWhitelisted;
if (onlyWhitelisted && prototype.SpeciesRestrictions == null)
{
@@ -254,7 +254,7 @@ namespace Content.Shared.Humanoid.Markings
IoCManager.Resolve(ref prototypeManager);
var speciesProto = prototypeManager.Index<SpeciesPrototype>(species);
if (
!prototypeManager.TryIndex(speciesProto.SpriteSet, out HumanoidSpeciesBaseSpritesPrototype? baseSprites) ||
!prototypeManager.TryIndex(speciesProto.SpriteSet, out var baseSprites) ||
!baseSprites.Sprites.TryGetValue(layer, out var spriteName) ||
!prototypeManager.TryIndex(spriteName, out HumanoidSpeciesSpriteLayer? sprite) ||
sprite == null ||