Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Member

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?

{
if (!prototypes.TryIndex<EntityPrototype>(node.Value, out _))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use HasIndex instead

return new ErrorNode(node, $"{nameof(EntityPrototype)} {node.Value} is abstract!");

return new ValidatedValueNode(node);
}

return new ErrorNode(node, $"No {nameof(EntityPrototype)} found with id {node.Value}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

{
if (!prototypes.TryIndex<T>(node.Value, out _))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

return new ErrorNode(node, $"{typeof(T)} {node.Value} is abstract!");

return new ValidatedValueNode(node);
}

return new ErrorNode(node, $"No {typeof(T)} found with id {node.Value}");
}
Expand Down
Loading