public static void XMLWriter(ref AUTH Data, string file) { KKtXml Xml = new KKtXml(); if (File.Exists(file + ".xml")) { File.Delete(file + ".xml"); } XElement AuthDB = new XElement("AuthDB"); Xml.Compact = true; Xml.Writer(AuthDB, KKtText.ToASCII(BitConverter.GetBytes(Data.Signature)), "Signature"); if (Data.Category != null) { XElement Categories = new XElement("Categories"); Xml.Writer(Categories, Data.Category.Length.ToString(), "Length"); foreach (string category in Data.Category) { XElement Category = new XElement("Category"); Xml.Writer(Category, category, "Value"); Categories.Add(Category); } AuthDB.Add(Categories); } if (Data.UID != null) { XElement UIDs = new XElement("UIDs"); Xml.Writer(UIDs, Data.UID.Length.ToString(), "Length"); foreach (UID uid in Data.UID) { XElement UID = new XElement("UID"); if (uid.Category != "") { Xml.Writer(UID, uid.Category, "Category"); } if (uid.Size != -1) { Xml.Writer(UID, uid.Size.ToString(), "Size"); } if (uid.Value != "") { Xml.Writer(UID, uid.Value, "Value"); } UIDs.Add(UID); } AuthDB.Add(UIDs); } Xml.doc.Add(AuthDB); Xml.SaveXml(file + ".xml"); }
public int DEXReader() { KKtIO reader = KKtIO.OpenReader(filepath + ext); Header = new KKtMain.Header(); Header.Format = KKtMain.Format.F; Header.Signature = reader.ReadInt32(); if (Header.Signature == 0x43505845) { Header = reader.ReadHeader(true); } if (Header.Signature != 0x64) { return(0); } Offset = reader.Position - 0x4; DEX = new EXP[reader.ReadInt32()]; int DEXOffset = reader.ReadInt32(); if (reader.ReadInt32() == 0x00) { Header.Format = KKtMain.Format.X; } reader.Seek(DEXOffset + Offset, 0); for (int i0 = 0; i0 < DEX.Length; i0++) { DEX[i0] = new EXP { Main = new List <EXPElement>(), Eyes = new List <EXPElement>() } } ; for (int i0 = 0; i0 < DEX.Length; i0++) { DEX[i0].MainOffset = reader.ReadInt32(); if (Header.Format == KKtMain.Format.X) { reader.ReadInt32(); } DEX[i0].EyesOffset = reader.ReadInt32(); if (Header.Format == KKtMain.Format.X) { reader.ReadInt32(); } } for (int i0 = 0; i0 < DEX.Length; i0++) { DEX[i0].NameOffset = reader.ReadInt32(); if (Header.Format == KKtMain.Format.X) { reader.ReadInt32(); } } for (int i0 = 0; i0 < DEX.Length; i0++) { EXPElement element = new EXPElement(); reader.Seek(DEX[i0].MainOffset + Offset, 0); while (true) { element.Frame = reader.ReadSingle(); element.Both = reader.ReadUInt16(); element.ID = reader.ReadUInt16(); element.Value = reader.ReadSingle(); element.Trans = reader.ReadSingle(); DEX[i0].Main.Add(element); if (element.Frame == 999999 || element.Both == 0xFFFF) { break; } } reader.Seek(DEX[i0].EyesOffset + Offset, 0); while (true) { element.Frame = reader.ReadSingle(); element.Both = reader.ReadUInt16(); element.ID = reader.ReadUInt16(); element.Value = reader.ReadSingle(); element.Trans = reader.ReadSingle(); DEX[i0].Eyes.Add(element); if (element.Frame == 999999 || element.Both == 0xFFFF) { break; } } reader.Seek(DEX[i0].NameOffset + Offset, 0); DEX[i0].Name = KKtText.ToUTF8(reader.NullTerminated()); } reader.Close(); return(1); }
public static void XMLReader(ref AUTH Data, string file) { KKtXml Xml = new KKtXml(); Xml.OpenXml(file + ".xml", true); foreach (XElement AuthDB in Xml.doc.Elements("AuthDB")) { foreach (XAttribute Entry in AuthDB.Attributes()) { if (Entry.Name == "Signature") { Data.Signature = BitConverter.ToInt32(KKtText.ToASCII(Entry.Value), 0); } } foreach (XElement Child0 in AuthDB.Elements()) { if (Child0.Name == "Categories") { foreach (XAttribute Entry in Child0.Attributes()) { if (Entry.Name == "Length") { Data.Category = new string[int.Parse(Entry.Value)]; } } int i = 0; foreach (XElement Category in Child0.Elements()) { Data.Category[i] = ""; foreach (XAttribute Entry in Category.Attributes()) { if (Entry.Name == "Value") { Data.Category[i] = Entry.Value; } } i++; } } if (Child0.Name == "UIDs") { foreach (XAttribute Entry in Child0.Attributes()) { if (Entry.Name == "Length") { Data.UID = new UID[int.Parse(Entry.Value)]; } } int i = 0; foreach (XElement UID in Child0.Elements()) { Data.UID[i].Category = ""; Data.UID[i].Size = -1; Data.UID[i].Value = ""; foreach (XAttribute Entry in UID.Attributes()) { if (Entry.Name == "Category") { Data.UID[i].Category = Entry.Value; } if (Entry.Name == "Size") { Data.UID[i].Size = int.Parse(Entry.Value); } if (Entry.Name == "Value") { Data.UID[i].Value = Entry.Value; } } i++; } } } } }
public int STRReader() { KKtIO reader = KKtIO.OpenReader(filepath + ext); reader.Format = KKtMain.Format.F; Header.Signature = reader.ReadInt32(); if (Header.Signature == 0x41525453) { Header = reader.ReadHeader(true); STR = new List <String>(); POF = KKtMain.AddPOF(Header); reader.Position = Header.Lenght; Count = reader.ReadInt32Endian(); Offset = reader.ReadInt32Endian(); if (Offset == 0) { Offset = Count; OffsetX = reader.ReadInt64(); Count = reader.ReadInt64(); reader.XOffset = Header.Lenght; reader.Format = KKtMain.Format.X; } reader.LongPosition = reader.IsX ? Offset + reader.XOffset : Offset; for (int i = 0; i < Count; i++) { String Str = new String { StrOffset = reader.GetOffset(ref POF).ReadInt32Endian(), ID = reader.ReadInt32Endian() }; if (reader.IsX) { Str.StrOffset += (int)OffsetX; } STR.Add(Str); } for (int i = 0; i < Count; i++) { reader.LongPosition = STR[i].StrOffset + (reader.IsX ? reader.XOffset : 0); STR[i] = new String { ID = STR[i].ID, Str = KKtText. ToUTF8(reader.NullTerminated()), StrOffset = STR[i].StrOffset }; } reader.Seek(POF.Offset, 0); reader.ReadPOF(ref POF); } else { reader.Seek(-4, (SeekOrigin)1); int i = 0; STR = new List <String>(); while (reader.LongPosition > 0 && reader.LongPosition < reader.LongLength) { int a = reader.ReadInt32(); if (a != 0) { reader.Seek(-4, (SeekOrigin)1); STR.Add(new String { Str = KKtText.ToUTF8(reader.NullTerminated()), ID = i }); i++; } else { break; } } Count = STR.Count; } reader.Close(); return(1); }