- Timestamp:
- Mar 26, 2015, 1:38:24 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/multiplayerFS15/src/libraries/network/ServerList.cc
r8937 r10334 30 30 31 31 namespace orxonox 32 { 32 { 33 33 ServerList::ServerList() 34 34 { /* create a new list */ } … … 39 39 } 40 40 41 int 41 int 42 42 ServerList::addServer( packet::ServerInformation toadd, 43 43 ENetPeer *peer ) 44 { 44 { 45 45 ServerListElem toAdd; 46 46 toAdd.ServerInfo = toadd; 47 47 toAdd.peer = peer; 48 48 49 this->serverlist.push_back( toAdd ); 49 this->serverlist.push_back( toAdd ); 50 50 return 0; 51 51 } 52 52 53 bool 53 bool 54 54 ServerList::delServerByName( std::string name ) 55 { 55 { 56 56 /* get an iterator */ 57 57 std::list<ServerListElem>::iterator i; 58 58 59 59 /* loop through list elements */ 60 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 60 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 61 61 if( (*i).ServerInfo.getServerName() == name ) 62 62 { /* found this name, remove and quit */ … … 68 68 69 69 bool ServerList::delServerByAddress( std::string address ) 70 { 70 { 71 71 /* get an iterator */ 72 72 std::list<ServerListElem>::iterator i; 73 73 74 74 /* loop through list elements */ 75 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 75 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 76 76 if( (*i).ServerInfo.getServerIP() == address ) 77 77 { /* found this name, remove and quit */ … … 90 90 91 91 /* loop through list elements */ 92 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 92 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 93 93 if( (*i).ServerInfo.getServerIP() == address ) 94 94 { /* found the target, return it */ … … 110 110 /* iterate, return when name found */ 111 111 /* loop through list elements */ 112 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 112 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 113 113 if( (*i).ServerInfo.getServerName() == name ) 114 { 114 { 115 115 ServerListSearchResult res = { (*i), true }; 116 116 return res; … … 124 124 /* SORTING */ 125 125 /* sort by name */ 126 bool sub_compare_names( ServerListElem no1, 126 bool sub_compare_names( ServerListElem no1, 127 127 ServerListElem no2 ) 128 128 { return no1.ServerInfo.getServerName() > no2.ServerInfo.getServerName(); } 129 129 130 130 void ServerList::sortByName() 131 { 132 this->serverlist.sort( sub_compare_names ); 131 { 132 this->serverlist.sort( sub_compare_names ); 133 133 } 134 134 135 135 /* sort by ping */ 136 bool sub_compare_pings( ServerListElem no1, 136 bool sub_compare_pings( ServerListElem no1, 137 137 ServerListElem no2 ) 138 { 139 return no1.ServerInfo.getServer Name() > no2.ServerInfo.getServerName();138 { 139 return no1.ServerInfo.getServerRTT() > no2.ServerInfo.getServerRTT(); 140 140 } 141 141 142 142 void ServerList::sortByPing() 143 143 { 144 this->serverlist.sort( sub_compare_pings ); 144 this->serverlist.sort( sub_compare_pings ); 145 145 } 146 146
Note: See TracChangeset
for help on using the changeset viewer.