1
0
mirror of synced 2025-02-22 05:19:50 +01:00

BYAML : Some yaml tag fixes

This commit is contained in:
KillzXGaming 2020-04-16 17:19:23 -04:00
parent 224972df98
commit d5f2d60bfa
2 changed files with 39003 additions and 14 deletions

View File

@ -113,7 +113,14 @@ namespace FirstPlugin
ReferenceNodes.Add(node.Tag, values); ReferenceNodes.Add(node.Tag, values);
foreach (var child in ((YamlMappingNode)node).Children) foreach (var child in ((YamlMappingNode)node).Children)
values.Add(((YamlScalarNode)child.Key).Value, ParseNode(child.Value)); {
var key = ((YamlScalarNode)child.Key).Value;
var tag = ((YamlScalarNode)child.Key).Tag;
if (tag == "!h")
key = Crc32.Compute(key).ToString("x");
values.Add(key, ParseNode(child.Value));
}
return values; return values;
} }
else if (node is YamlSequenceNode) { else if (node is YamlSequenceNode) {
@ -175,16 +182,7 @@ namespace FirstPlugin
bool isFloat = float.TryParse(value, out floatValue); bool isFloat = float.TryParse(value, out floatValue);
if (isFloat) if (isFloat)
return floatValue; return floatValue;
else return value;
{
if (BYAML.IsHash(value))
{
uint hash = Convert.ToUInt32(value, 16);
if (BYAML.Hashes.ContainsKey(hash))
return $"!h {BYAML.Hashes[hash]}";
}
return value;
}
} }
} }
@ -225,13 +223,17 @@ namespace FirstPlugin
foreach (var item in (IDictionary<string, dynamic>)node) foreach (var item in (IDictionary<string, dynamic>)node)
{ {
string key = item.Key; string key = item.Key;
YamlNode keyNode = new YamlScalarNode(key);
if (BYAML.IsHash(key)) if (BYAML.IsHash(key))
{ {
uint hash = Convert.ToUInt32(key, 16); uint hash = Convert.ToUInt32(key, 16);
if (BYAML.Hashes.ContainsKey(hash)) if (BYAML.Hashes.ContainsKey(hash))
key = $"!h {BYAML.Hashes[hash]}"; key = $"{BYAML.Hashes[hash]}";
keyNode = new YamlScalarNode(key);
keyNode.Tag = "!h";
} }
yamlNode.Add(key, SaveNode(item.Key, item.Value)); yamlNode.Add(keyNode, SaveNode(item.Key, item.Value));
} }
return yamlNode; return yamlNode;
} }

File diff suppressed because one or more lines are too long