godzcheater

GTA IV savegame

Dec 18th, 2011
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1.     public class GTASave
  2.     {
  3.         public XboxClasses.IO.IO IO;
  4.  
  5.         public System.Int32 Unk;
  6.         public GameVersion GameVersion = GameVersion.GrandTheftAutoIV;
  7.         public System.Int32 Unk2;
  8.         public System.Collections.Generic.List<System.Byte[]> Blocks = new System.Collections.Generic.List<System.Byte[]>();
  9.  
  10.         public GTASave(XboxClasses.IO.IO _IO) { IO = _IO; }
  11.  
  12.         public void Read()
  13.         {
  14.             IO.Open(0);
  15.             Unk = IO.Reader.ReadInt32();
  16.             GameVersion = (GameVersion)IO.Reader.ReadInt32();
  17.             Unk2 = IO.Reader.ReadInt32();
  18.             IO.Reader.ReadASCII(4);//"Save"
  19.             Blocks.Clear();
  20.             for (System.Int32 i = 0; i < 32; i++)
  21.             {
  22.                 System.String BLOCK = IO.Reader.ReadASCII(5);//always = "BLOCK"
  23.                 System.Int32 BlockLength = IO.Reader.ReadInt32();
  24.                 Blocks.Add(IO.Reader.ReadBytes(BlockLength - 9));//9 be "BLOCK" + BlockLength
  25.             }
  26.         }
  27.         public void Write()
  28.         {
  29.             IO.Open(0);
  30.             IO.Writer.WriteInt32(Unk);
  31.             IO.Writer.WriteInt32((System.Int32)GameVersion);
  32.             IO.Writer.WriteInt32(Unk2);
  33.             IO.Writer.WriteASCII("SAVE");
  34.             for (System.Int32 i = 0; i < Blocks.Count; i++)
  35.             {
  36.                 IO.Writer.WriteASCII("BLOCK");
  37.                 IO.Writer.WriteInt32(Blocks[i].Length + 9);
  38.                 IO.Writer.Write(Blocks[i]);
  39.             }
  40.             //CheckSum
  41.             System.Int32 EndBlockPos = (System.Int32)IO.Writer.BaseStream.Position;
  42.             System.UInt32 CheckSum = 0;
  43.             IO.Writer.BaseStream.Position = 0;
  44.             for (System.Int32 i = 0; i < EndBlockPos; i++)
  45.             {
  46.                 CheckSum += IO.Reader.ReadByte();
  47.             }
  48.             IO.Writer.WriteUInt32(CheckSum);
  49.             IO.Writer.WriteASCII("END");
  50.             IO.Writer.WriteInt8(0);
  51.             IO.Writer.Flush();
  52.         }
  53.     }
  54.     public enum GameVersion : int
  55.     {
  56.         GrandTheftAutoIV = 707822,
  57.         TheLostandDamned = 604730,
  58.         TheBalladofGayTony = 622706,
  59.     }
Advertisement
Add Comment
Please, Sign In to add comment