public Animation(Reader reader) { if (!reader.ReadBytes(4).SequenceEqual(MAGIC)) { throw new Exception("Invalid config file header magic"); } int TotalFrameCount = reader.ReadInt32(); int spriteSheetCount = reader.ReadByte(); for (int i = 0; i < spriteSheetCount; ++i) { SpriteSheets.Add(reader.ReadRSDKString().Replace("" + '\0', "")); } int collisionBoxCount = reader.ReadByte(); for (int i = 0; i < collisionBoxCount; ++i) { CollisionBoxes.Add(reader.ReadRSDKString().Replace("" + '\0', "")); /* * string tmp = ""; * for (int ii = 0; ii < CollisionBoxes[i].Length - 1; ii++) //Fixes a crash when using the string to load (by trimming the null char off) * { * tmp += CollisionBoxes[i][ii]; * } * CollisionBoxes[i] = tmp;*/ } var animationCount = reader.ReadInt16(); for (int i = 0; i < animationCount; ++i) { Animations.Add(new AnimationEntry(reader, this)); } reader.Close(); }
public Replay(Reader reader) { using (MemoryStream outMemoryStream = new MemoryStream()) { using (ZOutputStream decompress = new ZOutputStream(outMemoryStream)) { decompress.Write(reader.ReadBytes(reader.BaseStream.Length), 0, (int)reader.BaseStream.Length); decompress.finish(); reader.Close(); } Reader creader = new Reader(outMemoryStream); long shit = creader.ReadInt64(); //no idea what it do int count = creader.ReadInt32(); creader.Close(); } }
public Replay(Reader reader) { Reader creader = reader.GetCompressedStreamRaw(); //creader.BaseStream.Position = 0x84; byte[] data = new byte[creader.BaseStream.Length]; int[] data2 = new int[creader.BaseStream.Length / 4]; for (int i = 0; i < creader.BaseStream.Length; i++) { data[i] = creader.ReadByte(); } creader.BaseStream.Position = 0; for (int i = 0; i < creader.BaseStream.Length / 4; i++) { data2[i] = creader.ReadInt32(); } creader.Close(); //data[0]: Header //data[1]: Header //data[2]: Packed Flag //data[3]: Header //data[5]: EntryCount //data[11]: ??? //Entries Start: 14/0xE //Entry Size: 28/0x1C (bytes?) Writer writer = new Writer("Replay.bin"); writer.Write(data); writer.Close(); }
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 Replay(Reader reader) { Reader creader = reader.GetCompressedStreamRaw(); //creader.BaseStream.Position = 0x84; int[] data = new int[creader.BaseStream.Length / 4]; creader.BaseStream.Position = 0; for (int i = 0; i < creader.BaseStream.Length / 4; i++) { data[i] = creader.ReadInt32(); } creader.Seek(0, SeekOrigin.Begin); for (int i = 0; i < 14; i++) { Header[i] = creader.ReadInt32(); } for (int i = 0; i < Header[4]; i++) { ReplayEntry entry = new ReplayEntry(); entry.Data[0] = creader.ReadInt32(); //Inputs entry.Data[1] = creader.ReadInt32(); //Flags entry.Data[2] = creader.ReadInt32(); //Fuckery entry.Data[3] = creader.ReadInt32(); } //"CurrentEntity->ObjectID" is actually "Scene.Mode" //data[0]: Header //data[1]: ??? //data[2]: Packed Flag //data[3]: ActiveBuffer //data[4]: EntryCount //data[5]: FrameCount //data[6]: ZoneID (MenuParam[92]) //data[7]: ActID (MenuParam[93]) //data[8]: PlayerID (MenuParam[91]) //data[9]: PlusLayout //data[10]: Oscillation //data[11]: ??? //data[12]: ??? //data[13]: ??? //Entries Start: 14/0xE //Entry Size: 28 (bytes) (7 ints) //Entry[2]: Inputs //Input & 0x01 = ??? (Up) //Input & 0x02 = ??? (Down) //Input & 0x04 = ??? (Left) //Input & 0x08 = ??? (Right) //Input & 0x10 = ??? (JumpPress) //Input & 0x20 = ??? (JumpHold) creader.Close(); //Writer writer = new Writer("Replay.bin"); //writer.Write(data); //writer.Close(); }
public int unpack(Reader reader, bool isPacked) { int pos = (int)reader.BaseStream.Position; info = (InfoTypes)reader.ReadByte(); byte flags = reader.ReadByte(); if (isPacked) { bool flag = info == InfoTypes.StateChange || info == InfoTypes.PassedTimeAttackGate; if ((flags & (byte)FlagTypes.InputChange) != 0 || flag) { inputs = reader.ReadByte(); } if ((flags & (byte)FlagTypes.PositionChange) != 0 || flag) { position.x = reader.ReadInt32(); position.y = reader.ReadInt32(); } if ((flags & (byte)FlagTypes.VelocityChange) != 0 || flag) { velocity.x = reader.ReadInt32(); velocity.y = reader.ReadInt32(); } if ((flags & (byte)FlagTypes.RotationChange) != 0 || flag) { rotation = reader.ReadByte() << 1; } if ((flags & (byte)FlagTypes.DirectionChange) != 0 || flag) { direction = (Directions)reader.ReadByte(); } if ((flags & (byte)FlagTypes.AnimationChange) != 0 || flag) { anim = reader.ReadByte(); } if ((flags & (byte)FlagTypes.FrameChange) != 0 || flag) { frame = reader.ReadByte(); } } else { inputs = reader.ReadByte(); position.x = reader.ReadInt32(); position.y = reader.ReadInt32(); velocity.x = reader.ReadInt32(); velocity.y = reader.ReadInt32(); rotation = reader.ReadInt32(); direction = (Directions)reader.ReadByte(); anim = reader.ReadByte(); frame = reader.ReadByte(); } this.flags = (FlagTypes)flags; return((int)reader.BaseStream.Position - pos); }
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(); }