Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 16, 2011, 2:55:40 PM (12 years ago)
Author:
smerkli
Message:

merged masterserverfix corretly now.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/ServerList.cc

    r8351 r8937  
    4040
    4141  int
    42   ServerList::addServer( packet::ServerInformation toadd )
    43   { this->serverlist.push_back( toadd );
     42  ServerList::addServer( packet::ServerInformation toadd,
     43    ENetPeer *peer )
     44  {
     45    ServerListElem toAdd;
     46    toAdd.ServerInfo = toadd;
     47    toAdd.peer = peer;
     48
     49    this->serverlist.push_back( toAdd );
    4450    return 0;
    4551  }
     
    4955  {
    5056    /* get an iterator */
    51     std::list<packet::ServerInformation>::iterator i;
     57    std::list<ServerListElem>::iterator i;
    5258
    5359    /* loop through list elements */
    5460    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    55       if( (*i).getServerName() == name )
     61      if( (*i).ServerInfo.getServerName() == name )
    5662      { /* found this name, remove and quit */
    5763        this->serverlist.erase( i );
     
    6470  {
    6571    /* get an iterator */
    66     std::list<packet::ServerInformation>::iterator i;
     72    std::list<ServerListElem>::iterator i;
    6773
    6874    /* loop through list elements */
    69     for( i=serverlist.begin(); i != serverlist.end(); ++i )
    70       if( (*i).getServerIP() == address )
     75    for( i = serverlist.begin(); i != serverlist.end(); ++i )
     76      if( (*i).ServerInfo.getServerIP() == address )
    7177      { /* found this name, remove and quit */
    7278        this->serverlist.erase( i );
     
    7682  }
    7783
     84  /* SEARCHING */
     85  ServerListSearchResult
     86  ServerList::findServerByAddress( std::string address )
     87  {
     88    /* get an iterator */
     89    std::list<ServerListElem>::iterator i;
    7890
     91    /* loop through list elements */
     92    for( i = serverlist.begin(); i != serverlist.end(); ++i )
     93      if( (*i).ServerInfo.getServerIP() == address )
     94      { /* found the target, return it */
     95        ServerListSearchResult res = { (*i), true };
     96        return res;
     97      }
     98
     99    /* no success */
     100    ServerListSearchResult res = { (*i), false };
     101    return res;
     102  }
     103
     104  ServerListSearchResult
     105  ServerList::findServerByName( std::string name )
     106  {
     107    /* get an iterator */
     108    std::list<ServerListElem>::iterator i;
     109
     110    /* iterate, return when name found */
     111    /* loop through list elements */
     112    for( i = serverlist.begin(); i != serverlist.end(); ++i )
     113      if( (*i).ServerInfo.getServerName() == name )
     114      {
     115        ServerListSearchResult res = { (*i), true };
     116        return res;
     117      }
     118
     119    /* no luck, return a struct that tells the caller so */
     120    ServerListSearchResult res = { (*i), false };
     121    return res;
     122  }
     123
     124  /* SORTING */
    79125  /* sort by name */
    80   bool sub_compare_names( packet::ServerInformation no1,
    81     packet::ServerInformation no2 )
    82   { return no1.getServerName() > no2.getServerName(); }
     126  bool sub_compare_names( ServerListElem no1,
     127    ServerListElem no2 )
     128  { return no1.ServerInfo.getServerName() > no2.ServerInfo.getServerName(); }
    83129
    84130  void ServerList::sortByName()
     
    88134 
    89135  /* sort by ping */
    90   bool sub_compare_pings( packet::ServerInformation no1,
    91     packet::ServerInformation no2 )
     136  bool sub_compare_pings( ServerListElem no1,
     137    ServerListElem no2 )
    92138  {
    93     /* TODO */
    94     return no1.getServerName() > no2.getServerName();
     139    return no1.ServerInfo.getServerName() > no2.ServerInfo.getServerName();
    95140  }
    96141
Note: See TracChangeset for help on using the changeset viewer.