Changeset 8280 for code/branches/masterserver2/src/libraries
- Timestamp:
- Apr 21, 2011, 4:01:44 PM (14 years ago)
- Location:
- code/branches/masterserver2/src/libraries/network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/masterserver2/src/libraries/network/MasterServer.cc
r8242 r8280 38 38 /* commands for the terminal interface */ 39 39 SetConsoleCommand( "ms-listservers", &MasterServer::listServers ); 40 //SetConsoleCommand( "ms-delserver", &MasterServer::delServer );40 SetConsoleCommand( "ms-delserver", &MasterServer::delServer ); 41 41 //SetConsoleCommand( "ms-serverinfo", &MasterServer::serverInfo ); 42 42 … … 67 67 COUT(0) << MasterServer::getInstance()->mainlist.serverlist.size() << 68 68 " 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; 69 95 } 70 96 … … 365 391 } 366 392 367 /***** INITIALIZE GAME SERVER AND PEER LISTS *****/368 this->peers = new PeerList();369 370 393 /* set pointer to this instance */ 371 394 MasterServer::setInstance( this ); -
code/branches/masterserver2/src/libraries/network/MasterServer.h
r8241 r8280 70 70 /* functions for commands */ 71 71 static void listServers( void ); 72 static void delServer( std::string todeladdr ); 72 73 73 74 private: … … 85 86 ENetHost *server; 86 87 ServerList mainlist; 87 PeerList *peers;88 88 89 89 unsigned int port; -
code/branches/masterserver2/src/libraries/network/MasterServerComm.cc
r7801 r8280 168 168 case ENET_EVENT_TYPE_CONNECT: break; 169 169 170 /* disconnect */ 171 case ENET_EVENT_TYPE_DISCONNECT: /* ?? */ break; 170 /* disconnection event - probably kick from masterserver or crash. */ 171 case ENET_EVENT_TYPE_DISCONNECT: 172 COUT(0) << "ERROR: Master server connection was dropped." << std::endl; 173 break; 172 174 173 175 /* incoming data */ -
code/branches/masterserver2/src/libraries/network/ServerList.cc
r8203 r8280 82 82 } 83 83 84 /* SEARCHING */ 85 ServerListSearchResult 86 ServerList::findServerByAddress( std::string address ) 87 { 88 /* get an iterator */ 89 std::list<ServerListElem>::iterator i; 84 90 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 */ 85 125 /* sort by name */ 86 126 bool sub_compare_names( ServerListElem no1, -
code/branches/masterserver2/src/libraries/network/ServerList.h
r8202 r8280 37 37 namespace orxonox 38 38 { 39 /* HELPER STRUCTURES */ 39 40 struct ServerListElem 40 41 { … … 45 46 ENetPeer* peer; 46 47 }; 48 49 struct ServerListSearchResult 50 { 51 /* list element found */ 52 ServerListElem result; 53 54 /* successful search */ 55 bool success; 56 }; 57 58 59 60 47 61 48 62 /** This class is keeps a list of game servers … … 79 93 80 94 81 /* SORTING (to be implemented) */82 95 96 97 /* SEARCHING */ 98 /* \param address The address of the server that is to be 99 * found 100 * \return A struct containing a result of the search and a boolean 101 * that is only true if the search was successful 102 * 103 * Find and return the list handle of a given address. 104 */ 105 ServerListSearchResult 106 findServerByAddress( std::string address ); 107 108 109 /* \param name The name of the server that is to be 110 * found 111 * \return The struct containing the list entry of the server 112 * 113 * Find and return the list handle of a given name. 114 */ 115 ServerListSearchResult 116 findServerByName( std::string name ); 117 118 119 /* SORTING */ 83 120 /** sort by name */ 84 121 void sortByName();
Note: See TracChangeset
for help on using the changeset viewer.