Exemple #1
0
        public void Load(ProjectReader reader)
        {
            int magic = reader.ReadInt32();

            if (magic != GMProject.GMMagic)
            {
                throw new Exception("Invalid GEX magic, got " + magic);
            }

            Version = reader.ReadInt32();
            if (Version != 701)
            {
                throw new Exception("Invalid GEX version, got " + Version);
            }

            Seed = reader.ReadInt32();
            Lookup(Seed);

            // Decrypt GED/DAT
            var gedStream = new MemoryStream();

            gedStream.WriteByte((byte)reader.ReadByte()); // first byte is never encrypted.

            while (true)
            {
                int bb = reader.ReadByte();
                if (bb < 0)
                {
                    break;
                }

                // non-additive mode.
                gedStream.WriteByte(GMKrypt[1][(byte)bb]);
            }

            gedStream.Seek(0, SeekOrigin.Begin);
            var gedReader = new ProjectReader(gedStream);

            Package = new GED();
            Package.Load(gedReader);

            RawDATs = new List <byte[]>(Package.Files.Count);
            for (int i = 0; i < Package.Files.Count; i++)
            {
                //if (Package.Files[i].Kind != GEDFile.GEDFileKind.ActionLib) // ???????????????????????????
                RawDATs.Add(gedReader.ReadCompressedStream());
            }

            gedStream.Dispose();
            gedReader.Dispose();
        }