public StaticObject(Reader reader, bool PrintDebugInfo = false) { Debug = PrintDebugInfo; int[] TmpData = new int[reader.BaseStream.Length]; DataPos = 0; string filename = System.IO.Path.GetFileName(reader.GetFilename()); if (!reader.ReadBytes(4).SequenceEqual(MAGIC)) //"OBJ" Header { throw new Exception("Invalid config file header magic"); } if (Debug) { Console.WriteLine("Viewing Info for " + filename); } int MemPos = 0; // I think? while (!reader.IsEof) { int DataType = reader.ReadByte(); int ArraySize = reader.ReadInt32(); if ((DataType & 0x80) != 0) { uint DataSize = reader.ReadUInt32(); DataType &= 0x7F; ArrayInfo array = new ArrayInfo(); array.Type = (byte)DataType; array.Size = (int)DataSize; array.Data = new int[(int)DataSize]; switch (DataType) { //INT8 case (int)AttributeTypes.UINT8: if (Debug) { Console.WriteLine(); Console.WriteLine("Struct Offset: " + MemPos + "(0x" + MemPos.ToString("X") + ")"); Console.WriteLine("Array Size: " + DataSize); Console.WriteLine("Array Type: UINT8"); } for (int i = 0; i < DataSize; i++) { TmpData[DataPos++] = reader.ReadByte(); array.Data[i] = TmpData[DataPos - 1]; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.UINT8 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 1) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 1).ToString("X")); } } MemPos += ArraySize; break; case (int)AttributeTypes.INT8: if (Debug) { Console.WriteLine(); Console.WriteLine("Struct Offset: " + MemPos + "(0x" + MemPos.ToString("X") + ")"); Console.WriteLine("Array Size: " + DataSize); Console.WriteLine("Array Type: INT8"); } for (int i = 0; i < DataSize; i++) { TmpData[DataPos++] = reader.ReadSByte(); array.Data[i] = TmpData[DataPos - 1]; if (Debug) { Console.WriteLine("Value Info: Value: Type:" + AttributeTypes.INT8 + ", " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 1) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 1).ToString("X")); } } MemPos += ArraySize; break; //IN16 case (int)AttributeTypes.UINT16: int TmpDataOffset = (int)((MemPos & 0xFFFFFFFE) + 2); if ((MemPos & 0xFFFFFFFE) >= MemPos) { TmpDataOffset = MemPos; } MemPos = TmpDataOffset; if (Debug) { Console.WriteLine(); Console.WriteLine("Struct Offset: " + MemPos + "(0x" + MemPos.ToString("X") + ")"); Console.WriteLine("Array Size: " + DataSize); Console.WriteLine("Array Type: UINT16"); } for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); ushort Value = (ushort)(valA + (valB << 8)); TmpData[DataPos++] = Value; array.Data[i] = Value; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.UINT16 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 2) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 2).ToString("X")); } } MemPos += 2 * ArraySize; break; case (int)AttributeTypes.INT16: TmpDataOffset = (int)((MemPos & 0xFFFFFFFE) + 2); if ((MemPos & 0xFFFFFFFE) >= MemPos) { TmpDataOffset = MemPos; } MemPos = TmpDataOffset; if (Debug) { Console.WriteLine(); Console.WriteLine("Struct Offset: " + MemPos + "(0x" + MemPos.ToString("X") + ")"); Console.WriteLine("Array Size: " + DataSize); Console.WriteLine("Array Type: INT16"); } for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); short Value = (short)(valA + (valB << 8)); TmpData[DataPos++] = Value; array.Data[i] = Value; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.INT16 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 2) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 2).ToString("X")); } } MemPos += 2 * ArraySize; break; //INT32 case (int)AttributeTypes.UINT32: TmpDataOffset = (int)((MemPos & 0xFFFFFFFC) + 4); if ((MemPos & 0xFFFFFFFC) >= MemPos) { TmpDataOffset = MemPos; } MemPos = TmpDataOffset; if (Debug) { Console.WriteLine(); Console.WriteLine("Struct Offset: " + MemPos + "(0x" + MemPos.ToString("X") + ")"); Console.WriteLine("Array Size: " + DataSize); Console.WriteLine("Array Type: UINT32"); } for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); uint Value = (uint)(valA + (valB << 8) + (valC << 16) + (valD << 24)); TmpData[DataPos++] = (int)Value; array.Data[i] = (int)Value; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.UINT32 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 4) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 4).ToString("X")); } } MemPos += 4 * ArraySize; break; case (int)AttributeTypes.INT32: TmpDataOffset = (int)((MemPos & 0xFFFFFFFC) + 4); if ((MemPos & 0xFFFFFFFC) >= MemPos) { TmpDataOffset = MemPos; } MemPos = TmpDataOffset; if (Debug) { Console.WriteLine(); Console.WriteLine("Struct Offset: " + MemPos + "(0x" + MemPos.ToString("X") + ")"); Console.WriteLine("Array Size: " + DataSize); Console.WriteLine("Array Type: INT32"); } for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); int Value = valA + (valB << 8) + (valC << 16) + (valD << 24); TmpData[DataPos++] = Value; array.Data[i] = Value; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.INT32 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 4) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 4).ToString("X")); } } MemPos += 4 * ArraySize; break; case (int)AttributeTypes.ENUM: TmpDataOffset = (int)((MemPos & 0xFFFFFFFC) + 4); if ((MemPos & 0xFFFFFFFC) >= MemPos) { TmpDataOffset = MemPos; } MemPos = TmpDataOffset; if (Debug) { Console.WriteLine(); Console.WriteLine("Struct Offset: " + MemPos + "(0x" + MemPos.ToString("X") + ")"); Console.WriteLine("Array Size: " + DataSize); Console.WriteLine("Array Type: VAR"); } for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); int Value = (valA + (valB << 8) + (valC << 16) + (valD << 24)); TmpData[DataPos++] = (int)Value; array.Data[i] = Value; if (Debug) { Console.WriteLine("Value Info: Value: Type:" + AttributeTypes.ENUM + ", " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 4) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 4).ToString("X")); } } MemPos += 4 * ArraySize; break; } } else { int Buffer = 0; switch (DataType) { //INT8 case (int)AttributeTypes.UINT8: case (int)AttributeTypes.INT8: MemPos += ArraySize; break; //IN16 case (int)AttributeTypes.UINT16: case (int)AttributeTypes.INT16: Buffer = (int)((MemPos & 0xFFFFFFFE) + 2); if ((MemPos & 0xFFFFFFFE) >= MemPos) { Buffer = MemPos; } MemPos = Buffer + 2 * ArraySize; break; //INT32 case (int)AttributeTypes.UINT32: case (int)AttributeTypes.INT32: case (int)AttributeTypes.ENUM: case (int)AttributeTypes.BOOL: Buffer = (int)((MemPos & 0xFFFFFFFC) + 4); if ((MemPos & 0xFFFFFFFC) >= MemPos) { Buffer = MemPos; } MemPos = Buffer + 4 * ArraySize; break; case (int)AttributeTypes.STRING: case (int)AttributeTypes.VECTOR2: Buffer = (int)((MemPos & 0xFFFFFFFC) + 4); if ((MemPos & 0xFFFFFFFC) >= MemPos) { Buffer = MemPos; } MemPos = Buffer + 8 * ArraySize; break; case (int)AttributeTypes.VECTOR3: Buffer = (int)((MemPos & 0xFFFFFFFC) + 4); if ((MemPos & 0xFFFFFFFC) >= MemPos) { Buffer = MemPos; } MemPos = Buffer + 24 * ArraySize; break; case (int)AttributeTypes.COLOR: Buffer = (int)((MemPos & 0xFFFFFFFE) + 2); if ((MemPos & 0xFFFFFFFE) >= MemPos) { Buffer = MemPos; } MemPos = Buffer + 8 * ArraySize; break; default: break; } } } reader.Close(); Data = new int[DataPos]; for (int i = 0; i < DataPos; i++) { Data[i] = TmpData[i]; } if (Debug) { Console.WriteLine(filename + " Has " + Data.Length + " Values"); } }
public FileInfo(Reader reader, List <string> FileList, int cnt) { for (int y = 0; y < 16; y += 4) { md5Hash[y + 3] = reader.ReadByte(); md5Hash[y + 2] = reader.ReadByte(); md5Hash[y + 1] = reader.ReadByte(); md5Hash[y] = reader.ReadByte(); } MD5FileName = ConvertByteArrayToString(md5Hash); var md5 = MD5.Create(); FileName = (cnt + 1) + ".bin"; //Make a base name for (int i = 0; i < FileList.Count; i++) { // Mania Hashes all Strings at Lower Case string fp = FileList[i].ToLower(); bool match = true; for (int z = 0; z < 16; z++) { if (CalculateMD5Hash(fp)[z] != md5Hash[z]) { match = false; break; } } if (match) { FileName = FileList[i]; break; } } DataOffset = reader.ReadUInt32(); uint tmp = reader.ReadUInt32(); Encrypted = (tmp & 0x80000000) != 0; FileSize = (tmp & 0x7FFFFFFF); long tmp2 = reader.BaseStream.Position; reader.BaseStream.Position = DataOffset; Filedata = reader.ReadBytes(FileSize); // Decrypt File if Encrypted if (Encrypted) { Filedata = Decrypt(Filedata); } reader.BaseStream.Position = tmp2; Extension = GetExtensionFromData(); if (FileName == (cnt + 1) + ".bin") { switch (Extension) { case ExtensionTypes.CFG: if (Encrypted) { FileName = "Config[Encrypted]" + (cnt + 1) + ".bin"; } else { FileName = "Config" + (cnt + 1) + ".bin"; } break; case ExtensionTypes.GIF: if (Encrypted) { FileName = "Sprite[Encrypted]" + (cnt + 1) + ".gif"; } else { FileName = "Sprite" + (cnt + 1) + ".gif"; } break; case ExtensionTypes.MDL: if (Encrypted) { FileName = "Model[Encrypted]" + (cnt + 1) + ".bin"; } else { FileName = "Model" + (cnt + 1) + ".bin"; } break; case ExtensionTypes.OBJ: if (Encrypted) { FileName = "StaticObject[Encrypted]" + (cnt + 1) + ".bin"; } else { FileName = "StaticObject" + (cnt + 1) + ".bin"; } break; case ExtensionTypes.OGG: if (Encrypted) { FileName = "Music[Encrypted]" + (cnt + 1) + ".ogg"; } else { FileName = "Music" + (cnt + 1) + ".ogg"; } break; case ExtensionTypes.PNG: if (Encrypted) { FileName = "Image[Encrypted]" + (cnt + 1) + ".png"; } else { FileName = "Image" + (cnt + 1) + ".png"; } break; case ExtensionTypes.SCN: if (Encrypted) { FileName = "Scene[Encrypted]" + (cnt + 1) + ".bin"; } else { FileName = "Scene" + (cnt + 1) + ".bin"; } break; case ExtensionTypes.SPR: if (Encrypted) { FileName = "SpriteMappings[Encrypted]" + (cnt + 1) + ".bin"; } else { FileName = "SpriteMappings" + (cnt + 1) + ".bin"; } break; case ExtensionTypes.TIL: if (Encrypted) { FileName = "Tileconfig[Encrypted]" + (cnt + 1) + ".bin"; } else { FileName = "Tileconfig" + (cnt + 1) + ".bin"; } break; case ExtensionTypes.WAV: if (Encrypted) { FileName = "SoundEffect[Encrypted]" + (cnt + 1) + ".wav"; } else { FileName = "SoundEffect" + (cnt + 1) + ".wav"; } break; case ExtensionTypes.UNKNOWN: if (Encrypted) { FileName = "UnknownFileType[Encrypted]" + (cnt + 1) + ".bin"; } else { FileName = "UnknownFileType" + (cnt + 1) + ".bin"; } break; } } md5.Dispose(); }
public StaticObject(Reader reader) { uint[] TmpData = new uint[reader.BaseStream.Length]; DataPos = 0; if (!reader.ReadBytes(4).SequenceEqual(MAGIC)) //"OBJ" Header { throw new Exception("Invalid config file header magic"); } while (!reader.IsEof) { int Unknown1 = reader.ReadByte(); uint Unknown2 = reader.ReadUInt32(); //Unknown if ((Unknown1 & 0x80) != 0) { uint DataSize = reader.ReadUInt32(); int DataType = Unknown1 & 0x7F; switch (DataType) { //INT8 case 0: case 3: for (int i = 0; i < DataSize; i++) { TmpData[DataPos++] = reader.ReadByte(); } break; //IN16 case 1: case 4: for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); int Value = valA + (valB << 8); TmpData[DataPos++] = (uint)Value; } break; //INT32 case 2: case 5: case 6: for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); int Value = valA + (valB << 8) + (valC << 16) + (valD << 24); TmpData[DataPos++] = (uint)Value; } break; } } } reader.Close(); Data = new uint[DataPos]; for (int i = 0; i < DataPos; i++) { Data[i] = TmpData[i]; } }
public StaticObject(Reader reader) { int[] TmpData = new int[reader.BaseStream.Length]; DataPos = 0; string filename = System.IO.Path.GetFileName(reader.GetFilename()); if (!reader.ReadBytes(4).SequenceEqual(MAGIC)) //"OBJ" Header { throw new Exception("Invalid config file header magic"); } if (Debug) { Console.WriteLine("Viewing Info for " + filename); } while (!reader.IsEof) { int DataType = reader.ReadByte(); uint Unknown = reader.ReadUInt32(); //Unknown if ((DataType & 0x80) != 0) { uint DataSize = reader.ReadUInt32(); DataType &= 0x7F; switch (DataType) { //INT8 case (int)AttributeTypes.UINT8: for (int i = 0; i < DataSize; i++) { TmpData[DataPos++] = reader.ReadByte(); if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.UINT8 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 1) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 1).ToString("X")); } } break; case (int)AttributeTypes.INT8: for (int i = 0; i < DataSize; i++) { TmpData[DataPos++] = reader.ReadSByte(); if (Debug) { Console.WriteLine("Value Info: Value: Type:" + AttributeTypes.INT8 + ", " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 1) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 1).ToString("X")); } } break; //IN16 case (int)AttributeTypes.UINT16: for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); ushort Value = (ushort)(valA + (valB << 8)); TmpData[DataPos++] = Value; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.UINT16 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 2) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 2).ToString("X")); } } break; case (int)AttributeTypes.INT16: for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); short Value = (short)(valA + (valB << 8)); TmpData[DataPos++] = Value; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.INT16 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 2) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 2).ToString("X")); } } break; //INT32 case (int)AttributeTypes.UINT32: for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); uint Value = (uint)(valA + (valB << 8) + (valC << 16) + (valD << 24)); TmpData[DataPos++] = (int)Value; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.UINT32 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 4) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 4).ToString("X")); } } break; case (int)AttributeTypes.INT32: for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); int Value = valA + (valB << 8) + (valC << 16) + (valD << 24); TmpData[DataPos++] = Value; if (Debug) { Console.WriteLine("Value Info: Type:" + AttributeTypes.INT32 + ", Value: " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 4) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 4).ToString("X")); } } break; case (int)AttributeTypes.ENUM: for (int i = 0; i < DataSize; i++) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); uint Value = (uint)(valA + (valB << 8) + (valC << 16) + (valD << 24)); TmpData[DataPos++] = (int)Value; if (Debug) { Console.WriteLine("Value Info: Value: Type:" + AttributeTypes.ENUM + ", " + TmpData[DataPos - 1] + ", Value (Hex) 0x" + TmpData[DataPos - 1].ToString("X") + ", Offset: " + (reader.BaseStream.Position - 4) + ", Offset (Hex): 0x" + (reader.BaseStream.Position - 4).ToString("X")); } } break; } } } reader.Close(); Data = new int[DataPos]; for (int i = 0; i < DataPos; i++) { Data[i] = TmpData[i]; } if (Debug) { Console.WriteLine(filename + " Has " + Data.Length + " Values"); } }
public void read(Reader reader, List <string> fileNames = null, int fileID = 0) { for (int y = 0; y < 16; y += 4) { fileName.hash[y + 3] = reader.ReadByte(); fileName.hash[y + 2] = reader.ReadByte(); fileName.hash[y + 1] = reader.ReadByte(); fileName.hash[y + 0] = reader.ReadByte(); } fileName.usingHash = true; var md5 = MD5.Create(); fileName.name = (fileID + 1) + ".bin"; //Make a base name for (int i = 0; fileNames != null && i < fileNames.Count; i++) { // Mania Hashes all Strings at Lower Case string fp = fileNames[i].ToLower(); bool match = true; for (int z = 0; z < 16; z++) { if (calculateMD5Hash(fp)[z] != fileName.hash[z]) { match = false; break; } } if (match) { fileName = new NameIdentifier(fileNames[i]); break; } } uint fileOffset = reader.ReadUInt32(); uint tmp = reader.ReadUInt32(); encrypted = (tmp & 0x80000000) != 0; uint fileSize = (tmp & 0x7FFFFFFF); long tmp2 = reader.BaseStream.Position; reader.BaseStream.Position = fileOffset; // Decrypt File if Encrypted if (encrypted && !fileName.usingHash) { fileData = decrypt(reader.readBytes(fileSize), false); } else { fileData = reader.readBytes(fileSize); } reader.BaseStream.Position = tmp2; extension = getExtensionFromData(); if (fileName.usingHash) { switch (extension) { case ExtensionTypes.CFG: if (encrypted) { fileName.name = "Config[Encrypted]" + (fileID + 1) + ".bin"; } else { fileName.name = "Config" + (fileID + 1) + ".bin"; } break; case ExtensionTypes.GIF: if (encrypted) { fileName.name = "SpriteSheet[Encrypted]" + (fileID + 1) + ".gif"; } else { fileName.name = "SpriteSheet" + (fileID + 1) + ".gif"; } break; case ExtensionTypes.MDL: if (encrypted) { fileName.name = "Model[Encrypted]" + (fileID + 1) + ".bin"; } else { fileName.name = "Model" + (fileID + 1) + ".bin"; } break; case ExtensionTypes.OBJ: if (encrypted) { fileName.name = "StaticObject[Encrypted]" + (fileID + 1) + ".bin"; } else { fileName.name = "StaticObject" + (fileID + 1) + ".bin"; } break; case ExtensionTypes.OGG: if (encrypted) { fileName.name = "Music[Encrypted]" + (fileID + 1) + ".ogg"; } else { fileName.name = "Music" + (fileID + 1) + ".ogg"; } break; case ExtensionTypes.PNG: if (encrypted) { fileName.name = "Image[Encrypted]" + (fileID + 1) + ".png"; } else { fileName.name = "Image" + (fileID + 1) + ".png"; } break; case ExtensionTypes.SCN: if (encrypted) { fileName.name = "Scene[Encrypted]" + (fileID + 1) + ".bin"; } else { fileName.name = "Scene" + (fileID + 1) + ".bin"; } break; case ExtensionTypes.SPR: if (encrypted) { fileName.name = "Animation[Encrypted]" + (fileID + 1) + ".bin"; } else { fileName.name = "Animation" + (fileID + 1) + ".bin"; } break; case ExtensionTypes.TIL: if (encrypted) { fileName.name = "TileConfig[Encrypted]" + (fileID + 1) + ".bin"; } else { fileName.name = "TileConfig" + (fileID + 1) + ".bin"; } break; case ExtensionTypes.WAV: if (encrypted) { fileName.name = "SoundFX[Encrypted]" + (fileID + 1) + ".wav"; } else { fileName.name = "SoundFX" + (fileID + 1) + ".wav"; } break; case ExtensionTypes.UNKNOWN: if (encrypted) { fileName.name = "UnknownFileType[Encrypted]" + (fileID + 1) + ".bin"; } else { fileName.name = "UnknownFileType" + (fileID + 1) + ".bin"; } break; } } md5.Dispose(); }
public void read(Reader reader) { if (!reader.readBytes(4).SequenceEqual(signature)) { reader.Close(); throw new Exception("Invalid Static Object v5 signature"); } int memPos = 0; while (!reader.isEof) { int type = reader.ReadByte(); int arraySize = reader.ReadInt32(); if ((type & 0x80) != 0) { uint count = reader.ReadUInt32(); type &= 0x7F; ArrayInfo array = new ArrayInfo(); array.type = (byte)type; array.size = arraySize; array.valueCount = (int)count; array.values = new int[(int)count]; switch (type) { default: Console.WriteLine($"ERROR: Encountered unexpected array type ({type})!"); break; //INT8 case (int)VariableTypes.UINT8: for (int i = 0; i < count; ++i) { array.values[i] = reader.ReadByte(); } memPos += arraySize; break; case (int)VariableTypes.INT8: for (int i = 0; i < count; ++i) { array.values[i] = reader.ReadSByte(); } memPos += arraySize; break; //IN16 case (int)VariableTypes.UINT16: int tmpMemPos = (int)((memPos & 0xFFFFFFFE) + 2); if ((memPos & 0xFFFFFFFE) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos; for (int i = 0; i < count; ++i) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); array.values[i] = (ushort)(valA + (valB << 8)); } memPos += 2 * arraySize; break; case (int)VariableTypes.INT16: tmpMemPos = (int)((memPos & 0xFFFFFFFE) + 2); if ((memPos & 0xFFFFFFFE) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos; for (int i = 0; i < count; ++i) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); array.values[i] = (short)(valA + (valB << 8)); } memPos += 2 * arraySize; break; //INT32 case (int)VariableTypes.UINT32: tmpMemPos = (int)((memPos & 0xFFFFFFFC) + 4); if ((memPos & 0xFFFFFFFC) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos; for (int i = 0; i < count; ++i) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); array.values[i] = (int)(uint)(valA + (valB << 8) + (valC << 16) + (valD << 24)); } memPos += 4 * arraySize; break; case (int)VariableTypes.INT32: tmpMemPos = (int)((memPos & 0xFFFFFFFC) + 4); if ((memPos & 0xFFFFFFFC) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos; for (int i = 0; i < count; ++i) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); array.values[i] = valA + (valB << 8) + (valC << 16) + (valD << 24); } memPos += 4 * arraySize; break; case (int)VariableTypes.ENUM: // bool tmpMemPos = (int)((memPos & 0xFFFFFFFC) + 4); if ((memPos & 0xFFFFFFFC) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos; for (int i = 0; i < count; ++i) { byte valA = reader.ReadByte(); byte valB = reader.ReadByte(); byte valC = reader.ReadByte(); byte valD = reader.ReadByte(); array.values[i] = valA + (valB << 8) + (valC << 16) + (valD << 24); } memPos += 4 * arraySize; break; } arrays.Add(array); } else { ArrayInfo array = new ArrayInfo(); array.type = (byte)type; array.size = arraySize; array.valueCount = 0; array.values = new int[0]; arrays.Add(array); int tmpMemPos = 0; switch (type) { //INT8 case (int)VariableTypes.UINT8: case (int)VariableTypes.INT8: memPos += arraySize; break; //IN16 case (int)VariableTypes.UINT16: case (int)VariableTypes.INT16: tmpMemPos = (int)((memPos & 0xFFFFFFFE) + 2); if ((memPos & 0xFFFFFFFE) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos + 2 * arraySize; break; //INT32 case (int)VariableTypes.UINT32: case (int)VariableTypes.INT32: case 6: //bool tmpMemPos = (int)((memPos & 0xFFFFFFFC) + 4); if ((memPos & 0xFFFFFFFC) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos + 4 * arraySize; break; case 7: // Pointer tmpMemPos = (int)((memPos & 0xFFFFFFFC) + 4); if ((memPos & 0xFFFFFFFC) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos + 4 * arraySize; break; case 8: // Vector2 tmpMemPos = (int)((memPos & 0xFFFFFFFC) + 4); if ((memPos & 0xFFFFFFFC) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos + 8 * arraySize; break; case 9: // Text tmpMemPos = (int)((memPos & 0xFFFFFFFC) + 4); if ((memPos & 0xFFFFFFFC) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos + 8 * arraySize; break; case 10: // Animator tmpMemPos = (int)((memPos & 0xFFFFFFFC) + 4); if ((memPos & 0xFFFFFFFC) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos + 24 * arraySize; break; case 11: // Hitbox tmpMemPos = (int)((memPos & 0xFFFFFFFE) + 2); if ((memPos & 0xFFFFFFFE) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos + 8 * arraySize; break; case 12: // Unknown tmpMemPos = (int)((memPos & 0xFFFFFFFE) + 2); if ((memPos & 0xFFFFFFFE) >= memPos) { tmpMemPos = memPos; } memPos = tmpMemPos + 18 * arraySize; break; default: break; } } } reader.Close(); }