Changeset 10334 for code/branches/multiplayerFS15/src/libraries
- Timestamp:
- Mar 26, 2015, 1:38:24 PM (10 years ago)
- Location:
- code/branches/multiplayerFS15/src/libraries/network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/multiplayerFS15/src/libraries/network/LANDiscovery.cc
r8858 r10334 124 124 } 125 125 126 std::string LANDiscovery::getServerListItemRTT(unsigned int index) 127 { 128 if( index >= this->servers_.size() ) 129 return BLANKSTRING; 130 else{ 131 uint32_t serverrtt = this->servers_[index].getServerRTT(); 132 return Ogre::StringConverter::toString(serverrtt); 133 } 134 135 } 136 126 137 127 138 } // namespace orxonox -
code/branches/multiplayerFS15/src/libraries/network/LANDiscovery.h
r8858 r10334 33 33 #include "packet/ServerInformation.h" 34 34 #include "util/Singleton.h" 35 #include <OgreStringConverter.h> 35 36 36 37 #include <vector> … … 51 52 std::string getServerListItemName( unsigned int index ); // tolua_export 52 53 std::string getServerListItemIP( unsigned int index ); // tolua_export 54 std::string getServerListItemRTT( unsigned int index ); // tolua_export 53 55 static LANDiscovery& getInstance(){ return Singleton<LANDiscovery>::getInstance(); } // tolua_export 54 56 55 57 private: 56 58 static LANDiscovery* singletonPtr_s; -
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 -
code/branches/multiplayerFS15/src/libraries/network/packet/ServerInformation.cc
r8351 r10334 39 39 namespace packet 40 40 { 41 41 42 42 ServerInformation::ServerInformation() 43 43 { 44 44 45 45 } 46 46 47 47 ServerInformation::ServerInformation(ENetEvent* event) 48 48 { … … 69 69 ServerInformation::~ServerInformation() 70 70 { 71 71 72 72 } 73 73 … … 81 81 ENetPacket* packet = enet_packet_create( temp, size, 0 ); 82 82 enet_peer_send(peer, 0, packet); 83 83 84 84 delete[] temp; 85 85 } 86 86 87 87 } // namespace packet 88 88 … … 95 95 } 96 96 } // namespace orxonox 97 -
code/branches/multiplayerFS15/src/libraries/network/packet/ServerInformation.h
r8351 r10334 45 45 ServerInformation(ENetEvent* event); 46 46 ~ServerInformation(); 47 47 48 48 void send( ENetPeer* peer ); 49 49 std::string getServerIP() { return this->serverIP_; } … … 52 52 void setServerIP( std::string IP ) { this->serverIP_ = IP; } 53 53 uint32_t getServerRTT() { return this->serverRTT_; } 54 54 55 55 private: 56 56 std::string serverName_;
Note: See TracChangeset
for help on using the changeset viewer.