mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Make prototype load ignore documents with empty values
This happens if you have a YAML file like this: --- # commented prototype --- # Real prototype - type: bla This case is generated by my (next commit) prototype file merger asset pass, and I don't see any harm in just skipping in this case. Also improve the logging in general.
This commit is contained in:
@@ -52,21 +52,36 @@ public partial class PrototypeManager
|
||||
return (file, Array.Empty<ExtractedMappingData>());
|
||||
|
||||
var extractedList = new List<ExtractedMappingData>();
|
||||
var i = 0;
|
||||
foreach (var document in DataNodeParser.ParseYamlStream(reader))
|
||||
{
|
||||
i += 1;
|
||||
LoadedData?.Invoke(document);
|
||||
|
||||
var seq = (SequenceDataNode)document.Root;
|
||||
foreach (var mapping in seq.Sequence)
|
||||
switch (document.Root)
|
||||
{
|
||||
var data = ExtractMapping((MappingDataNode)mapping);
|
||||
if (data != null)
|
||||
{
|
||||
if (ignored)
|
||||
AbstractPrototype(data.Data);
|
||||
case SequenceDataNode seq:
|
||||
foreach (var mapping in seq.Sequence)
|
||||
{
|
||||
var data = ExtractMapping((MappingDataNode)mapping);
|
||||
if (data != null)
|
||||
{
|
||||
if (ignored)
|
||||
AbstractPrototype(data.Data);
|
||||
|
||||
extractedList.Add(data);
|
||||
}
|
||||
extractedList.Add(data);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case ValueDataNode { Value: "" }:
|
||||
// Documents with absolutely nothing in them get deserialized as this.
|
||||
// How does this happen? Text file merger generates separate documents for each file.
|
||||
// Just skip it.
|
||||
break;
|
||||
default:
|
||||
sawmill.Error($"{file} document #{i} is not a sequence! Did you forget to indent your prototype with a '-'?");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user