From 486fe98cca2ca06ef14b28cc2352e23585f3c68c Mon Sep 17 00:00:00 2001
From: Li
Date: Mon, 20 Jun 2022 01:20:50 +1200
Subject: [PATCH] Fix floats when compiling
---
CXMLCli/CXMLBuilder.cs | 8 +-
CXMLCli/CXMLCli.csproj.user | 2 +-
CXMLCli/CXMLReader.cs | 22 +-
CXMLCli/Program.cs | 499 +++++++++++++++++++-----------------
CXMLCli/Tools.cs | 6 +-
5 files changed, 278 insertions(+), 259 deletions(-)
diff --git a/CXMLCli/CXMLBuilder.cs b/CXMLCli/CXMLBuilder.cs
index 42f413a..ae38b09 100644
--- a/CXMLCli/CXMLBuilder.cs
+++ b/CXMLCli/CXMLBuilder.cs
@@ -17,7 +17,7 @@ namespace CXMLDecompiler
String XMLFilename = "";
String MagicNumber = "";
- Endainness FileEndainness;
+ Endianness FileEndainness;
bool ps3;
Tools tools;
@@ -46,9 +46,9 @@ namespace CXMLDecompiler
Version = Int32.Parse(GetTypingInformation("VERSION").Replace("0x", ""), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);
// Determine filetype.
- FileEndainness = (Endainness)Enum.Parse(typeof(Endainness), GetTypingInformation("ENDAINESS"));
+ FileEndainness = (Endianness)Enum.Parse(typeof(Endianness), GetTypingInformation("ENDAINESS"));
ps3 = GetTypingInformation("PS3") == "true";
- tools = new Tools((FileEndainness == Endainness.BIG_ENDAIN));
+ tools = new Tools((FileEndainness == Endianness.BIG_ENDIAN));
InfoFile = File.Open(CxmlFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
InfoFile.SetLength(0);
@@ -362,7 +362,7 @@ namespace CXMLDecompiler
Console.WriteLine("Int - Value: " + intWrite.ToString());
break;
case AttributeType.TYPE_FLOAT:
- float FloatValue = Single.Parse(attribute.Value.Substring(0, attribute.Value.Length - 1), CultureInfo.InvariantCulture);
+ float FloatValue = Single.Parse(attribute.Value.Replace("f", ""), CultureInfo.InvariantCulture);
tools.WriteSingle(WorkRam, FloatValue);
tools.WriteInt32(WorkRam, 0x00);
Console.WriteLine("Float - Value: " + FloatValue.ToString());
diff --git a/CXMLCli/CXMLCli.csproj.user b/CXMLCli/CXMLCli.csproj.user
index 2cc53d9..c9ea63d 100644
--- a/CXMLCli/CXMLCli.csproj.user
+++ b/CXMLCli/CXMLCli.csproj.user
@@ -1,7 +1,7 @@
- sample\sample.xml sample2.cxml --compile
+ PvrResource.cxml -ps3 -le -f -d
C:\Users\User\Documents\git\cxml-decompiler\CXMLCli\bin\x64\Debug
\ No newline at end of file
diff --git a/CXMLCli/CXMLReader.cs b/CXMLCli/CXMLReader.cs
index b061ca2..f437755 100644
--- a/CXMLCli/CXMLReader.cs
+++ b/CXMLCli/CXMLReader.cs
@@ -74,7 +74,7 @@ namespace CXMLDecompiler
CXML.Version FileVersion;
- public Endainness FileEndainness = Endainness.LITTLE_ENDAIN;
+ public Endianness FileEndainness = Endianness.LITTLE_ENDIAN;
List FileList = new List();
@@ -84,7 +84,7 @@ namespace CXMLDecompiler
public bool ProcessFiles = false;
public bool WaitExit = false;
public bool NoRecursive = false;
- public void Init(string path, bool CheckMagic = true, bool forcePs3 = false, Endainness forceEndainness = Endainness.UNCHANGED)
+ public void Init(string path, bool CheckMagic = true, bool forcePs3 = false, Endianness forceEndainness = Endianness.UNCHANGED)
{
InfoFile = File.Open(path, FileMode.Open, FileAccess.Read);
bool MagicValid = _checkMagicNumber();
@@ -101,20 +101,20 @@ namespace CXMLDecompiler
if (FileVersion == CXML.Version.PS3)
{
ps3 = true;
- FileEndainness = Endainness.BIG_ENDAIN;
+ FileEndainness = Endianness.BIG_ENDIAN;
}
else
{
- FileEndainness = Endainness.LITTLE_ENDAIN;
+ FileEndainness = Endianness.LITTLE_ENDIAN;
}
if (forcePs3)
ps3 = true;
- if (forceEndainness != Endainness.UNCHANGED)
+ if (forceEndainness != Endianness.UNCHANGED)
FileEndainness = forceEndainness;
- tools = new Tools(FileEndainness == Endainness.BIG_ENDAIN);
+ tools = new Tools(FileEndainness == Endianness.BIG_ENDIAN);
TreeTable = Tools.ByteToStream(GetTreeTable());
StringTable = Tools.ByteToStream(GetStringTable());
@@ -416,11 +416,11 @@ namespace CXMLDecompiler
Align(InfoFile, 0x10);
}
- public void DecompileCXML(String CXMLFile, bool force = false)
+ public void DecompileCXML(String CXMLFile)
{
if (!IsInitalized)
- Init(CXMLFile,force);
+ Init(CXMLFile);
if (Directory.Exists(MainDir))
@@ -683,10 +683,10 @@ namespace CXMLDecompiler
Console.WriteLine("Int - Value: " + AttributeValue.ToString() + " sz:" + sz);
break;
case AttributeType.TYPE_FLOAT:
- float FloatValue = tools.ReadSingle(TreeTable);
+ Double FloatValue = (Double)tools.ReadSingle(TreeTable);
string FloatStr = FloatValue.ToString("G9", CultureInfo.InvariantCulture);
if (!FloatStr.Contains("."))
- FloatStr += ".0";
+ FloatStr += ".0";
AttributeValue = FloatStr;
sz = tools.ReadInt32(TreeTable);
Console.WriteLine("Float: " + AttributeValue.ToString() + " sz:" + sz);
@@ -749,7 +749,7 @@ namespace CXMLDecompiler
for(int i = 0; i < FloatArraySize; i++)
{
- FloatValue = tools.ReadSingle(FloatArrayTable);
+ FloatValue = (Double)tools.ReadSingle(FloatArrayTable);
FloatStr = FloatValue.ToString("G9", CultureInfo.InvariantCulture);
if (!FloatStr.Contains("."))
FloatStr += ".0";
diff --git a/CXMLCli/Program.cs b/CXMLCli/Program.cs
index dada6f7..b295647 100644
--- a/CXMLCli/Program.cs
+++ b/CXMLCli/Program.cs
@@ -1,240 +1,259 @@
-using CXMLDecompiler;
-using General;
-using Ionic.Zlib;
-using System;
-using System.IO;
-using System.Reflection;
-
-namespace CXMLCli
-{
- class Program
- {
- static bool HasArg(string argsfull, string argcheck)
- {
- string[] args = argsfull.Split(' ');
- foreach(string arg in args)
- {
- if(arg == argcheck)
- {
- return true;
- }
- }
-
- return false;
- }
- static int Main(string[] args)
- {
-
- // Do you have gimconv?
-
- bool windowsNT = Environment.OSVersion.Platform.Equals(PlatformID.Win32NT);
- bool windows32 = Environment.OSVersion.Platform.Equals(PlatformID.Win32Windows);
- bool windows32S = Environment.OSVersion.Platform.Equals(PlatformID.Win32S);
- bool windowsCE = Environment.OSVersion.Platform.Equals(PlatformID.WinCE);
-
- if (windowsNT || windows32 || windows32S || windowsCE)
- {
- if (!File.Exists(Path.Combine("GimConv", "GimConv.exe")))
- {
- GimConv.DownloadGimConv(); // Politely ask sony to give it to us.
- }
- }
- else
- {
- Console.WriteLine("NOTE: GimConv is windows binary, so you cant use it on this OS!\n.GIM Decoding will be disabled!");
- }
-
- bool Check = true;
-
- if (args.Length == 0)
- {
- Console.WriteLine("-- CXML Decompiler --");
- Console.WriteLine("Required Arguments:");
- Console.WriteLine("\t");
- Console.WriteLine("Optional Arguments:");
- Console.WriteLine("\t-iv --is-vag File is HE-VAG audio and NOT CXML");
- Console.WriteLine("\t-dc --decompress Decompress .Z File");
- Console.WriteLine("\t-cc --compress Compress back to .Z File");
- Console.WriteLine("\t-f --force Dont check magic number.");
- Console.WriteLine("\t-dt --dump-tables Dump ALL tables.");
- Console.WriteLine("\t-tt --dump-tree Dump tree table.");
- Console.WriteLine("\t-idt --dump-id Dump id ID table.");
- Console.WriteLine("\t-iht --dump-hash-id Dump hash ID table.");
- Console.WriteLine("\t-st --dump-string Dump string table.");
- Console.WriteLine("\t-wt --dump-wstring Dump wstring table.");
- Console.WriteLine("\t-ht --dump-hash Dump hash table.");
- Console.WriteLine("\t-iat --dump-int-array Dump int array table.");
- Console.WriteLine("\t-fat --dump-float-array Dump float array table.");
- Console.WriteLine("\t-ft --dump-file Dump file table.");
- Console.WriteLine("\t-le --little-endain De/Encode ints as Little Endain");
- Console.WriteLine("\t-be --big-endain De/Encode ints as Big Endain");
- Console.WriteLine("\t-ps3 --playstation-3 Use the old CXML Format used back on PS3.");
- Console.WriteLine("\t-p --process-files Process Extracted Files");
- Console.WriteLine("\t-nr --no-recursive Do not recursively decompile .RCS to XML");
- Console.WriteLine("\t-w --wait-exit Wait for keypress before exiting");
- Console.WriteLine("\t-d --decompile Decompile CXML to XML.");
- Console.WriteLine("\t-c --compile Compile XML to CXML");
- Console.WriteLine("\t-h --hash-string When Compiling, Generate new hashes");
- Console.WriteLine("Example Decompile: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.info -d -p");
- Console.WriteLine("Example Compile: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.xml app.info -c");
- Console.WriteLine("Default functonality is to Decompile,\nThis is canceled if any other arguments passed.");
- return 0;
- }
-
- String ArgsFull = String.Join(" ", args);
- String path = args[0];
-
- if (args.Length == 1)
- {
- ArgsFull += " -d -p -w";
- }
-
- if (HasArg(ArgsFull, "-iv") || HasArg(ArgsFull, "--is-vag"))
- {
- byte[] WaveData = VAG.VAGAudio.Vag2Wav(path);
- string FileName = Path.GetFileNameWithoutExtension(path) + "-" + VAG.VAGAudio.GetFilename(path) + ".wav";
- Console.WriteLine("Writing "+FileName);
- File.WriteAllBytes(FileName, WaveData);
- return 0;
- }
-
- if (HasArg(ArgsFull, "-dc") || HasArg(ArgsFull, "--decompress"))
- {
- Console.WriteLine("Decompressing " + path);
- Byte[] FileData = File.ReadAllBytes(path);
- Byte[] DecompressedData = ZlibStream.UncompressBuffer(FileData);
- string Extension = Tools.GetFileExtension(DecompressedData);
- string OutPath = Path.ChangeExtension(path, Extension);
- File.WriteAllBytes(OutPath, DecompressedData);
- return 0;
- }
-
- if (HasArg(ArgsFull, "-cc") || HasArg(ArgsFull, "--compress"))
- {
- Console.WriteLine("Compressing " + path);
- Byte[] FileData = File.ReadAllBytes(path);
- Byte[] CompressedData = ZlibStream.CompressBuffer(FileData);
- string Extension = Tools.GetFileExtension(CompressedData);
- string OutPath = Path.ChangeExtension(path, Extension);
- File.WriteAllBytes(OutPath, CompressedData);
- return 0;
- }
-
- CXMLReader cxmlParser = new CXMLReader();
- if(!HasArg(ArgsFull, "-c") && !HasArg(ArgsFull, "--compile"))
- {
- Console.WriteLine("Initalizing: " + path);
- cxmlParser.Init(path, Check);
- }
-
-
- if (HasArg(ArgsFull, "-f") || HasArg(ArgsFull, "--force"))
- {
- Check = false;
- }
-
- if (HasArg(ArgsFull, "-dt") || HasArg(ArgsFull, "--dump-tables"))
- {
- ArgsFull += " --dump-tree --dump-id --dump-hash-id --dump-string --dump-wstring --dump-hash --dump-int-array --dump-float-array --dump-file ";
- }
-
- if (HasArg(ArgsFull, "-tt") || HasArg(ArgsFull, "--dump-tree"))
- {
- Console.WriteLine("Dumping tree table.");
- File.WriteAllBytes("tree-table.bin", cxmlParser.GetTreeTable());
-
- }
-
- if (HasArg(ArgsFull, "-idt") || HasArg(ArgsFull, "--dump-id"))
- {
- Console.WriteLine("Dumping ID table.");
- File.WriteAllBytes("id-table.bin", cxmlParser.GetIDTable());
-
- }
-
- if (HasArg(ArgsFull, "-iht") || HasArg(ArgsFull, "--dump-hash-id"))
- {
- Console.WriteLine("Dumping hash ID table.");
- File.WriteAllBytes("hash-id-table.bin", cxmlParser.GetHashIDTable());
- }
-
- if (HasArg(ArgsFull, "-st") || HasArg(ArgsFull, "--dump-string"))
- {
- Console.WriteLine("Dumping string table.");
- File.WriteAllBytes("string-table.bin",cxmlParser.GetStringTable());
-
- }
-
- if (HasArg(ArgsFull, "-wt") || HasArg(ArgsFull, "--dump-wstring"))
- {
- Console.WriteLine("Dumping wstring table.");
- File.WriteAllBytes("wstring-table.bin", cxmlParser.GetWStringTable());
- }
-
- if (HasArg(ArgsFull, "-ht") || HasArg(ArgsFull, "--dump-hash"))
- {
- Console.WriteLine("Dumping hash table.");
- File.WriteAllBytes("hash-table.bin", cxmlParser.GetHashTable());
- }
-
-
- if (HasArg(ArgsFull, "-iat") || HasArg(ArgsFull, "--dump-int-array"))
- {
- Console.WriteLine("Dumping int array table.");
- File.WriteAllBytes("int-array-table.bin", cxmlParser.GetIntArrayTable());
- }
-
- if (HasArg(ArgsFull, "-fat") || HasArg(ArgsFull, "--dump-float-array"))
- {
- Console.WriteLine("Dumping float array table.");
- File.WriteAllBytes("float-array-table.bin", cxmlParser.GetFloatArrayTable());
- }
-
-
- if (HasArg(ArgsFull, "-ft") || HasArg(ArgsFull, "--dump-tree"))
- {
- Console.WriteLine("Dumping file table.");
- File.WriteAllBytes("file-table.bin", cxmlParser.GetFileTable());
- }
-
- if (HasArg(ArgsFull, "-p") || HasArg(ArgsFull, "--process-files"))
- {
- cxmlParser.ProcessFiles = true;
- }
-
- if (HasArg(ArgsFull, "-w") || HasArg(ArgsFull, "--wait-exit"))
- {
- cxmlParser.WaitExit = true;
- }
-
- if (HasArg(ArgsFull, "-nr") || HasArg(ArgsFull, "--no-recursive"))
- {
- cxmlParser.NoRecursive = true;
- }
-
- if (HasArg(ArgsFull, "-d") || HasArg(ArgsFull, "--decompile") && !HasArg(ArgsFull, "-dt"))
- {
- Console.WriteLine("Decompiling.");
- cxmlParser.DecompileCXML(path, Check);
- Console.WriteLine("\n\nDECOMPILATION COMPLETE!");
- if(cxmlParser.WaitExit)
- Console.ReadKey();
- }
- else if (HasArg(ArgsFull, "-c") || HasArg(ArgsFull, "--compile"))
- {
- Console.WriteLine("Compiling: " + path);
- CXMLBuilder builder = new CXMLBuilder();
- if (HasArg(ArgsFull, "-h") || HasArg(ArgsFull, "----hash-string"))
- builder.HashStrings = true;
-
- builder.Init(path, args[1]);
- builder.BuildCXML(path, args[1]);
- Console.WriteLine("\n\nCOMPILATION COMPLETE!");
- if (cxmlParser.WaitExit)
- Console.ReadKey();
- }
-
- return 0;
- }
- }
-}
+using CXMLDecompiler;
+using General;
+using Ionic.Zlib;
+using System;
+using System.IO;
+using System.Reflection;
+
+namespace CXMLCli
+{
+ class Program
+ {
+ static bool HasArg(string argsfull, string argcheck)
+ {
+ string[] args = argsfull.Split(' ');
+ foreach(string arg in args)
+ {
+ if(arg == argcheck)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ static int Main(string[] args)
+ {
+
+ // Do you have gimconv?
+
+ bool windowsNT = Environment.OSVersion.Platform.Equals(PlatformID.Win32NT);
+ bool windows32 = Environment.OSVersion.Platform.Equals(PlatformID.Win32Windows);
+ bool windows32S = Environment.OSVersion.Platform.Equals(PlatformID.Win32S);
+ bool windowsCE = Environment.OSVersion.Platform.Equals(PlatformID.WinCE);
+
+ if (windowsNT || windows32 || windows32S || windowsCE)
+ {
+ if (!File.Exists(Path.Combine("GimConv", "GimConv.exe")))
+ {
+ GimConv.DownloadGimConv(); // Politely ask sony to give it to us.
+ }
+ }
+ else
+ {
+ Console.WriteLine("NOTE: GimConv is windows binary, so you cant use it on this OS!\n.GIM Decoding will be disabled!");
+ }
+
+ bool Check = true;
+
+ if (args.Length == 0)
+ {
+ Console.WriteLine("-- CXML Decompiler --");
+ Console.WriteLine("Required Arguments:");
+ Console.WriteLine("\t");
+ Console.WriteLine("Optional Arguments:");
+ Console.WriteLine("\t-iv --is-vag File is HE-VAG audio and NOT CXML");
+ Console.WriteLine("\t-dc --decompress Decompress .Z File");
+ Console.WriteLine("\t-cc --compress Compress back to .Z File");
+ Console.WriteLine("\t-f --force Dont check magic number.");
+ Console.WriteLine("\t-dt --dump-tables Dump ALL tables.");
+ Console.WriteLine("\t-tt --dump-tree Dump tree table.");
+ Console.WriteLine("\t-idt --dump-id Dump id ID table.");
+ Console.WriteLine("\t-iht --dump-hash-id Dump hash ID table.");
+ Console.WriteLine("\t-st --dump-string Dump string table.");
+ Console.WriteLine("\t-wt --dump-wstring Dump wstring table.");
+ Console.WriteLine("\t-ht --dump-hash Dump hash table.");
+ Console.WriteLine("\t-iat --dump-int-array Dump int array table.");
+ Console.WriteLine("\t-fat --dump-float-array Dump float array table.");
+ Console.WriteLine("\t-ft --dump-file Dump file table.");
+ Console.WriteLine("\t-le --little-endian Decode ints as Little Endian");
+ Console.WriteLine("\t-be --big-endian Decode ints as Big Endian");
+ Console.WriteLine("\t-ps3 --playstation-3 Use the old CXML Format used back on PS3.");
+ Console.WriteLine("\t-p --process-files Process Extracted Files");
+ Console.WriteLine("\t-nr --no-recursive Do not recursively decompile .RCS to XML");
+ Console.WriteLine("\t-w --wait-exit Wait for keypress before exiting");
+ Console.WriteLine("\t-d --decompile Decompile CXML to XML.");
+ Console.WriteLine("\t-c --compile Compile XML to CXML");
+ Console.WriteLine("\t-h --hash-string When Compiling, Generate new hashes");
+ Console.WriteLine("Example Decompile: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.info -d -p");
+ Console.WriteLine("Example Compile: " + Path.GetFileName(Assembly.GetEntryAssembly().Location) + " app.xml app.info -c");
+ Console.WriteLine("Default functonality is to Decompile,\nThis is canceled if any other arguments passed.");
+ return 0;
+ }
+
+ String ArgsFull = String.Join(" ", args);
+ String ProcessFilePath = args[0];
+
+ bool ForcePs3 = false;
+ Endianness FileEndianness = Endianness.UNCHANGED;
+
+ if (args.Length == 1)
+ {
+ ArgsFull += " -d -p -w";
+ }
+
+ if (HasArg(ArgsFull, "-le") || HasArg(ArgsFull, "--little-endian"))
+ {
+ FileEndianness = Endianness.LITTLE_ENDIAN;
+ }
+
+ if (HasArg(ArgsFull, "-be") || HasArg(ArgsFull, "--big-endian"))
+ {
+ FileEndianness = Endianness.LITTLE_ENDIAN;
+ }
+
+ if (HasArg(ArgsFull, "-ps3") || HasArg(ArgsFull, "--playstation-3"))
+ {
+ ForcePs3 = true;
+ }
+
+ if (HasArg(ArgsFull, "-iv") || HasArg(ArgsFull, "--is-vag"))
+ {
+ byte[] WaveData = VAG.VAGAudio.Vag2Wav(ProcessFilePath);
+ string FileName = Path.GetFileNameWithoutExtension(ProcessFilePath) + "-" + VAG.VAGAudio.GetFilename(ProcessFilePath) + ".wav";
+ Console.WriteLine("Writing "+FileName);
+ File.WriteAllBytes(FileName, WaveData);
+ return 0;
+ }
+
+ if (HasArg(ArgsFull, "-f") || HasArg(ArgsFull, "--force"))
+ {
+ Check = false;
+ }
+
+ if (HasArg(ArgsFull, "-dc") || HasArg(ArgsFull, "--decompress"))
+ {
+ Console.WriteLine("Decompressing " + ProcessFilePath);
+ Byte[] FileData = File.ReadAllBytes(ProcessFilePath);
+ Byte[] DecompressedData = ZlibStream.UncompressBuffer(FileData);
+ string Extension = Tools.GetFileExtension(DecompressedData);
+ string OutPath = Path.ChangeExtension(ProcessFilePath, Extension);
+ File.WriteAllBytes(OutPath, DecompressedData);
+ return 0;
+ }
+
+ if (HasArg(ArgsFull, "-cc") || HasArg(ArgsFull, "--compress"))
+ {
+ Console.WriteLine("Compressing " + ProcessFilePath);
+ Byte[] FileData = File.ReadAllBytes(ProcessFilePath);
+ Byte[] CompressedData = ZlibStream.CompressBuffer(FileData);
+ string Extension = Tools.GetFileExtension(CompressedData);
+ string OutPath = Path.ChangeExtension(ProcessFilePath, Extension);
+ File.WriteAllBytes(OutPath, CompressedData);
+ return 0;
+ }
+
+ CXMLReader cxmlParser = new CXMLReader();
+ if(!HasArg(ArgsFull, "-c") && !HasArg(ArgsFull, "--compile"))
+ {
+ Console.WriteLine("Initalizing: " + ProcessFilePath);
+ cxmlParser.Init(ProcessFilePath, Check, ForcePs3, FileEndianness);
+ }
+
+
+
+ if (HasArg(ArgsFull, "-dt") || HasArg(ArgsFull, "--dump-tables"))
+ {
+ ArgsFull += " --dump-tree --dump-id --dump-hash-id --dump-string --dump-wstring --dump-hash --dump-int-array --dump-float-array --dump-file ";
+ }
+
+ if (HasArg(ArgsFull, "-tt") || HasArg(ArgsFull, "--dump-tree"))
+ {
+ Console.WriteLine("Dumping tree table.");
+ File.WriteAllBytes("tree-table.bin", cxmlParser.GetTreeTable());
+
+ }
+
+ if (HasArg(ArgsFull, "-idt") || HasArg(ArgsFull, "--dump-id"))
+ {
+ Console.WriteLine("Dumping ID table.");
+ File.WriteAllBytes("id-table.bin", cxmlParser.GetIDTable());
+
+ }
+
+ if (HasArg(ArgsFull, "-iht") || HasArg(ArgsFull, "--dump-hash-id"))
+ {
+ Console.WriteLine("Dumping hash ID table.");
+ File.WriteAllBytes("hash-id-table.bin", cxmlParser.GetHashIDTable());
+ }
+
+ if (HasArg(ArgsFull, "-st") || HasArg(ArgsFull, "--dump-string"))
+ {
+ Console.WriteLine("Dumping string table.");
+ File.WriteAllBytes("string-table.bin",cxmlParser.GetStringTable());
+
+ }
+
+ if (HasArg(ArgsFull, "-wt") || HasArg(ArgsFull, "--dump-wstring"))
+ {
+ Console.WriteLine("Dumping wstring table.");
+ File.WriteAllBytes("wstring-table.bin", cxmlParser.GetWStringTable());
+ }
+
+ if (HasArg(ArgsFull, "-ht") || HasArg(ArgsFull, "--dump-hash"))
+ {
+ Console.WriteLine("Dumping hash table.");
+ File.WriteAllBytes("hash-table.bin", cxmlParser.GetHashTable());
+ }
+
+
+ if (HasArg(ArgsFull, "-iat") || HasArg(ArgsFull, "--dump-int-array"))
+ {
+ Console.WriteLine("Dumping int array table.");
+ File.WriteAllBytes("int-array-table.bin", cxmlParser.GetIntArrayTable());
+ }
+
+ if (HasArg(ArgsFull, "-fat") || HasArg(ArgsFull, "--dump-float-array"))
+ {
+ Console.WriteLine("Dumping float array table.");
+ File.WriteAllBytes("float-array-table.bin", cxmlParser.GetFloatArrayTable());
+ }
+
+
+ if (HasArg(ArgsFull, "-ft") || HasArg(ArgsFull, "--dump-tree"))
+ {
+ Console.WriteLine("Dumping file table.");
+ File.WriteAllBytes("file-table.bin", cxmlParser.GetFileTable());
+ }
+
+ if (HasArg(ArgsFull, "-p") || HasArg(ArgsFull, "--process-files"))
+ {
+ cxmlParser.ProcessFiles = true;
+ }
+
+ if (HasArg(ArgsFull, "-w") || HasArg(ArgsFull, "--wait-exit"))
+ {
+ cxmlParser.WaitExit = true;
+ }
+
+ if (HasArg(ArgsFull, "-nr") || HasArg(ArgsFull, "--no-recursive"))
+ {
+ cxmlParser.NoRecursive = true;
+ }
+
+ if (HasArg(ArgsFull, "-d") || HasArg(ArgsFull, "--decompile") && !HasArg(ArgsFull, "-dt"))
+ {
+ Console.WriteLine("Decompiling.");
+ cxmlParser.DecompileCXML(ProcessFilePath);
+ Console.WriteLine("\n\nDECOMPILATION COMPLETE!");
+ if(cxmlParser.WaitExit)
+ Console.ReadKey();
+ }
+ else if (HasArg(ArgsFull, "-c") || HasArg(ArgsFull, "--compile"))
+ {
+ Console.WriteLine("Compiling: " + ProcessFilePath);
+ CXMLBuilder builder = new CXMLBuilder();
+ if (HasArg(ArgsFull, "-h") || HasArg(ArgsFull, "----hash-string"))
+ builder.HashStrings = true;
+
+ builder.Init(ProcessFilePath, args[1]);
+ builder.BuildCXML(ProcessFilePath, args[1]);
+ Console.WriteLine("\n\nCOMPILATION COMPLETE!");
+ if (cxmlParser.WaitExit)
+ Console.ReadKey();
+ }
+
+ return 0;
+ }
+ }
+}
diff --git a/CXMLCli/Tools.cs b/CXMLCli/Tools.cs
index 8749820..ed8ffff 100644
--- a/CXMLCli/Tools.cs
+++ b/CXMLCli/Tools.cs
@@ -7,10 +7,10 @@ using System.Text;
namespace General
{
- enum Endainness
+ enum Endianness
{
- LITTLE_ENDAIN,
- BIG_ENDAIN,
+ LITTLE_ENDIAN,
+ BIG_ENDIAN,
UNCHANGED
};