withSIX.Play.Core.Games.Legacy.ServerQuery.SourceServerQuery.CollectPacket C# (CSharp) Method

CollectPacket() private method

private CollectPacket ( byte reply, int pos ) : byte[]
reply byte
pos int
return byte[]
        byte[] CollectPacket(byte[] reply, int pos) {
            //TODO: test if this works on old source server or mockup
            var id = BitConverter.ToInt32(reply, pos);
            pos += 4;
            var bzipped = (id & 0x80000000) != 0;
            var total = reply[pos++];
            var number = reply[pos++];
            pos += 2; //ignoring next short
            if (bzipped) {
                throw new Exception("bzip2 compression not implemented");
                /*
                if (!_bzipDict.ContainsKey(id))
                {
                    _bzipDict[id] = new byte[total + 2][];
                    _bzipDict[id][total] = new byte[1];
                }
                if (number == 0)
                {
                    _bzipDict[id][total + 1] = reply.Skip(pos).Take(4).ToArray();
                    pos += 4;
                }
                _bzipDict[id][number] = reply.Skip(pos).ToArray();
                var runTotal = _bzipDict[id][total][0]++;
                if (runTotal == total) JoinPackets(id, total, true);
                 */
            }
            //else
            if (!_plainDict.ContainsKey(id)) {
                _plainDict[id] = new byte[total + 1][];
                _plainDict[id][total] = new byte[1];
            }
            _plainDict[id][number] = reply.Skip(pos).ToArray();
            var runTotal = _plainDict[id][total][0]++;
            if (runTotal == total)
                return JoinPackets(id, total, false);

            return null;
        }