Ejemplo n.º 1
0
        static SourceParseResult ParseSettings(byte[] info)
        {
            var r = new Reader(info);

            r.Skip(5);
            var settings = new SourceParseResult();

            settings.Protocol       = r.ReadAsInt();
            settings.Name           = r.ReadStringUntil();
            settings.Map            = r.ReadStringUntil();
            settings.Folder         = r.ReadStringUntil();
            settings.Game           = r.ReadStringUntil();
            settings.AppId          = r.ReadShort();
            settings.CurrentPlayers = r.ReadAsInt();
            settings.MaxPlayers     = r.ReadAsInt();
            settings.BotCount       = r.ReadAsInt();
            settings.ServerType     = r.ReadAsInt();
            settings.Environment    = r.ReadAsInt();
            settings.Visibility     = r.ReadAsInt();
            settings.Vac            = r.ReadAsInt();
            //if The Ship, additional fields:
            //_results.mode = reply[pos++];
            //_results.witnesses = reply[pos++];
            //_results.duration = reply[pos++];
            settings.Version = r.ReadStringUntil();
            var edf = r.ReadByte();

            //settings.edf = edf.ToString(CultureInfo.InvariantCulture);
            if ((edf & 0x80) != 0)
            {
                settings.Port = r.ReadShort();
            }
            if ((edf & 0x10) != 0)
            {
                settings.SteamId = r.ReadLong();
            }
            if ((edf & 0x40) != 0)
            {
                settings.TvPort = r.ReadShort();
                settings.TvName = r.ReadStringUntil();
            }
            if ((edf & 0x20) != 0)
            {
                settings.Keywords = r.ReadStringUntil();
            }
            //gameID = full appID if was truncated in previous field (not always the case)
            if ((edf & 0x01) != 0)
            {
                settings.AppId = r.ReadLong();
            }

            return(settings);
        }
        static SourceParseResult ParseSettings(byte[] info) {
            var r = new Reader(info);
            r.Skip(5);
            var settings = new SourceParseResult();
            settings.Protocol = r.ReadAsInt();
            settings.Name = r.ReadStringUntil();
            settings.Map = r.ReadStringUntil();
            settings.Folder = r.ReadStringUntil();
            settings.Game = r.ReadStringUntil();
            settings.AppId = r.ReadShort();
            settings.CurrentPlayers = r.ReadAsInt();
            settings.MaxPlayers = r.ReadAsInt();
            settings.BotCount = r.ReadAsInt();
            settings.ServerType = r.ReadAsInt();
            settings.Environment = r.ReadAsInt();
            settings.Visibility = r.ReadAsInt();
            settings.Vac = r.ReadAsInt();
            //if The Ship, additional fields:
            //_results.mode = reply[pos++];
            //_results.witnesses = reply[pos++];
            //_results.duration = reply[pos++];
            settings.Version = r.ReadStringUntil();
            var edf = r.ReadByte();
            //settings.edf = edf.ToString(CultureInfo.InvariantCulture);
            if ((edf & 0x80) != 0)
                settings.Port = r.ReadShort();
            if ((edf & 0x10) != 0)
                settings.SteamId = r.ReadLong();
            if ((edf & 0x40) != 0) {
                settings.TvPort = r.ReadShort();
                settings.TvName = r.ReadStringUntil();
            }
            if ((edf & 0x20) != 0) {
                settings.Keywords = r.ReadStringUntil();
            }
            //gameID = full appID if was truncated in previous field (not always the case)
            if ((edf & 0x01) != 0)
                settings.AppId = r.ReadLong();

            return settings;
        }
 public SourceServerQueryResult(IPEndPoint ep, SourceParseResult settings, bool isMasterResult = false)
     : base(ep, settings, isMasterResult) {}