diff --git a/.vs/AppInfoParser/v16/.suo b/.vs/AppInfoParser/v16/.suo index 397d8d3..67d8fff 100644 Binary files a/.vs/AppInfoParser/v16/.suo and b/.vs/AppInfoParser/v16/.suo differ 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)