Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 21, 2011, 4:01:44 PM (14 years ago)
Author:
smerkli
Message:

ms-delserver command implemented to kick servers from the master server list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/masterserver2/src/libraries/network/MasterServer.cc

    r8242 r8280  
    3838  /* commands for the terminal interface */
    3939  SetConsoleCommand( "ms-listservers", &MasterServer::listServers );
    40   //SetConsoleCommand( "ms-delserver", &MasterServer::delServer );
     40  SetConsoleCommand( "ms-delserver", &MasterServer::delServer );
    4141  //SetConsoleCommand( "ms-serverinfo", &MasterServer::serverInfo );
    4242
     
    6767    COUT(0) << MasterServer::getInstance()->mainlist.serverlist.size() <<
    6868      " servers connected." << std::endl;
     69  }
     70
     71  void
     72  MasterServer::delServer( std::string todeladdr )
     73  {
     74    /* tell the user we're now removing the entry from the server list */
     75    COUT(0) << "MS: Deleting server \"" << todeladdr << "\"..."
     76      << std::endl;
     77
     78    /* see if we actually have that server on our list */
     79    ServerListSearchResult shandle =
     80      MasterServer::getInstance()->mainlist.findServerByAddress(todeladdr);
     81
     82    if( !shandle.success )
     83    { COUT(0) << "MS: Server not found, not removing." << std::endl;
     84      return;
     85    }
     86
     87    /* force-disconnect the server */ 
     88    enet_peer_disconnect( shandle.result.peer, NULL );
     89
     90    /* actually remove the entry from the server list by address */
     91    MasterServer::getInstance()->mainlist.delServerByAddress( todeladdr);
     92
     93    /* tell the user about our success */
     94    COUT(0) << "MS: Server deletion successful." << std::endl;
    6995  }
    7096
     
    365391    }
    366392
    367     /***** INITIALIZE GAME SERVER AND PEER LISTS *****/
    368     this->peers = new PeerList();
    369 
    370393    /* set pointer to this instance */
    371394    MasterServer::setInstance( this );
Note: See TracChangeset for help on using the changeset viewer.