示例#1
0
        public static ServerInfoResult Parse(byte[] data)
        {
            var parser = new ResponseParser(data);

            parser.CurrentPosition += 5; //Header
            var result = new ServerInfoResult();

            result.Protocol    = parser.GetByte();
            result.Name        = parser.GetStringToTermination();
            result.Map         = parser.GetStringToTermination();
            result.Folder      = parser.GetStringToTermination();
            result.Game        = parser.GetStringToTermination();
            result.ID          = parser.GetShort();
            result.Players     = parser.GetByte();
            result.MaxPlayers  = parser.GetByte();
            result.Bots        = parser.GetByte();
            result.ServerType  = parser.GetStringOfByte();
            result.Environment = parser.GetStringOfByte();
            result.Visibility  = parser.GetByte();
            result.VAC         = parser.GetByte();
            result.Version     = parser.GetStringToTermination();

            //get EDF
            uint edf = parser.GetByte();

            if ((edf & 0x80) != 0) //has port number
            {
                result.Port = parser.GetShort();
            }

            return(result);
        }
示例#2
0
        public static ServerRulesResult Parse(byte[] bytes)
        {
            var result = new ServerRulesResult();
            var parser = new ResponseParser(bytes);

            parser.CurrentPosition += 7;
            while (parser.BytesLeft)
            {
                result.Add(parser.GetStringToTermination(), parser.GetStringToTermination());
            }
            return(result);
        }