Example #1
0
        private void ReadInitialLoadSegment(ref ShockwaveReader input, AfterBurnerMapEntry[] entries, Dictionary <int, ChunkItem> chunks)
        {
            //First entry in the AfterBurnerMap must be ILS.
            AfterBurnerMapEntry ilsEntry = entries[0];

            input.Advance(ilsEntry.Offset);

            //TODO: this shouldn't be here
            ReadOnlySpan <byte> compressedData = input.ReadBytes(ilsEntry.Length);

            Span <byte> decompressedData = ilsEntry.DecompressedLength <= 1024 ?
                                           stackalloc byte[ilsEntry.DecompressedLength] : new byte[ilsEntry.DecompressedLength];

            ZLib.Decompress(compressedData, decompressedData);

            ShockwaveReader ilsReader = new ShockwaveReader(decompressedData, input.IsBigEndian);

            while (ilsReader.IsDataAvailable)
            {
                int id = ilsReader.ReadVarInt();

                AfterBurnerMapEntry entry = entries.FirstOrDefault(e => e.Id == id); //TODO: Chunk entries as dictionary
                if (entry == null)
                {
                    break;
                }

                chunks.Add(id, Read(ref ilsReader, entry.Header));
            }
        }
        public AfterburnerMapChunk(ref ShockwaveReader input, ChunkHeader header)
            : base(header)
        {
            input.ReadByte();
            Remnants.Enqueue(input.ReadVarInt());

            using DeflateShockwaveReader deflaterInput = CreateDeflateReader(ref input);
            Remnants.Enqueue(deflaterInput.ReadVarInt());
            Remnants.Enqueue(deflaterInput.ReadVarInt());

            Entries = new AfterBurnerMapEntry[deflaterInput.ReadVarInt()];
            for (int i = 0; i < Entries.Length; i++)
            {
                Entries[i] = new AfterBurnerMapEntry(deflaterInput);
            }
        }
Example #3
0
 public ChunkHeader(ref ShockwaveReader input)
     : this((ChunkKind)input.ReadBEInt32())
 {
     Length = IsVariableLength ?
              input.ReadVarInt() : input.ReadBEInt32();
 }