예제 #1
0
        private void FromMessage(byte[] msg)
        {
            int i = 4;

            byte first = msg[i];

            if (first == (byte)PacketType.A2S_INFO)             // Skip first byte if you haven't already.
            {
                first = msg[++i];
            }

            this.Version = first;

            this.ServerName      = ByteExtensions.GetString(msg, ++i, ref i);
            this.MapName         = ByteExtensions.GetString(msg, i, ref i);
            this.GameDirectory   = ByteExtensions.GetString(msg, i, ref i);
            this.GameDescription = ByteExtensions.GetString(msg, i, ref i);

            this.Application = (SteamApplication)ByteExtensions.GetShort(msg, i, ref i);

            this.NumPlayers   = msg[i];
            this.MaxPlayers   = msg[++i];
            this.NumBots      = msg[++i];
            this.Dedicated    = (Dedicated)msg[++i];
            this.HostOS       = (HostOS)msg[++i];
            this.IsPassworded = (msg[++i] == 0x01);
            this.IsSecure     = (msg[++i] == 0x01);

            this.GameVersion = ByteExtensions.GetString(msg, i, ref i);

            var edf = (ExtraDataFlag)msg[i];

            if ((edf & ExtraDataFlag.GamePort) == ExtraDataFlag.GamePort)
            {
                this.GameServerPort = ByteExtensions.GetShort(msg, i, ref i);
            }

            if ((edf & ExtraDataFlag.Spectator) == ExtraDataFlag.Spectator)
            {
                this.SpectatorPort       = ByteExtensions.GetShort(msg, i, ref i);
                this.SpectatorServerName = ByteExtensions.GetString(msg, i, ref i);
            }

            if ((edf & ExtraDataFlag.GameTagData) == ExtraDataFlag.GameTagData)
            {
                this.GameTagData = ByteExtensions.GetString(msg, i, ref i);
            }
        }