Fix more Locale related issues.

This commit is contained in:
Bluzume 2021-08-18 02:35:49 +12:00
parent 7d66eaf08f
commit 031277071d
3 changed files with 18 additions and 18 deletions

Binary file not shown.

View File

@ -44,7 +44,7 @@ namespace CXMLDecompiler
{ {
GetSilicaTypingInformation(XMLFile); GetSilicaTypingInformation(XMLFile);
MagicNumber = GetTypingInformation("MAGIC"); MagicNumber = GetTypingInformation("MAGIC");
Version = int.Parse(GetTypingInformation("VERSION")); Version = Int32.Parse(GetTypingInformation("VERSION"), CultureInfo.InvariantCulture);
InfoFile = File.Open(CxmlFile, FileMode.OpenOrCreate, FileAccess.ReadWrite); InfoFile = File.Open(CxmlFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
InfoFile.SetLength(0); InfoFile.SetLength(0);
@ -336,7 +336,7 @@ namespace CXMLDecompiler
public AttributeType DetermineType(string ElementName, string AttributeName) public AttributeType DetermineType(string ElementName, string AttributeName)
{ {
return (AttributeType)int.Parse(GetTypingInformation(ElementName + ":" + AttributeName)); return (AttributeType)Int32.Parse(GetTypingInformation(ElementName + ":" + AttributeName), CultureInfo.InvariantCulture);
} }
public void WriteAttribute(XmlAttribute attribute, MemoryStream WorkRam, BinaryWriter bWorkRam, string ElementName) public void WriteAttribute(XmlAttribute attribute, MemoryStream WorkRam, BinaryWriter bWorkRam, string ElementName)
{ {
@ -352,13 +352,13 @@ namespace CXMLDecompiler
Console.ReadKey(); Console.ReadKey();
break; break;
case AttributeType.TYPE_INT: case AttributeType.TYPE_INT:
int intWrite = Int32.Parse(attribute.Value); int intWrite = Int32.Parse(attribute.Value, CultureInfo.InvariantCulture);
bWorkRam.Write((int)intWrite); bWorkRam.Write((int)intWrite);
bWorkRam.Write((int)0x00); bWorkRam.Write((int)0x00);
Console.WriteLine("Int - Value: " + intWrite.ToString()); Console.WriteLine("Int - Value: " + intWrite.ToString());
break; break;
case AttributeType.TYPE_FLOAT: case AttributeType.TYPE_FLOAT:
float FloatValue = Single.Parse(attribute.Value.Substring(0, attribute.Value.Length - 1)); float FloatValue = Single.Parse(attribute.Value.Substring(0, attribute.Value.Length - 1), CultureInfo.InvariantCulture);
bWorkRam.Write((float)FloatValue); bWorkRam.Write((float)FloatValue);
bWorkRam.Write((int)0x00); bWorkRam.Write((int)0x00);
Console.WriteLine("Float - Value: " + FloatValue.ToString()); Console.WriteLine("Float - Value: " + FloatValue.ToString());
@ -378,10 +378,10 @@ namespace CXMLDecompiler
Console.WriteLine("Char: " + attribute.Value); Console.WriteLine("Char: " + attribute.Value);
break; break;
case AttributeType.TYPE_HASH_ID: case AttributeType.TYPE_HASH_ID:
int hashId = int.Parse(attribute.Value, NumberStyles.HexNumber); int hashId = Int32.Parse(attribute.Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
if (HashStrings) if (HashStrings)
hashId = int.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber); hashId = Int32.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int HashTableOffset = AddGetHashIdTable(hashId); int HashTableOffset = AddGetHashIdTable(hashId);
int HashTableSize = 4; int HashTableSize = 4;
@ -393,7 +393,7 @@ namespace CXMLDecompiler
string[] arr = attribute.Value.Replace("[", "").Replace("]", "").Replace(" ", "").Split(','); string[] arr = attribute.Value.Replace("[", "").Replace("]", "").Replace(" ", "").Split(',');
int[] intArr = new int[arr.Length]; int[] intArr = new int[arr.Length];
for (int i = 0; i < intArr.Length; i++) for (int i = 0; i < intArr.Length; i++)
intArr[i] = int.Parse(arr[i]); intArr[i] = Int32.Parse(arr[i], CultureInfo.InvariantCulture);
int IntArrayOffset = AddGetIntArrayTable(intArr); int IntArrayOffset = AddGetIntArrayTable(intArr);
int IntArraySize = intArr.Length; int IntArraySize = intArr.Length;
@ -406,7 +406,7 @@ namespace CXMLDecompiler
arr = attribute.Value.Replace("[", "").Replace("]", "").Replace(" ", "").Replace("f", "").Split(','); arr = attribute.Value.Replace("[", "").Replace("]", "").Replace(" ", "").Replace("f", "").Split(',');
float[] floatArr = new float[arr.Length]; float[] floatArr = new float[arr.Length];
for (int i = 0; i < floatArr.Length; i++) for (int i = 0; i < floatArr.Length; i++)
floatArr[i] = float.Parse(arr[i]); floatArr[i] = Single.Parse(arr[i], CultureInfo.InvariantCulture);
int FloatArrayOffset = AddGetFloatArrayTable(floatArr); int FloatArrayOffset = AddGetFloatArrayTable(floatArr);
int FloatArraySize = floatArr.Length; int FloatArraySize = floatArr.Length;
@ -438,9 +438,9 @@ namespace CXMLDecompiler
Console.WriteLine("ID String: " + StringIdTableOffset + " sz: 0"); Console.WriteLine("ID String: " + StringIdTableOffset + " sz: 0");
break; break;
case AttributeType.TYPE_ID_INT_LOOPBACK: case AttributeType.TYPE_ID_INT_LOOPBACK:
int hash = int.Parse(attribute.Value, NumberStyles.HexNumber); int hash = Int32.Parse(attribute.Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
if (HashStrings) if (HashStrings)
hash = int.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber); hash = Int32.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
int IntIdTableOffset = AddGetIntIdTable(hash, Convert.ToInt32(TreeTable.Position)); int IntIdTableOffset = AddGetIntIdTable(hash, Convert.ToInt32(TreeTable.Position));
bWorkRam.Write(IntIdTableOffset); bWorkRam.Write(IntIdTableOffset);
bWorkRam.Write((int)0x00); bWorkRam.Write((int)0x00);
@ -448,9 +448,9 @@ namespace CXMLDecompiler
Console.WriteLine("Loopback ID Int: " + IntIdTableOffset + " sz: 0"); Console.WriteLine("Loopback ID Int: " + IntIdTableOffset + " sz: 0");
break; break;
case AttributeType.TYPE_ID_INT: case AttributeType.TYPE_ID_INT:
hash = int.Parse(attribute.Value, NumberStyles.HexNumber); hash = Int32.Parse(attribute.Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
if (HashStrings) if (HashStrings)
hash = int.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber); hash = Int32.Parse(Tools.GenerateShortHash(Encoding.UTF8.GetBytes(attribute.Value)), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
IntIdTableOffset = AddGetIntIdTable(hash, -1); IntIdTableOffset = AddGetIntIdTable(hash, -1);
bWorkRam.Write(IntIdTableOffset); bWorkRam.Write(IntIdTableOffset);

View File

@ -414,7 +414,7 @@ namespace CXML
int bytesRemaining = Convert.ToInt32(InfoFile.Length - InfoFile.Position); int bytesRemaining = Convert.ToInt32(InfoFile.Length - InfoFile.Position);
if (bytesRemaining > 0) // Some RCS files have unexplainable random XML Data at the end of them, Dont ask me. im just the messanger if (bytesRemaining > 0) // Some RCS files have unexplainable random XML Data at the end of them, Dont ask me. im just the messanger
{ {
Console.WriteLine(bytesRemaining.ToString("X8") + " Excess Bytes Found, Shoving it in SilicaTypingInformation."); Console.WriteLine(bytesRemaining.ToString("X8", CultureInfo.InvariantCulture) + " Excess Bytes Found, Shoving it in SilicaTypingInformation.");
byte[] ExcessData = new byte[bytesRemaining]; byte[] ExcessData = new byte[bytesRemaining];
InfoFile.Read(ExcessData, 0x00, bytesRemaining); InfoFile.Read(ExcessData, 0x00, bytesRemaining);
byte[] Compressed = ZlibStream.CompressBuffer(ExcessData); byte[] Compressed = ZlibStream.CompressBuffer(ExcessData);
@ -557,7 +557,7 @@ namespace CXML
public void RegisterFile(Int64 ElementPtr, String NewName, Boolean FileEntry, String IdealName=null) public void RegisterFile(Int64 ElementPtr, String NewName, Boolean FileEntry, String IdealName=null)
{ {
Console.WriteLine("Adding Entry for Loopback: 0x" + ElementPtr.ToString("X8") + " (" + NewName + ")"); Console.WriteLine("Adding Entry for Loopback: 0x" + ElementPtr.ToString("X8", CultureInfo.InvariantCulture) + " (" + NewName + ")");
for(int i = 0; i < FileList.Count; i++) for(int i = 0; i < FileList.Count; i++)
{ {
if(FileList[i].FilePointer == ElementPtr) if(FileList[i].FilePointer == ElementPtr)
@ -745,9 +745,9 @@ namespace CXML
int IDValue = bIntIDTable.ReadInt32(); int IDValue = bIntIDTable.ReadInt32();
LoopbackAttribute = Tools.ReadStringAt(StringTable, StringPtr); LoopbackAttribute = Tools.ReadStringAt(StringTable, StringPtr);
Console.WriteLine("Int Loopback: " + LoopbackAttribute + " " + LoopbackPtr.ToString("X") + " (" + ElementPtr.ToString("X") + ")"); Console.WriteLine("Int Loopback: " + LoopbackAttribute + " " + LoopbackPtr.ToString("X", CultureInfo.InvariantCulture) + " (" + ElementPtr.ToString("X") + ")");
AttributeValue = IDValue.ToString("X8"); AttributeValue = IDValue.ToString("X8", CultureInfo.InvariantCulture);
RegisterFile(LoopbackPtr, AttributeValue.ToString(), false); RegisterFile(LoopbackPtr, AttributeValue.ToString(), false);
Console.WriteLine("Loopback Int: " + IntIdTableOffset + " sz: " + bTreeTable.ReadInt32()); Console.WriteLine("Loopback Int: " + IntIdTableOffset + " sz: " + bTreeTable.ReadInt32());
@ -757,7 +757,7 @@ namespace CXML
IntIDTable.Seek(IntIdTableOffset + 4, SeekOrigin.Begin); IntIDTable.Seek(IntIdTableOffset + 4, SeekOrigin.Begin);
IDValue = bIntIDTable.ReadInt32(); IDValue = bIntIDTable.ReadInt32();
AttributeValue = IDValue.ToString("X8"); AttributeValue = IDValue.ToString("X8", CultureInfo.InvariantCulture);
Console.WriteLine("Int Id: " + IntIdTableOffset + " sz: " + bTreeTable.ReadInt32()); Console.WriteLine("Int Id: " + IntIdTableOffset + " sz: " + bTreeTable.ReadInt32());
break; break;
default: default:
@ -766,7 +766,7 @@ namespace CXML
break; break;
}; };
AddTypingInfo(ElementName + ":" + AttributeName, ((int)Type).ToString()); AddTypingInfo(ElementName + ":" + AttributeName, ((int)Type).ToString(CultureInfo.InvariantCulture));
Console.WriteLine(AttributeName + "=" + AttributeValue.ToString()); Console.WriteLine(AttributeName + "=" + AttributeValue.ToString());
XMLFile.WriteAttributeString(AttributeName, AttributeValue.ToString()); XMLFile.WriteAttributeString(AttributeName, AttributeValue.ToString());
XMLFile.Flush(); XMLFile.Flush();