private static void ProcessPacket(byte[] bytes) { var length = bytes.Length; uint seq, ack; byte flags; using (var stream = BitStreamUtil.Create(bytes)) { seq = stream.ReadInt(32); ack = stream.ReadInt(32); flags = stream.ReadByte(); ushort checksum = (ushort)stream.ReadInt(16); stream.BeginChunk((length - 11) * 8); ushort computed = CrcUtils.Compute16(stream); stream.EndChunk(); if (checksum != computed) { //Console.WriteLine( // "failed checksum:" // + "recv seq {0} ack {1} flags {2:x} checksum {3:x} computed {4:x}", // seq, ack, flags, checksum, computed); return; } } var remaining = new byte[length - 11]; Array.Copy(bytes, 11, remaining, 0, length - 11); using (var stream = BitStreamUtil.Create(remaining)) { byte reliableState = stream.ReadByte(); if ((flags & 0x10) == 0x10) { //Console.WriteLine( // "choke {0}: recv seq {1} ack {2} flags {3:x}", // stream.ReadByte(), seq, ack, flags); return; } if (seq < sequenceIn) { // We no longer care. //Console.WriteLine("dropped: recv seq {0} ack {1}", seq, ack); return; } if ((flags & (uint)PacketFlags.IsReliable) != 0) { return; } //filter2++; //Console.WriteLine($"filter2: {filter2}"); try { stream.BeginChunk((remaining.Length - 1) * 8); DemoPacketParser.ParsePacket(stream, demoParser); stream.EndChunk(); demoParser.ForceTick(true); } catch { } lastAckRecv = ack; sequenceIn = seq; } }