Simplefied XMLVERSION check in PCKFileReader/Writer

This commit is contained in:
miku-666
2022-07-14 14:34:10 +02:00
parent 98e8d6e6fe
commit 2d319747a9
2 changed files with 6 additions and 10 deletions

View File

@@ -32,16 +32,14 @@ namespace PckStudio.Classes.IO
internal void ReadMetaData(Stream stream)
{
int meta_entry_count = ReadInt(stream);
bool has_xml_tag = false;
_file.meta_data.Capacity = meta_entry_count;
for (; 0 < meta_entry_count; meta_entry_count--)
{
int index = ReadInt(stream);
string value = ReadString(stream);
if (value.Equals("XMLVERSION")) has_xml_tag = true;
_file.meta_data.Insert(index, value);
}
if (has_xml_tag)
if (_file.meta_data.Contains("XMLVERSION"))
Console.WriteLine(ReadInt(stream)); // xml version num ??
}

View File

@@ -40,14 +40,12 @@ namespace PckStudio.Classes.IO
internal void WriteMetaEntries(Stream stream)
{
WriteInt(stream, _file.meta_data.Count);
bool has_xmlverion_tag = false;
foreach (var metaEntry in _file.meta_data)
_file.meta_data.ForEach(entry =>
{
if (metaEntry == "XMLVERSION") has_xmlverion_tag = true;
WriteInt(stream, _file.meta_data.IndexOf(metaEntry));
WriteString(stream, metaEntry);
}
if (has_xmlverion_tag)
WriteInt(stream, _file.meta_data.IndexOf(entry));
WriteString(stream, entry);
});
if (_file.meta_data.Contains("XMLVERSION"))
WriteInt(stream, 0x1337); // :^)
}