Ejemplo n.º 1
0
        private void FromMessage(byte[] msg)
        {
            int i = 4;

            byte first = msg[i];

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

            this.NumPlayers = first;

            this.players = new List <IPlayer> (this.NumPlayers);

            for (int p = 0; p < this.NumPlayers; ++p)
            {
                var player = new SourcePlayer();
                player.Index         = msg[++i];
                player.Name          = ByteExtensions.GetString(msg, ++i, ref i);
                player.Score         = ByteExtensions.GetInt32(msg, i, ref i);
                player.TimeConnected = ByteExtensions.GetSingle(msg, i, ref i);

                this.players.Add(player);
            }
        }