コード例 #1
0
 private void CheckFilePosition(IEXEntry entry)
 {
     if (_reader.BaseStream.Position != entry.EntryEnd)
     {
         throw new Exception("Failed to parse entry!");
     }
 }
コード例 #2
0
        private IEXEntry[] ReadEntryTable(BinaryReader reader)
        {
            uint numEntries = reader.ReadUInt32();

            IEXEntry[] array = new IEXEntry[numEntries];

            for (uint x = 0; x < numEntries; x++)
            {
                byte header = reader.ReadByte();
                if (header == 0x00)
                {
                    array[x] = null;

                    continue;
                }
                else if (header != 0x01)
                {
                    throw new Exception("Unexpected header!");
                }

                array[x] = ReadEntry(reader);
            }

            return(array);
        }
コード例 #3
0
        public void Read(BinaryReader reader)
        {
            _reader = reader;

            ReadHeader(reader);

            ReadStrings(reader);
            ReadGraphicsLookup(reader);
            ReadSoundLookup(reader);

            SoundEntries     = ReadEntryTable(reader);
            FontEntires      = ReadEntryTable(reader);
            CursorEntries    = ReadEntryTable(reader);
            TileEntries      = ReadEntryTable(reader);
            ObjectEntries    = ReadEntryTable(reader);
            CollisionEntries = ReadEntryTable(reader);
            ParticleEntries  = ReadEntryTable(reader);

            UnknownEntry  = ReadEntry(reader);
            FunctonTable1 = ReadEntry(reader);
            FunctonTable2 = ReadEntry(reader);

            LevelEntries = ReadNamedEntryTable(reader);
            GUIEntries   = ReadNamedEntryTable(reader);

            if (reader.BaseStream.Position != reader.BaseStream.Length)
            {
                throw new Exception("Failed to parse IEX successfully!");
            }
        }
コード例 #4
0
        public void CopyEntryToStream(IEXEntry entry, Stream target)
        {
            JumpToEntry(entry);

            byte[] buffer = _reader.ReadBytes(entry.Length);
            target.Write(buffer, 0, buffer.Length);

            CheckFilePosition(entry);
        }
コード例 #5
0
        public CollisionData ReadCollisionData(IEXEntry entry)
        {
            JumpToEntry(entry);

            CollisionData collision = CollisionData.Read(_reader);

            CheckFilePosition(entry);

            return(collision);
        }
コード例 #6
0
        public ObjectData ReadObjectData(IEXEntry entry)
        {
            JumpToEntry(entry);

            ObjectData obj = ObjectData.Read(_reader);

            CheckFilePosition(entry);

            return(obj);
        }
コード例 #7
0
        public CursorData ReadCursorData(IEXEntry entry)
        {
            JumpToEntry(entry);

            CursorData font = CursorData.Read(_reader);

            CheckFilePosition(entry);

            return(font);
        }
コード例 #8
0
        public FontData ReadFontData(IEXEntry entry)
        {
            JumpToEntry(entry);

            FontData font = FontData.Read(_reader);

            CheckFilePosition(entry);

            return(font);
        }
コード例 #9
0
        public SoundData ReadSoundData(IEXEntry entry)
        {
            JumpToEntry(entry);

            SoundData data = SoundData.Read(_reader);

            CheckFilePosition(entry);

            return(data);
        }
コード例 #10
0
        public LevelData ReadLevelData(IEXEntry entry)
        {
            JumpToEntry(entry);

            LevelData level = LevelData.Read(_reader);

            CheckFilePosition(entry);

            return(level);
        }
コード例 #11
0
        public GUIData ReadGUIData(IEXEntry entry)
        {
            JumpToEntry(entry);

            GUIData gui = GUIData.Read(_reader);

            CheckFilePosition(entry);

            return(gui);
        }
コード例 #12
0
        public ParticleData ReadParticleData(IEXEntry entry)
        {
            JumpToEntry(entry);

            ParticleData particle = ParticleData.Read(_reader);

            CheckFilePosition(entry);

            return(particle);
        }
コード例 #13
0
        private void WriteNamedEntryList(BinaryWriter writer, IEXEntry[] list)
        {
            writer.Write((uint)list.Length);

            for (uint x = 0; x < list.Length; x++)
            {
                IEXEntry entry = list[x];

                WriteNamedEntry(writer, entry);
            }
        }
コード例 #14
0
        //Read unnamed entries
        private IEXEntry ReadEntry(BinaryReader reader)
        {
            uint dataLength = reader.ReadUInt32();
            long dataEnd    = reader.BaseStream.Position + dataLength;

            IEXEntry entry = new IEXEntry(dataLength, reader.BaseStream.Position);

            reader.BaseStream.Position = dataEnd;

            return(entry);
        }
コード例 #15
0
        private void WriteEntry(BinaryWriter writer, IEXEntry entry)
        {
            writer.Write((uint)entry.Length);

            writer.Flush();

            using (FileStream data = File.OpenRead(entry.SourceFile))
            {
                data.CopyTo(writer.BaseStream);
            }
        }
コード例 #16
0
        //Read named entries
        private IEXEntry ReadNamedEntry(BinaryReader reader)
        {
            string name = reader.ReadTString();

            uint dataLength = reader.ReadUInt32();
            long dataEnd    = reader.BaseStream.Position + dataLength;

            IEXEntry entry = new IEXEntry(dataLength, reader.BaseStream.Position, name);

            reader.BaseStream.Position = dataEnd;

            return(entry);
        }
コード例 #17
0
        private IEXEntry[] ReadNamedEntryTable(BinaryReader reader)
        {
            uint numEntries = reader.ReadUInt32();

            IEXEntry[] array = new IEXEntry[numEntries];

            for (uint x = 0; x < numEntries; x++)
            {
                array[x] = ReadNamedEntry(reader);
            }

            return(array);
        }
コード例 #18
0
        public TileData ReadTileData(IEXEntry entry)
        {
            JumpToEntry(entry);

            uint magicNumber = _reader.ReadUInt32();             //Tile count?

            if (magicNumber != 0x01)
            {
                throw new Exception("Unexpected tile count");;
            }

            TileData tile = TileData.Read(_reader);

            CheckFilePosition(entry);

            return(tile);
        }
コード例 #19
0
        public GameFunction[] ReadFunctionTable(IEXEntry entry)
        {
            JumpToEntry(entry);

            uint entries = _reader.ReadUInt32();

            GameFunction[] array = new GameFunction[entries];

            for (uint x = 0; x < entries; x++)
            {
                array[x] = GameFunction.ReadFunction(_reader);
            }

            CheckFilePosition(entry);

            return(array);
        }
コード例 #20
0
        private void WriteIndexedEntryList(BinaryWriter writer, IEXEntry[] list)
        {
            writer.Write((uint)list.Length);

            for (uint x = 0; x < list.Length; x++)
            {
                IEXEntry entry = list[x];

                if (entry == null)
                {
                    writer.Write((byte)0x00);
                    continue;
                }

                writer.Write((byte)0x01);

                WriteEntry(writer, entry);
            }
        }
コード例 #21
0
 private void JumpToEntry(IEXEntry entry)
 {
     _reader.BaseStream.Position = entry.FileOffset;
 }