Exemple #1
0
        public static ReplayHeader FromReader(BinaryReader reader)
        {
            if (new string(reader.ReadChars(HeaderString.Length)) != HeaderString)
            {
                throw new InvalidDataException("Invalid file header.");
            }

            var header = new ReplayHeader();

            header._dataOffset       = reader.ReadUInt32();
            header._compressedSize   = reader.ReadUInt32();
            header._headerVersion    = reader.ReadUInt32();
            header._decompressedSize = reader.ReadUInt32();
            header._dataBlocksCount  = reader.ReadUInt32();

            if (header._headerVersion == 0x01)
            {
                header._gameIdentifier = reader.ReadUInt32();
                header._gameVersion    = reader.ReadUInt32();
                header._build          = reader.ReadUInt16();
                header._flags          = reader.ReadUInt16();
                header._gameLength     = reader.ReadUInt32();
                header._checksum       = reader.ReadUInt32();
            }
            else
            {
                throw new NotSupportedException("Only header version 1 is supported.");
            }

            return(header);
        }
Exemple #2
0
        public void Parse(Stream stream, bool leaveOpen = false)
        {
            using var reader = new BinaryReader(stream, new UTF8Encoding(false, true), leaveOpen);

            _header = ReplayHeader.FromReader(reader);

            Decompress(reader);
        }