Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 26, 2015, 1:38:24 PM (10 years ago)
Author:
frovelli
Message:

Added serverlist ping display in LAN

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/multiplayerFS15/src/libraries/network/ServerList.cc

    r8937 r10334  
    3030
    3131namespace orxonox
    32 { 
     32{
    3333  ServerList::ServerList()
    3434  { /* create a new list */ }
     
    3939  }
    4040
    41   int 
     41  int
    4242  ServerList::addServer( packet::ServerInformation toadd,
    4343    ENetPeer *peer )
    44   { 
     44  {
    4545    ServerListElem toAdd;
    4646    toAdd.ServerInfo = toadd;
    4747    toAdd.peer = peer;
    4848
    49     this->serverlist.push_back( toAdd ); 
     49    this->serverlist.push_back( toAdd );
    5050    return 0;
    5151  }
    5252
    53   bool 
     53  bool
    5454  ServerList::delServerByName( std::string name )
    55   { 
     55  {
    5656    /* get an iterator */
    5757    std::list<ServerListElem>::iterator i;
    5858
    5959    /* loop through list elements */
    60     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
     60    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    6161      if( (*i).ServerInfo.getServerName() == name )
    6262      { /* found this name, remove and quit */
     
    6868
    6969  bool ServerList::delServerByAddress( std::string address )
    70   { 
     70  {
    7171    /* get an iterator */
    7272    std::list<ServerListElem>::iterator i;
    7373
    7474    /* loop through list elements */
    75     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
     75    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    7676      if( (*i).ServerInfo.getServerIP() == address )
    7777      { /* found this name, remove and quit */
     
    9090
    9191    /* loop through list elements */
    92     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
     92    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    9393      if( (*i).ServerInfo.getServerIP() == address )
    9494      { /* found the target, return it */
     
    110110    /* iterate, return when name found */
    111111    /* loop through list elements */
    112     for( i = serverlist.begin(); i != serverlist.end(); ++i ) 
     112    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    113113      if( (*i).ServerInfo.getServerName() == name )
    114       { 
     114      {
    115115        ServerListSearchResult res = { (*i), true };
    116116        return res;
     
    124124  /* SORTING */
    125125  /* sort by name */
    126   bool sub_compare_names( ServerListElem no1, 
     126  bool sub_compare_names( ServerListElem no1,
    127127    ServerListElem no2 )
    128128  { return no1.ServerInfo.getServerName() > no2.ServerInfo.getServerName(); }
    129129
    130130  void ServerList::sortByName()
    131   { 
    132     this->serverlist.sort( sub_compare_names ); 
     131  {
     132    this->serverlist.sort( sub_compare_names );
    133133  }
    134  
     134
    135135  /* sort by ping */
    136   bool sub_compare_pings( ServerListElem no1, 
     136  bool sub_compare_pings( ServerListElem no1,
    137137    ServerListElem no2 )
    138   { 
    139     return no1.ServerInfo.getServerName() > no2.ServerInfo.getServerName();
     138  {
     139    return no1.ServerInfo.getServerRTT() > no2.ServerInfo.getServerRTT();
    140140  }
    141141
    142142  void ServerList::sortByPing()
    143143  {
    144     this->serverlist.sort( sub_compare_pings ); 
     144    this->serverlist.sort( sub_compare_pings );
    145145  }
    146146
Note: See TracChangeset for help on using the changeset viewer.