private byte[] decompressFile(int pntr)
 {
     if (File.Exists(this.outDir + pntr.ToString("x")))
     {
         return(new byte[0]);
     }
     try
     {
         if (pntr == 0)
         {
             return(new byte[0]);
         }
         int    num1           = (int)this.rom[pntr] * 16777216 + (int)this.rom[pntr + 1] * 65536 + (int)this.rom[pntr + 2] * 256 + (int)this.rom[pntr + 3];
         int    compressedSize = this.getNextPointer(pntr) - num1;
         int    num2           = num1 + 68816;
         byte[] numArray       = new byte[compressedSize];
         for (int index = 0; index < compressedSize; ++index)
         {
             numArray[index] = this.rom[num2 + index];
         }
         GECompression geCompression = new GECompression();
         byte[]        Buffer        = numArray;
         geCompression.SetCompressedBuffer(Buffer, Buffer.Length);
         int fileSize = 0;
         return(geCompression.OutputDecompressedBuffer(ref fileSize, ref compressedSize));
     }
     catch (Exception ex)
     {
         return(new byte[0]);
     }
 }
        public bool getModelFile(int F9CAE0_file_loc, int size, int sceneID, int pntr, bool b)
        {
            bool          flag           = true;
            GECompression geCompression  = new GECompression();
            int           fileSize       = 0;
            int           compressedSize = 0;

            byte[] Buffer = this.arrayCopy(F9CAE0_file_loc, size);
            geCompression.SetCompressedBuffer(Buffer, Buffer.Length);
            byte[] numArray = geCompression.OutputDecompressedBuffer(ref fileSize, ref compressedSize);
            int    num      = 0;

            for (int index = 30288; index < 33412 && num == 0; index += 24)
            {
                if ((int)numArray[index] == (int)(byte)(sceneID >> 8) && (int)numArray[index + 1] == (int)(byte)sceneID)
                {
                    num = index;
                }
            }
            if (!b && numArray[num + 2] == (byte)0 && numArray[num + 3] == (byte)0)
            {
                flag = false;
            }
            if (b && numArray[num + 4] == (byte)0 && numArray[num + 5] == (byte)0)
            {
                flag = false;
            }
            return(flag);
        }
        public int setModelFile(
            int F9CAE0_file_loc,
            int size,
            int sceneID,
            int pntr,
            bool b,
            bool clear)
        {
            GECompression geCompression  = new GECompression();
            int           fileSize       = 0;
            int           compressedSize = 0;

            byte[] Buffer = this.arrayCopy(F9CAE0_file_loc, size);
            geCompression.SetCompressedBuffer(Buffer, Buffer.Length);
            byte[] buffer = geCompression.OutputDecompressedBuffer(ref fileSize, ref compressedSize);
            int    num1   = 0;

            for (int index = 30288; index < 33412 && num1 == 0; index += 24)
            {
                if ((int)buffer[index] == (int)(byte)(sceneID >> 8) && (int)buffer[index + 1] == (int)(byte)sceneID)
                {
                    num1 = index;
                }
            }
            int num2 = (pntr - 24216) / 8;

            if (!b && !clear)
            {
                buffer[num1 + 2] = (byte)(num2 >> 8);
                buffer[num1 + 3] = (byte)num2;
            }
            if (!b & clear)
            {
                buffer[num1 + 2] = (byte)0;
                buffer[num1 + 3] = (byte)0;
            }
            if (b && !clear)
            {
                buffer[num1 + 4] = (byte)(num2 >> 8);
                buffer[num1 + 5] = (byte)num2;
            }
            if (b & clear)
            {
                buffer[num1 + 4] = (byte)0;
                buffer[num1 + 5] = (byte)0;
            }
            FileStream   fileStream   = File.Create(this.outDir + "F9CAE0.bin");
            BinaryWriter binaryWriter = new BinaryWriter((Stream)fileStream);

            binaryWriter.Write(buffer, 0, ((IEnumerable <byte>)buffer).Count <byte>());
            binaryWriter.Close();
            fileStream.Close();
            return(this.insertDecompressedFile(this.outDir, "F9CAE0.bin", F9CAE0_file_loc, compressedSize, true));
        }
        private int getCompressedFileSize(int l)
        {
            byte[]        numArray      = this.arrayCopy(l, 1048576);
            GECompression geCompression = new GECompression();

            byte[] Buffer = numArray;
            geCompression.SetCompressedBuffer(Buffer, Buffer.Length);
            int compressedSize = 0;
            int fileSize       = 0;

            geCompression.OutputDecompressedBuffer(ref fileSize, ref compressedSize);
            return(compressedSize);
        }
        public static byte[] DecompressFileToByteArray(int pntr)
        {
            int num1           = (int)RomHandler.rom[pntr] * 16777216 + (int)RomHandler.rom[pntr + 1] * 65536 + (int)RomHandler.rom[pntr + 2] * 256 + (int)RomHandler.rom[pntr + 3];
            int compressedSize = RomHandler.getNextPointer(pntr) - num1;
            int num2           = num1 + 68816;

            byte[] numArray = new byte[compressedSize];
            for (int index = 0; index < compressedSize; ++index)
            {
                numArray[index] = RomHandler.rom[num2 + index];
            }
            GECompression geCompression = new GECompression();

            byte[] Buffer = numArray;
            geCompression.SetCompressedBuffer(Buffer, Buffer.Length);
            int fileSize = 0;

            return(geCompression.OutputDecompressedBuffer(ref fileSize, ref compressedSize));
        }
        public int insertDecompressedFile(
            string outDir,
            string file,
            int location,
            int originalSize,
            bool special)
        {
            int num1 = 0;

            if (!special)
            {
                originalSize = 0;
                while (originalSize == 0)
                {
                    int nextPointer = this.getNextPointer(location);
                    int num2        = (int)this.rom[location] * 16777216 + (int)this.rom[location + 1] * 65536 + (int)this.rom[location + 2] * 256 + (int)this.rom[location + 3];
                    int num3        = num2;
                    originalSize = nextPointer - num3;
                    num1         = num2 + 68816;
                }
            }
            GECompression geCompression = new GECompression();

            geCompression.SetPath(Directory.GetCurrentDirectory() + "\\out\\");
            if (special)
            {
                geCompression.padding = false;
            }
            if (file.Contains(".\\resources\\"))
            {
                string inputFile = file;
                file = inputFile.Replace(".\\resources\\", "");
                geCompression.CompressGZipFile(inputFile, outDir + file + ".1172", false);
            }
            else
            {
                geCompression.CompressGZipFile(outDir + file, outDir + file + ".1172", false);
            }
            BinaryReader binaryReader = new BinaryReader((Stream)File.Open(outDir + file + ".1172", FileMode.Open));
            int          length       = (int)binaryReader.BaseStream.Length;

            byte[] buffer = new byte[length];
            binaryReader.BaseStream.Read(buffer, 0, length);
            binaryReader.Close();
            long num4 = (long)(length - originalSize);
            int  num5 = 66060288;

            if (num4 > 0L)
            {
                int num2 = location + originalSize;
                if (!special)
                {
                    num2 = num1 + originalSize;
                }
                for (int index = (int)((long)(num5 - 1) - num4); index >= num2; --index)
                {
                    this.rom[(long)index + num4] = this.rom[index];
                }
                for (int index = 0; index < buffer.Length; ++index)
                {
                    if (!special)
                    {
                        this.rom[num1 + index] = buffer[index];
                    }
                    else
                    {
                        this.rom[location + index] = buffer[index];
                    }
                }
            }
            else
            {
                int num2 = location + buffer.Length;
                if (!special)
                {
                    num2 = num1 + buffer.Length;
                }
                int index1 = location + originalSize;
                if (!special)
                {
                    index1 = num1 + originalSize;
                }
                for (int index2 = num2; (long)index2 < (long)num5 + num4; ++index2)
                {
                    this.rom[index2] = this.rom[index1];
                    ++index1;
                }
                for (int index2 = num5 + (int)num4; index2 < num5; ++index2)
                {
                    this.rom[index2] = byte.MaxValue;
                }
                for (int index2 = 0; index2 < buffer.Length; ++index2)
                {
                    if (!special)
                    {
                        this.rom[num1 + index2] = buffer[index2];
                    }
                    else
                    {
                        this.rom[location + index2] = buffer[index2];
                    }
                }
            }
            this.updateAllPointers(location, (int)num4, special);
            return((int)num4);
        }