Example #1
0
        private byte[] Decompress(BinaryReader Reader, Far3Entry Entry)
        {
            //Unknown part of the header, not needed for decompression.
            //NOTE: This header is part of the actual filedata if file isn't compressed.
            Reader.ReadBytes(9);

            //Read the compression header
            uint   Filesize      = Reader.ReadUInt32();
            ushort CompressionID = Reader.ReadUInt16();

            if (CompressionID == 0xFB10)
            {
                byte[] Dummy            = Reader.ReadBytes(3);
                uint   DecompressedSize = (uint)((Dummy[0] << 0x10) | (Dummy[1] << 0x08) | +Dummy[2]);

                Decompresser Dec = new Decompresser();
                Dec.CompressedSize   = Filesize;
                Dec.DecompressedSize = DecompressedSize;

                return(Dec.Decompress(Reader.ReadBytes((int)Filesize)));
            }
            else //The entry wasn't compressed...
            {
                Reader.BaseStream.Seek((Reader.BaseStream.Position - 15), SeekOrigin.Begin);
                return(Reader.ReadBytes((int)Entry.DecompressedFileSize));
            }
        }
Example #2
0
        private byte[] Decompress(BinaryReader Reader, Far3Entry Entry)
        {
            Reader.ReadBytes(9); //Unknown part of the header, not needed for decompression.

            //Read the compression header
            uint Filesize = Reader.ReadUInt32();
            ushort CompressionID = Reader.ReadUInt16();

            if (CompressionID == 0xFB10)
            {
                byte[] Dummy = Reader.ReadBytes(3);
                uint DecompressedSize = (uint)((Dummy[0] << 0x10) | (Dummy[1] << 0x08) | +Dummy[2]);

                /*return Uncompress(Reader.ReadBytes((int)Entry.CompressedFileSize), DecompressedSize, 0,
                    (int)Entry.CompressedFileSize, GameType.SimCity4);*/

                Decompresser Dec = new Decompresser();
                Dec.CompressedSize = Filesize;
                Dec.DecompressedSize = DecompressedSize;

                return Dec.Decompress(Reader.ReadBytes((int)Filesize));
            }
            else //The entry wasn't compressed...
            {
                MessageBox.Show("CompressionID didn't match!");
                Reader.BaseStream.Seek((Reader.BaseStream.Position - 6), SeekOrigin.Begin);
                return Reader.ReadBytes((int)Entry.DecompressedFileSize/*Entry.CalculateFileSize()*/);
            }
        }
Example #3
0
        private byte[] Decompress(BinaryReader Reader, Far3Entry Entry)
        {
            //Unknown part of the header, not needed for decompression.
            //NOTE: This header is part of the actual filedata if file isn't compressed.
            Reader.ReadBytes(9);

            //Read the compression header
            uint Filesize = Reader.ReadUInt32();
            ushort CompressionID = Reader.ReadUInt16();

            if (CompressionID == 0xFB10)
            {
                byte[] Dummy = Reader.ReadBytes(3);
                uint DecompressedSize = (uint)((Dummy[0] << 0x10) | (Dummy[1] << 0x08) | +Dummy[2]);

                Decompresser Dec = new Decompresser();
                Dec.CompressedSize = Filesize;
                Dec.DecompressedSize = DecompressedSize;

                return Dec.Decompress(Reader.ReadBytes((int)Filesize));
            }
            else //The entry wasn't compressed...
            {
                Reader.BaseStream.Seek((Reader.BaseStream.Position - 15), SeekOrigin.Begin);
                return Reader.ReadBytes((int)Entry.DecompressedFileSize);
            }
        }