コード例 #1
0
ファイル: Playback.cs プロジェクト: NaphalAXT/WarUOSallos
 public void Dispose()
 {
     if (this._stream == null)
     {
         return;
     }
     this._stream.Close();
     this._stream = (GZBlockIn)null;
 }
コード例 #2
0
ファイル: Playback.cs プロジェクト: NaphalAXT/WarUOSallos
        private void Open(Stream stream)
        {
            this._stream  = new GZBlockIn(stream);
            this._version = (int)this._stream.Raw.ReadByte();
            if (this._version > 4)
            {
                this.Dispose();
                throw new VersionMismatchException();
            }
            this._stream.IsCompressed = this._version > 1;
            this._hashCode            = this._stream.Raw.ReadBytes(16);
            this._timeStamp           = DateTime.FromFileTime(this._stream.Raw.ReadInt64());
            this._duration            = TimeSpan.FromMilliseconds((double)this._stream.Raw.ReadInt32());
            this._playerName          = this._stream.Compressed.ReadString();
            this._serverName          = this._stream.Compressed.ReadString();
            if (this._version > 1)
            {
                this._ipAddress = new IPAddress((long)this._stream.Compressed.ReadUInt32());
            }
            this._origin = this._stream.Position;
            long position = this._stream.RawStream.Position;

            this._stream.RawStream.Seek(17L, SeekOrigin.Begin);
            using (MD5 md5 = MD5.Create())
            {
                byte[] hash = md5.ComputeHash(this._stream.RawStream);
                for (int index = 0; index < hash.Length; ++index)
                {
                    if ((int)hash[index] != (int)this.HashCode[index])
                    {
                        this.Dispose();
                        throw new HashCodeMismatchException();
                    }
                }
            }
            this._stream.RawStream.Seek(position, SeekOrigin.Begin);
        }