From 6ac1d92efc51ff2680e2752318732bcea5cd8db3 Mon Sep 17 00:00:00 2001 From: Bluzume <39113159+KuromeSan@users.noreply.github.com> Date: Fri, 13 Aug 2021 16:59:34 +1200 Subject: [PATCH] Cleanup some stuff --- .vs/AppInfoParser/v16/.suo | Bin 90624 -> 91136 bytes AppInfoCli/CXMLBuilder.cs | 60 ++++++++++++++++++++++++++++--------- AppInfoCli/Program.cs | 1 + 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/.vs/AppInfoParser/v16/.suo b/.vs/AppInfoParser/v16/.suo index 397d8d3926db35a93546a5f79d22b1d99498d429..67d8fff4b097eaef0372ee8da9f1fe859cc3685b 100644 GIT binary patch delta 499 zcmZoT!rE|xb%Md<4c?p*0t^h&3=9m+K>Y9j|NlUWff0yPHU>&Fu{NBGc=dmCArre6 zKS7ldg&dW`(j zA8;^MN{TSSl<6HX1hRqtVBi5_=IzCtjJ!fzSAiU1AfJ_C`bAyF-P8ZeFm9h-puo6m z`!-p|T})uX?OKYAp-j^olo=ZsO{S?Z+HZGIVQgS#EZBZPozb3Yn-(JzlMI6d10&FU s3~ZQj^jQbW>6cjdV>c%q?{-(=1bT zlg-RhOpVPfQccp5SQ#ci{1>?ChXmX7IBiD5?Vb{h+Zm@Ye%=06i;RVsv2SG61?T5anNtNBQ>L$zU^JWFtH;Q{{ecam0_!$D#s=Q)4X%t0eA~1b hnV7aSg)kmtWCd&5eomKhIpg$5TSler)ASj$i~z5WM*RQ) diff --git a/AppInfoCli/CXMLBuilder.cs b/AppInfoCli/CXMLBuilder.cs index 1e9171d..5443e53 100644 --- a/AppInfoCli/CXMLBuilder.cs +++ b/AppInfoCli/CXMLBuilder.cs @@ -15,7 +15,7 @@ namespace CXMLDecompiler String XMLFilename = ""; String CXMLFilename = ""; String MagicNumber = ""; - + Int32 Version; FileStream InfoFile; MemoryStream TreeTable; @@ -37,11 +37,13 @@ namespace CXMLDecompiler BinaryWriter bIntArrayTable; BinaryWriter bHashIDTable; BinaryWriter bStringIDTable; - String SilicaTypingInformation = ""; - public void Init(string XMLFile, string CxmlFile, string Magic) + public void Init(string XMLFile, string CxmlFile) { - MagicNumber = Magic; + GetSilicaTypingInformation(XMLFile); + MagicNumber = GetTypingInformation("MAGIC"); + Version = int.Parse(GetTypingInformation("VERSION")); + InfoFile = File.Open(CxmlFile, FileMode.OpenOrCreate, FileAccess.ReadWrite); InfoFile.SetLength(0); @@ -332,7 +334,7 @@ namespace CXMLDecompiler return ent.offset; } - public AttributeType DetermineType(string ElementName, string AttributeName) // This is what i was worried about... + public AttributeType DetermineType(string ElementName, string AttributeName) { return (AttributeType)int.Parse(GetTypingInformation(ElementName + ":" + AttributeName)); } @@ -526,19 +528,50 @@ namespace CXMLDecompiler } } } + + public void Term() + { + InfoFile.Close(); + TreeTable.Close(); + StringIDTable.Close(); + IntIDTable.Close(); + StringTable.Close(); + CharTable.Close(); + HashIDTable.Close(); + IntArrayTable.Close(); + FloatArrayTable.Close(); + FileTable.Close(); + + bTreeTable.Close(); + bIntIDTable.Close(); + bFloatArrayTable.Close(); + bIntArrayTable.Close(); + bHashIDTable.Close(); + + TreeTableEntries.Clear(); + StringTableEntries.Clear(); + CharTableEntries.Clear(); + HashIdTableEntries.Clear(); + IntArrayTableEntries.Clear(); + FloatArrayTableEntries.Clear(); + FileTableEntries.Clear(); + StringIDTableEntries.Clear(); + IntIDTableEntries.Clear(); + + IsInitalized = false; + } + public void BuildCXML(string XmlFile, string CxmlFile) { - GetSilicaTypingInformation(XmlFile); - string Magic = GetTypingInformation("MAGIC"); - int Version = int.Parse(GetTypingInformation("VERSION")); - Console.WriteLine("Magic Number: " + Magic); - Console.WriteLine("Version: " + Version.ToString("X")); if (!IsInitalized) - Init(XmlFile, CxmlFile, Magic); + Init(XmlFile, CxmlFile); + Console.WriteLine("Magic Number: " + MagicNumber); + Console.WriteLine("Version: " + Version.ToString("X")); + XmlDocument XMLFile = new XmlDocument(); XMLFile.Load(XmlFile); - Tools.WriteStringToStream(InfoFile, Magic); + Tools.WriteStringToStream(InfoFile, MagicNumber); bInfoFile.Write((Int32)Version); byte[] headerPlaceholder = new byte[0x48]; InfoFile.Write(headerPlaceholder, 0x00, headerPlaceholder.Length); @@ -623,8 +656,7 @@ namespace CXMLDecompiler bInfoFile.Write(FileTableOffset); bInfoFile.Write(FileTableSize); - InfoFile.Close(); - + Term(); } } } diff --git a/AppInfoCli/Program.cs b/AppInfoCli/Program.cs index a1e105f..e4c3753 100644 --- a/AppInfoCli/Program.cs +++ b/AppInfoCli/Program.cs @@ -200,6 +200,7 @@ namespace CXMLCli { Console.WriteLine("Compiling."); CXMLBuilder builder = new CXMLBuilder(); + builder.Init(path, args[1]); builder.BuildCXML(path, args[1]); Console.WriteLine("\n\nCOMPILATION COMPLETE!"); if (cxmlParser.WaitExit)