Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GTASave
- {
- public XboxClasses.IO.IO IO;
- public System.Int32 Unk;
- public GameVersion GameVersion = GameVersion.GrandTheftAutoIV;
- public System.Int32 Unk2;
- public System.Collections.Generic.List<System.Byte[]> Blocks = new System.Collections.Generic.List<System.Byte[]>();
- public GTASave(XboxClasses.IO.IO _IO) { IO = _IO; }
- public void Read()
- {
- IO.Open(0);
- Unk = IO.Reader.ReadInt32();
- GameVersion = (GameVersion)IO.Reader.ReadInt32();
- Unk2 = IO.Reader.ReadInt32();
- IO.Reader.ReadASCII(4);//"Save"
- Blocks.Clear();
- for (System.Int32 i = 0; i < 32; i++)
- {
- System.String BLOCK = IO.Reader.ReadASCII(5);//always = "BLOCK"
- System.Int32 BlockLength = IO.Reader.ReadInt32();
- Blocks.Add(IO.Reader.ReadBytes(BlockLength - 9));//9 be "BLOCK" + BlockLength
- }
- }
- public void Write()
- {
- IO.Open(0);
- IO.Writer.WriteInt32(Unk);
- IO.Writer.WriteInt32((System.Int32)GameVersion);
- IO.Writer.WriteInt32(Unk2);
- IO.Writer.WriteASCII("SAVE");
- for (System.Int32 i = 0; i < Blocks.Count; i++)
- {
- IO.Writer.WriteASCII("BLOCK");
- IO.Writer.WriteInt32(Blocks[i].Length + 9);
- IO.Writer.Write(Blocks[i]);
- }
- //CheckSum
- System.Int32 EndBlockPos = (System.Int32)IO.Writer.BaseStream.Position;
- System.UInt32 CheckSum = 0;
- IO.Writer.BaseStream.Position = 0;
- for (System.Int32 i = 0; i < EndBlockPos; i++)
- {
- CheckSum += IO.Reader.ReadByte();
- }
- IO.Writer.WriteUInt32(CheckSum);
- IO.Writer.WriteASCII("END");
- IO.Writer.WriteInt8(0);
- IO.Writer.Flush();
- }
- }
- public enum GameVersion : int
- {
- GrandTheftAutoIV = 707822,
- TheLostandDamned = 604730,
- TheBalladofGayTony = 622706,
- }
Advertisement
Add Comment
Please, Sign In to add comment