Exemplo n.º 1
0
        // Extracts the server's details from the query response and raises an event for it
        private bool ExtractGameInfo(byte[] response, int Length)
        {
            if (response[0] != 0xf7 || response[1] != 0x30) return false;

            GameInfo game = new GameInfo();

            game.GameId = BitConverter.ToInt32(response, 0xc);
            game.Name = StringFromArray(response, 0x14);

            int cryptstart = 0x14 + game.Name.Length + 1 + 1; // one extra byte after the server name
            byte[] decrypted = Decrypt(response, cryptstart);
            game.Map = StringFromArray(decrypted, 0xd);

            game.Port = BitConverter.ToUInt16(response, Length - 2);
            game.SlotCount = BitConverter.ToInt32(response, Length - 22);
            game.CurrentPlayers = BitConverter.ToInt32(response, Length - 14);
            game.PlayerSlots = BitConverter.ToInt32(response, Length - 10);

            if (FoundServer != null) FoundServer(game);
            SendGameAnnounce(game);

            return true;
        }
Exemplo n.º 2
0
 // The client wont update the player count unless this is sent
 public void SendGameAnnounce(GameInfo Game)
 {
     int players = Game.SlotCount - Game.PlayerSlots + Game.CurrentPlayers;
     byte[] packet = new byte[] { 0xf7, 0x32, 0x10, 0x00, (byte)Game.GameId, 0x00, 0x00, 0x00, (byte)players, 0, 0, 0, (byte)Game.SlotCount, 0, 0, 0 };
     mBrowseSocket.SendTo(packet, mClientEP);
 }
Exemplo n.º 3
0
        void mBrowser_FoundServer(GameInfo Game)
        {
            mGameInfo = Game;
            DisplayGameInfo();

            mFoundGame = true;
            mLastFoundServer = DateTime.Now;
        }