private void Create(BinaryReader Reader)
{
byte BodyType = m_Reader.ReadByte();
if (BodyType != 0x01 && BodyType != 0x03)
throw (new Exception("Tuning.cs: Unknown Persist BodyType!"));
uint DecompressedSize = m_Reader.ReadUInt32();
uint CompressedSize = m_Reader.ReadUInt32();
uint StreamBodySize = m_Reader.ReadUInt32(); //same as compressed size for all current examples
//Note: wiki.niotso.org says this is actually one byte Compressor and four bytes CompressionParameters.
ushort CompressionID = m_Reader.ReadUInt16();
if (CompressionID != 0xFB10)
throw (new Exception("Tuning.cs: Unknown CompressionID!"));
byte[] Dummy = m_Reader.ReadBytes(3);
uint DecompressedSize2 = (uint)((Dummy[0] << 0x10) | (Dummy[1] << 0x08) | +Dummy[2]);
Decompresser Dec = new Decompresser();
Dec.CompressedSize = CompressedSize;
Dec.DecompressedSize = DecompressedSize;
var decompressedData = Dec.Decompress(m_Reader.ReadBytes((int)CompressedSize));
if (decompressedData == null)
throw (new Exception("Tuning.cs: Decompression failed!"));
m_Reader = new BinaryReader(new MemoryStream(decompressedData));
EntryCount = m_Reader.ReadUInt32();
for (int i = 0; i < EntryCount; i++)
{
TuningEntry Entry = new TuningEntry();
Entry.EntryName = DecodeString(m_Reader);
Entry.KeyValueCount = m_Reader.ReadUInt32();
Entry.KeyValues = new Dictionary<string, string>();
for (int j = 0; j < Entry.KeyValueCount; j++)
{
string Key = DecodeString(m_Reader);
string Val = DecodeString(m_Reader);
Entry.KeyValues.Add(Key, Val);
}
EntriesByName.Add(Entry.EntryName.ToLowerInvariant(), Entry);
}
}