godzcheater

COD MW2/3 Savegame

Mar 11th, 2012
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.18 KB | None | 0 0
  1.     public class savegame
  2.     {
  3.         public XboxClasses.IO.IO IO;
  4.  
  5.         public Header Header = new Header();
  6.         public System.Collections.Generic.List<System.Byte[]> Blocks = new System.Collections.Generic.List<System.Byte[]>();
  7.        
  8.         public savegame(XboxClasses.IO.IO _IO) { IO = _IO; }
  9.  
  10.         public void Read()
  11.         {
  12.             IO.Open(0);
  13.             Header.Read(ref IO);
  14.             Blocks.Clear();
  15.             for (System.Int32 i = 0; i < 8; i++)
  16.             {
  17.                 Blocks.Add(IO.Reader.ReadBytes(IO.Reader.ReadInt32() - 4));
  18.             }
  19.         }
  20.         public void Write()
  21.         {
  22.             IO.Open(1152);//Skip the header
  23.             for (System.Int32 i = 0; i < 8; i++)
  24.             {
  25.                 IO.Writer.WriteInt32(Blocks[i].Length + 4);
  26.                 IO.Writer.Write(Blocks[i]);
  27.             }
  28.             Header.Ints[12] = (System.Int32)IO.Writer.BaseStream.Position - 1152;//Checkthat it is actualy 12
  29.             IO.Reader.BaseStream.Position = 1152;
  30.             Header.CheckSum = Adler32.Compute(IO.Reader.ReadBytes(Header.Ints[12]));
  31.             IO.Writer.BaseStream.Position = 0;//goback and write the header
  32.             Header.Write(ref IO);
  33.         }
  34.     }
  35.     public class Header
  36.     {
  37.         public System.Int32 GameVersion = 0;
  38.         public System.Int32 Unknown = 0;
  39.         public System.Int32 CheckSum = 0;
  40.         public System.Byte[] Unkown2 = new System.Byte[20];
  41.         public System.String MapName = "";
  42.         public System.String DateTime = "";
  43.         public System.String Team = "";
  44.         public System.String Blah = "";
  45.         public System.String FileName = "savegome.svg";
  46.         public System.Int32[] Ints = new System.Int32[24];
  47.  
  48.         public void Read(ref XboxClasses.IO.IO IO)
  49.         {
  50.             GameVersion = IO.Reader.ReadInt32();
  51.             Unknown = IO.Reader.ReadInt32();
  52.             CheckSum = IO.Reader.ReadInt32();
  53.             Unkown2 = IO.Reader.ReadBytes(20);
  54.             MapName = IO.Reader.ReadASCII(256).Replace("\0", "");
  55.             DateTime = IO.Reader.ReadASCII(128).Replace("\0", "");
  56.             Team = IO.Reader.ReadASCII(320).Replace("\0", "");
  57.             Blah = IO.Reader.ReadASCII(256).Replace("\0", "");
  58.             FileName = IO.Reader.ReadASCII(64).Replace("\0", "");
  59.             for (System.Int32 i = 0; i < 24; i++)
  60.             {
  61.                 Ints[i] = IO.Reader.ReadInt32();
  62.             }
  63.         }
  64.         public void Write(ref XboxClasses.IO.IO IO)
  65.         {
  66.             IO.Writer.WriteInt32(GameVersion);
  67.             IO.Writer.WriteInt32(Unknown);
  68.             IO.Writer.WriteInt32(CheckSum);
  69.             IO.Writer.Write(Unkown2);
  70.             IO.Writer.WriteASCII(MapName.PadRight(256, (System.Char)0));
  71.             IO.Writer.WriteASCII(DateTime.PadRight(128, (System.Char)0));
  72.             IO.Writer.WriteASCII(Team.PadRight(320, (System.Char)0));
  73.             IO.Writer.WriteASCII(Blah.PadRight(256, (System.Char)0));
  74.             IO.Writer.WriteASCII(FileName.PadRight(64, (System.Char)0));
  75.             for (System.Int32 i = 0; i < 24; i++)
  76.             {
  77.                 IO.Writer.WriteInt32(Ints[i]);
  78.             }
  79.         }
  80.     }
Advertisement
Add Comment
Please, Sign In to add comment