Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class savegame
- {
- public XboxClasses.IO.IO IO;
- public Header Header = new Header();
- public System.Collections.Generic.List<System.Byte[]> Blocks = new System.Collections.Generic.List<System.Byte[]>();
- public savegame(XboxClasses.IO.IO _IO) { IO = _IO; }
- public void Read()
- {
- IO.Open(0);
- Header.Read(ref IO);
- Blocks.Clear();
- for (System.Int32 i = 0; i < 8; i++)
- {
- Blocks.Add(IO.Reader.ReadBytes(IO.Reader.ReadInt32() - 4));
- }
- }
- public void Write()
- {
- IO.Open(1152);//Skip the header
- for (System.Int32 i = 0; i < 8; i++)
- {
- IO.Writer.WriteInt32(Blocks[i].Length + 4);
- IO.Writer.Write(Blocks[i]);
- }
- Header.Ints[12] = (System.Int32)IO.Writer.BaseStream.Position - 1152;//Checkthat it is actualy 12
- IO.Reader.BaseStream.Position = 1152;
- Header.CheckSum = Adler32.Compute(IO.Reader.ReadBytes(Header.Ints[12]));
- IO.Writer.BaseStream.Position = 0;//goback and write the header
- Header.Write(ref IO);
- }
- }
- public class Header
- {
- public System.Int32 GameVersion = 0;
- public System.Int32 Unknown = 0;
- public System.Int32 CheckSum = 0;
- public System.Byte[] Unkown2 = new System.Byte[20];
- public System.String MapName = "";
- public System.String DateTime = "";
- public System.String Team = "";
- public System.String Blah = "";
- public System.String FileName = "savegome.svg";
- public System.Int32[] Ints = new System.Int32[24];
- public void Read(ref XboxClasses.IO.IO IO)
- {
- GameVersion = IO.Reader.ReadInt32();
- Unknown = IO.Reader.ReadInt32();
- CheckSum = IO.Reader.ReadInt32();
- Unkown2 = IO.Reader.ReadBytes(20);
- MapName = IO.Reader.ReadASCII(256).Replace("\0", "");
- DateTime = IO.Reader.ReadASCII(128).Replace("\0", "");
- Team = IO.Reader.ReadASCII(320).Replace("\0", "");
- Blah = IO.Reader.ReadASCII(256).Replace("\0", "");
- FileName = IO.Reader.ReadASCII(64).Replace("\0", "");
- for (System.Int32 i = 0; i < 24; i++)
- {
- Ints[i] = IO.Reader.ReadInt32();
- }
- }
- public void Write(ref XboxClasses.IO.IO IO)
- {
- IO.Writer.WriteInt32(GameVersion);
- IO.Writer.WriteInt32(Unknown);
- IO.Writer.WriteInt32(CheckSum);
- IO.Writer.Write(Unkown2);
- IO.Writer.WriteASCII(MapName.PadRight(256, (System.Char)0));
- IO.Writer.WriteASCII(DateTime.PadRight(128, (System.Char)0));
- IO.Writer.WriteASCII(Team.PadRight(320, (System.Char)0));
- IO.Writer.WriteASCII(Blah.PadRight(256, (System.Char)0));
- IO.Writer.WriteASCII(FileName.PadRight(64, (System.Char)0));
- for (System.Int32 i = 0; i < 24; i++)
- {
- IO.Writer.WriteInt32(Ints[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment