Exemple #1
0
        private void Decompress()
        {
            CatHeader    CompHeader = new CatHeader();
            StructReader Reader     = new StructReader(new MemoryStream(Script), false, Encoding);

            Reader.ReadStruct(ref CompHeader);

            if (CompHeader.Singnature != "CatScene")
            {
                throw new Exception("This isn't a valid CatSystem2 Script");
            }
            MemoryStream Decompressed = new MemoryStream();

            Algo.DecompressData(Reader.BaseStream, Decompressed);

            if (CompHeader.DecompressedSize != Decompressed.Length)
            {
                throw new Exception("Corrupted Script");
            }

            Reader.Close();
            Script = Decompressed.ToArray();
            Decompressed.Close();
            this.Decompressed = true;
        }
Exemple #2
0
        private byte[] Compress(byte[] Input)
        {
            byte[] Compressed;
            Algo.CompressData(Input, out Compressed);
            CatHeader Header = new CatHeader()
            {
                Singnature       = "CatScene",
                CompressedSize   = (uint)Compressed.LongLength,
                DecompressedSize = (uint)Input.LongLength
            };

            byte[] Output = new byte[0x10 + Header.CompressedSize];
            Tools.BuildStruct(ref Header, false, Encoding).CopyTo(Output, 0);
            Compressed.CopyTo(Output, 0x10);

            Input      = new byte[0];
            Compressed = new byte[0];

            return(Output);
        }