Changeset 7657 for code/branches/masterserver/src/modules
- Timestamp:
- Nov 24, 2010, 2:07:53 PM (14 years ago)
- Location:
- code/branches/masterserver/src/modules/masterserver
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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 };
Note: See TracChangeset
for help on using the changeset viewer.