godzcheater

Angry Birds Trilogy

Nov 10th, 2012
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.75 KB | None | 0 0
  1.     public class savemagic//<3 this format, only thing is they should store the name length
  2.     {
  3.         public savemagic Create(IO.IO IO)
  4.         {
  5.             savemagic Save = new savemagic();
  6.             Save.IO = IO;
  7.             Save.Write();
  8.  
  9.             return Save;
  10.         }
  11.  
  12.         #region Init
  13.         public savemagic(IO.IO _IO) { IO = _IO; Read(); }
  14.         public savemagic(System.String FilePath) { IO = new IO.IO(FilePath, System.IO.FileMode.Open, true); Read(); }
  15.         internal savemagic()
  16.         {
  17.             Properties = new System.Collections.Generic.Dictionary<System.String, Property>();
  18.         }
  19.         #endregion
  20.  
  21.         #region vars
  22.         public IO.IO IO;
  23.  
  24.         public System.Collections.Generic.Dictionary<System.String, Property> Properties { get; set; }
  25.         #endregion
  26.  
  27.         #region voids
  28.         public void Read()
  29.         {
  30.             IO.BaseStream.Position = 0;
  31.             if (IO.Reader.ReadInt32() != 825458603)
  32.             {
  33.                 IO.BaseStream.Close();
  34.                 throw new InvalidMagic(new System.Exception("Invalid FileMagic"));
  35.             }
  36.             System.Int32 Count = IO.Reader.ReadInt32();
  37.             Properties = new System.Collections.Generic.Dictionary<System.String, Property>();
  38.             for (System.Int32 PropertyIndex = 0; PropertyIndex < Count; PropertyIndex++)
  39.             {
  40.                 Property Property = new Property();
  41.                 Property.Name = IO.Reader.ReadASCIIString();
  42.                 Property.Flags = IO.Reader.ReadInt32();
  43.                 Property.Data = IO.Reader.ReadBytes(IO.Reader.ReadInt32());
  44.  
  45.                 Properties.Add(Property.Name, Property);
  46.             }
  47.         }
  48.         public void Write()
  49.         {
  50.             IO.BaseStream.Position = 0;
  51.             IO.Writer.WriteInt32(825458603);
  52.             IO.Writer.WriteInt32(Properties.Count);
  53.             foreach (System.Collections.Generic.KeyValuePair<System.String, Property> Property in Properties)
  54.             {
  55.                 IO.Writer.WriteASCIIString(Property.Value.Name + "\0");
  56.                 IO.Writer.WriteInt32(Property.Value.Flags);
  57.                 IO.Writer.WriteInt32(Property.Value.Data.Length);
  58.                 IO.Writer.WriteBytes(Property.Value.Data);
  59.             }
  60.             IO.BaseStream.SetLength(IO.BaseStream.Position);
  61.         }
  62.         #endregion
  63.  
  64.         public class InvalidMagic : System.Exception
  65.         {
  66.             public InvalidMagic(System.Exception Inner) : base("Invalid FileMagic", Inner) { }
  67.         }
  68.     }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.     public class Property
  83.     {
  84.         public System.String Name { get; set; }
  85.         public System.Int32 Flags { get; set; }//?
  86.         public System.Byte[] Data { get; set; }
  87.     }
Advertisement
Add Comment
Please, Sign In to add comment