-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate that ProtoId values are not abstract #5716
base: master
Are you sure you want to change the base?
Conversation
does TryIndex even work for abstract, and if so why |
Nope, it returns false for abstract prototypes (which is how this PR checks for them). The problem linked above snuck through because the entity spawn table stuff doesn't check for abstract prototypes (which it probably should). That would just be a runtime check though - this extra validation would let the linter catch the problem. |
@@ -23,7 +23,12 @@ public ValidationNode Validate(ISerializationManager serialization, ValueDataNod | |||
{ | |||
var prototypes = dependencies.Resolve<IPrototypeManager>(); | |||
if (prototypes.TryGetKindFrom<EntityPrototype>(out _) && prototypes.HasMapping<EntityPrototype>(node.Value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these checks for HasMapping
even necessary at this point?
@@ -23,7 +23,12 @@ public ValidationNode Validate(ISerializationManager serialization, ValueDataNod | |||
{ | |||
var prototypes = dependencies.Resolve<IPrototypeManager>(); | |||
if (prototypes.TryGetKindFrom<EntityPrototype>(out _) && prototypes.HasMapping<EntityPrototype>(node.Value)) | |||
{ | |||
if (!prototypes.TryIndex<EntityPrototype>(node.Value, out _)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use HasIndex
instead
@@ -21,7 +21,12 @@ public ValidationNode Validate(ISerializationManager serialization, ValueDataNod | |||
{ | |||
var prototypes = dependencies.Resolve<IPrototypeManager>(); | |||
if (prototypes.TryGetKindFrom<T>(out _) && prototypes.HasMapping<T>(node.Value)) | |||
{ | |||
if (!prototypes.TryIndex<T>(node.Value, out _)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
@@ -21,7 +21,12 @@ public ValidationNode Validate(ISerializationManager serialization, ValueDataNod | |||
{ | |||
var prototypes = dependencies.Resolve<IPrototypeManager>(); | |||
if (prototypes.TryGetKindFrom<T>(out _) && prototypes.HasMapping<T>(node.Value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
Adds an extra validation step to
ProtoId<T>
andEntProtoId
which makes sure that the prototype is not abstract. This lets YAML linter prevent attempts to spawn abstract prototypes (example: space-wizards/space-station-14#35562)If there's a valid reason to have a
ProtoId
field for an abstract prototype, then go ahead and close this. I can't think of one, and there don't seem to be any existing uses of it.