public override void Save(Stream stream) { KOARBinaryWriter bw = new KOARBinaryWriter(stream); bw.WriteUInt(0); bw.WriteUInt(0); bw.WriteInt(_records.Count); bw.WriteUInt(0); // TODO: write second list size for (int i = 0; i < _records.Count; i++) { bw.WriteUInt(_records[i].fileID); } for (int i = 0; i < _records.Count; i++) { bw.WriteUInt(_records[i].type, 1); } for (int i = 0; i < _records.Count; i++) { bw.WriteUInt(_records[i].unknown, 1); } for (int i = 0; i < _records.Count; i++) { bw.WriteInt(_records[i].bundle ? 1 : 0, 1); } // TODO: add second list bw.Close(); }
public override void Save(Stream stream) { KOARBinaryWriter bw = new KOARBinaryWriter(stream); bw.WriteUInt(1); bw.WriteInt(_fileIDs.Count); for (int i = 0; i < _fileIDs.Count; i++) { bw.WriteUInt(_fileIDs[i]); } if (_hashes != null) { for (int i = 0; i < _fileIDs.Count; i++) { bw.WriteUInt(_hashes[i]); } } bw.Close(); }
public override void Write(KOARBinaryWriter bw) { bw.WriteByte(3); bw.WriteInt(Value); }
public override void Save(Stream stream) { var XmlRecords = Xml.Descendants().ToList(); List <BxmlRecord> records = new List <BxmlRecord>(); for (int i = 0; i < XmlRecords.Count; i++) { var record = new BxmlRecord(); record.Parent = -1; record.FirstChild = -1; record.Next = -1; record.PropertiesCount = 1; record.PropertiesStartIndex = 0; records.Add(record); } List <UInt32> properties = new List <UInt32>(); List <UInt32> tags = new List <UInt32>(); List <String> strings = new List <string>(); List <UInt32> loc_keys = new List <uint>(); for (int i = 0; i < XmlRecords.Count; i++) { var children = XmlRecords[i].Elements().ToList(); if (children.Count > 0) { records[i].FirstChild = XmlRecords.IndexOf(children[0]); for (int j = 0; j < children.Count; j++) { int index = XmlRecords.IndexOf(children[j]); records[index].Parent = i; if (j > 0) { records[XmlRecords.IndexOf(children[j - 1])].Next = index; } } } if (i > 0) { records[i].PropertiesStartIndex = records[i - 1].PropertiesStartIndex + records[i - 1].PropertiesCount; } // only save inner text for tags without children if (records[i].FirstChild == -1) { properties.Add(ConvertProperty(XmlRecords[i].Name.LocalName, XmlRecords[i].Value, tags, strings, loc_keys)); } else { properties.Add(ConvertProperty(XmlRecords[i].Name.LocalName, null, tags, strings, loc_keys)); } var attributes = XmlRecords[i].Attributes().ToList(); if (attributes.Count > 0) { records[i].PropertiesCount = attributes.Count + 1; } foreach (var attribute in attributes) { properties.Add(ConvertProperty(attribute.Name.LocalName, attribute.Value, tags, strings, loc_keys)); } } KOARBinaryWriter bw = new KOARBinaryWriter(stream); bw.WriteInt(records.Count); foreach (var record in records) { bw.WriteInt(record.Parent); bw.WriteInt(record.FirstChild); bw.WriteInt(record.Next); bw.WriteInt(record.PropertiesCount); bw.WriteInt(record.PropertiesStartIndex); } bw.WriteInt(properties.Count); foreach (var v in properties) { bw.WriteUInt(v); } bw.WriteInt(tags.Count); foreach (var v in tags) { bw.WriteUInt(v); } bw.WriteInt(strings.Count); foreach (var v in strings) { bw.WriteString(v); } bw.WriteInt(loc_keys.Count); foreach (var v in loc_keys) { bw.WriteUInt(v); } bw.Close(); }