Example #1
0
        public SaveFile(String filePath, bool encrypted = true)
        {
            this.filePath = filePath;

            byte[] file = File.ReadAllBytes(filePath);
            byte[] data = encrypted ? Encryption.TransformData(file) : file;

            // Open save to process
            BinaryReader br = new BinaryReader(new MemoryStream(data));

            // Validate that file is a supported save format
            int version = br.ReadInt32();
            if (version != SAVE_VERSION)
            {
                throw new Exception(String.Format("Unsupported save version: {0}", version.ToString("X4")));
            }

            // Process blocks
            this.header = new DataBlock(br);
            this.gamedata = new GameDataBlock(br);
            this.footer = new DataBlock(br);

            // We're done with our reader
            br.Close();
        }
Example #2
0
        public SaveFile(String filePath, bool encrypted = true)
        {
            this.filePath = filePath;

            byte[] file = File.ReadAllBytes(filePath);
            byte[] data = encrypted ? Encryption.TransformData(file) : file;

            // Open save to process
            BinaryReader br = new BinaryReader(new MemoryStream(data));

            // Validate that file is a supported save format
            int version = br.ReadInt32();

            if (version != SAVE_VERSION)
            {
                throw new Exception(String.Format("Unsupported save version: {0}", version.ToString("X4")));
            }

            // Process blocks
            this.header   = new DataBlock(br);
            this.gamedata = new GameDataBlock(br);
            this.footer   = new DataBlock(br);

            // We're done with our reader
            br.Close();
        }