Changeset 7657
- Timestamp:
- Nov 24, 2010, 2:07:53 PM (14 years ago)
- Location:
- code/branches/masterserver/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/masterserver/src/libraries/network/MasterServerProtocol.h
r7650 r7657 37 37 38 38 #define MSPROTO_REQ_LIST "REQ:LIST" 39 #define MSPROTO_REQ_LIST_LEN 8 39 40 40 41 -
code/branches/masterserver/src/libraries/network/WANDiscovery.cc
r7651 r7657 62 62 63 63 /* callback for the network reply poller */ 64 /* WORK MARK WORK WORK */ 65 /* NOTE implement protocol-specific part here. */ 66 int WANDiscovery::rhandler( char *addr, ENetEvent *ev ) 64 int rhandler( char *addr, ENetEvent *ev ) 67 65 { 66 /* error recognition */ 67 if( !ev || !ev->packet || !ev->packet->data ) 68 { COUT(2) << "Bad arguments received in WANDiscovery's reply handler.\n"; 69 return 0; 70 } 71 68 72 /* handle incoming data */ 69 73 /* if a list entry arrives add to list */ … … 81 85 82 86 /* add to list */ 83 this->servers_.push_back( toadd );87 WANDiscovery::getInstance().servers_.push_back( toadd ); 84 88 } 85 89 else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END, … … 97 101 98 102 /* send request to server */ 99 msc.sendRequest( MSPROTO_CLIENT " " MSPROTO_REQ_LIST );103 this->msc.sendRequest( MSPROTO_CLIENT " " MSPROTO_REQ_LIST ); 100 104 101 105 /* deal with replies */ 102 while( ! msc.pollForReply( WANDiscovery::rhandler ) )106 while( !(this->msc).pollForReply( rhandler ) ) 103 107 /* nothing */; 104 108 -
code/branches/masterserver/src/libraries/network/WANDiscovery.h
r7651 r7657 78 78 static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export 79 79 80 int rhandler( char *addr, ENetEvent *ev ); 80 /** game server list */ 81 std::vector<packet::ServerInformation> servers_; 81 82 82 83 private: … … 87 88 MasterServerComm msc; 88 89 89 /** game server list */90 std::vector<packet::ServerInformation> servers_;91 92 90 }; // tolua_export 93 91 -
code/branches/masterserver/src/modules/masterserver/MasterServer.cc
r7651 r7657 80 80 81 81 /* remove the server from the list it belongs to */ 82 this->mainlist ->delServerByName( name );82 this->mainlist.delServerByName( name ); 83 83 84 84 /* Reset the peer's client information. */ … … 141 141 MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) ) 142 142 { /* register new server */ 143 mainlist ->addServer( packet::ServerInformation( event ) );143 mainlist.addServer( packet::ServerInformation( event ) ); 144 144 } 145 145 } … … 149 149 150 150 if( !strncmp( (char *)event->packet->data + MSPROTO_CLIENT_LEN+1, 151 MSPROTO_REQ_LIST ) )151 MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) ) 152 152 { /* send server list */ 153 153 154 154 /* get an iterator */ 155 std::list<packet::ServerInformation *>::iterator i;155 std::list<packet::ServerInformation>::iterator i; 156 156 157 157 /* loop through list elements */ 158 for( i = serverlist.begin(); i !=serverlist.end(); ++i )158 for( i = mainlist.serverlist.begin(); i != mainlist.serverlist.end(); ++i ) 159 159 { 160 160 /* WORK MARK */ 161 161 /* send this particular server */ 162 162 /* build reply string */ 163 char *tosend = (char *)calloc( (*i) ->getServerIP().length() + 1,1 );164 s nprintf( "%s %s", MSPROTO_SERVERLIST_ITEM, (*i)->getServerIP() );163 char *tosend = (char *)calloc( (*i).getServerIP().length() + MSPROTO_SERVERLIST_ITEM_LEN + 2,1 ); 164 sprintf( "%s %s", MSPROTO_SERVERLIST_ITEM, (*i).getServerIP().c_str() ); 165 165 166 166 /* create packet from it */ … … 258 258 259 259 /***** INITIALIZE GAME SERVER AND PEER LISTS *****/ 260 this->mainlist = new ServerList();260 //this->mainlist = new ServerList(); 261 261 this->peers = new PeerList(); 262 if( this->mainlist == NULL || this->peers == NULL )263 { COUT(1) << "Error creating server or peer list.\n";264 exit( EXIT_FAILURE );265 }262 //if( this->mainlist == NULL || this->peers == NULL ) 263 //{ COUT(1) << "Error creating server or peer list.\n"; 264 //exit( EXIT_FAILURE ); 265 //} 266 266 267 267 /* run the main method */ -
code/branches/masterserver/src/modules/masterserver/MasterServer.h
r7651 r7657 73 73 ENetAddress address; 74 74 ENetHost *server; 75 ServerList *mainlist;75 ServerList mainlist; 76 76 PeerList *peers; 77 77 -
code/branches/masterserver/src/modules/masterserver/ServerList.cc
r7611 r7657 40 40 41 41 int 42 ServerList::addServer( packet::ServerInformation *toadd )42 ServerList::addServer( packet::ServerInformation toadd ) 43 43 { this->serverlist.push_back( toadd ); 44 44 return 0; … … 49 49 { 50 50 /* get an iterator */ 51 std::list<packet::ServerInformation *>::iterator i;51 std::list<packet::ServerInformation>::iterator i; 52 52 53 53 /* loop through list elements */ 54 54 for( i = serverlist.begin(); i != serverlist.end(); ++i ) 55 if( (*i) ->getServerName() == name )55 if( (*i).getServerName() == name ) 56 56 { /* found this name, remove and quit */ 57 this->serverlist. remove( *i );57 this->serverlist.erase( i ); 58 58 return true; 59 59 } … … 64 64 { 65 65 /* get an iterator */ 66 std::list<packet::ServerInformation *>::iterator i;66 std::list<packet::ServerInformation>::iterator i; 67 67 68 68 /* loop through list elements */ 69 69 for( i=serverlist.begin(); i != serverlist.end(); ++i ) 70 if( (*i) ->getServerIP() == address )70 if( (*i).getServerIP() == address ) 71 71 { /* found this name, remove and quit */ 72 this->serverlist. remove( *i );72 this->serverlist.erase( i ); 73 73 return true; 74 74 } … … 78 78 79 79 /* sort by name */ 80 bool sub_compare_names( packet::ServerInformation *no1,81 packet::ServerInformation *no2 )82 { return no1 ->getServerName() > no2->getServerName(); }80 bool sub_compare_names( packet::ServerInformation no1, 81 packet::ServerInformation no2 ) 82 { return no1.getServerName() > no2.getServerName(); } 83 83 84 84 void ServerList::sortByName() … … 88 88 89 89 /* sort by ping */ 90 bool sub_compare_pings( packet::ServerInformation *no1,91 packet::ServerInformation *no2 )90 bool sub_compare_pings( packet::ServerInformation no1, 91 packet::ServerInformation no2 ) 92 92 { 93 93 /* TODO */ 94 return no1 ->getServerName() > no2->getServerName();94 return no1.getServerName() > no2.getServerName(); 95 95 } 96 96 -
code/branches/masterserver/src/modules/masterserver/ServerList.h
r7651 r7657 54 54 * Add server to the game server list 55 55 */ 56 int addServer( packet::ServerInformation *toadd );56 int addServer( packet::ServerInformation toadd ); 57 57 58 58 /** \param name Name of the server to remove … … 78 78 79 79 /** the list of servers for internal storage */ 80 std::list<packet::ServerInformation *> serverlist;80 std::list<packet::ServerInformation> serverlist; 81 81 private: 82 82 }; -
code/branches/masterserver/src/orxonox/Main.cc
r7431 r7657 90 90 else if (CommandLineParser::getValue("dedicatedClient").getBool()) 91 91 Game::getInstance().requestStates("client, level"); 92 //else if (CommandLineParser::getValue("masterserver").getBool()) 93 //Game::getInstance().requestStates("client, level"); 92 94 else 93 95 {
Note: See TracChangeset
for help on using the changeset viewer.