diff --git a/Robust.Shared/Prototypes/PrototypeManager.cs b/Robust.Shared/Prototypes/PrototypeManager.cs index 80a74bbb0..45260acd8 100644 --- a/Robust.Shared/Prototypes/PrototypeManager.cs +++ b/Robust.Shared/Prototypes/PrototypeManager.cs @@ -71,7 +71,7 @@ namespace Robust.Shared.Prototypes /// List LoadDirectory(ResourcePath path); - Dictionary> ValidateDirectory(ResourcePath path); + IEnumerable>> ValidateDirectory(ResourcePath path); List LoadFromStream(TextReader stream); @@ -341,12 +341,11 @@ namespace Robust.Shared.Prototypes return changedPrototypes; } - public Dictionary> ValidateDirectory(ResourcePath path) + public IEnumerable>> ValidateDirectory(ResourcePath path) { var streams = Resources.ContentFindFiles(path).ToList().AsParallel() .Where(filePath => filePath.Extension == "yml" && !filePath.Filename.StartsWith(".")); - var dict = new Dictionary>(); foreach (var resourcePath in streams) { using var reader = ReadFile(resourcePath); @@ -359,9 +358,9 @@ namespace Robust.Shared.Prototypes var yamlStream = new YamlStream(); yamlStream.Load(reader); - for (var i = 0; i < yamlStream.Documents.Count; i++) + foreach (var doc in yamlStream.Documents) { - var rootNode = (YamlSequenceNode) yamlStream.Documents[i].RootNode; + var rootNode = (YamlSequenceNode) doc.RootNode; foreach (YamlMappingNode node in rootNode.Cast()) { var type = node.GetNode("type").AsString(); @@ -372,7 +371,8 @@ namespace Robust.Shared.Prototypes continue; } - throw new PrototypeLoadException($"Unknown prototype type: '{type}'"); + // throw new PrototypeLoadException($"Unknown prototype type: '{type}'"); + continue; // TODO populate ignored prototypes in a better way } var mapping = node.ToDataNodeCast(); @@ -380,15 +380,11 @@ namespace Robust.Shared.Prototypes var errorNodes = _serializationManager.ValidateNode(prototypeTypes[type], mapping).GetErrors().ToHashSet(); if (errorNodes.Count != 0) { - if (!dict.TryGetValue(resourcePath.ToString(), out var hashSet)) - dict[resourcePath.ToString()] = new HashSet(); - dict[resourcePath.ToString()].UnionWith(errorNodes); + yield return new KeyValuePair>(resourcePath.ToString(), errorNodes); } } } } - - return dict; } private StreamReader? ReadFile(ResourcePath file, bool @throw = true)