/// <summary>
        ///     Initializes a new instance of the <see cref="DemoReader" /> class.
        /// </summary>
        /// <param name="demoStream">The demo stream.</param>
        /// <param name="gameVersion">The game type.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if demoStream or extension is null.
        /// </exception>
        public DemoReader(Stream demoStream, GameVersion gameVersion)
        {
            if (demoStream == null)
            {
                throw new ArgumentNullException("demoStream");
            }

            _demoStream  = demoStream;
            _gameVersion = gameVersion;

            // Initialize the huffman tree.
            _huffmanTree =
                new HuffmanTree(gameVersion == GameVersion.CallOfDuty2
                    ? HuffmanFrequencies.Quake3
                    : HuffmanFrequencies.CallOfDuty4);

            // Skip first byte.
            if (_gameVersion == GameVersion.CallOfDuty4 || _gameVersion == GameVersion.CallOfDuty5)
            {
                _demoStream.Seek(1, SeekOrigin.Begin);
            }
        }
Exemple #2
0
 /// <summary>
 ///     Decodes this message using the specified huffman tree.
 /// </summary>
 /// <param name="huffmanTree">The huffman tree to use.</param>
 /// <returns>The decoded message.</returns>
 public DemoMessage Decode(HuffmanTree huffmanTree)
 {
     return(new DemoMessage(huffmanTree.Decode(new BitArray(Data))));
 }