Changeset 10447 for code/branches/multiplayerFS15
- Timestamp:
- May 21, 2015, 2:39:05 PM (10 years ago)
- Location:
- code/branches/multiplayerFS15/src/libraries/network
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/multiplayerFS15/src/libraries/network/LANDiscoverable.cc
r10434 r10447 60 60 * has changed. 61 61 */ 62 SetConfigValueExternal(ownName, "Discovery", "ownName", " tme213");62 SetConfigValueExternal(ownName, "Discovery", "ownName", "OrxServer"); 63 63 } 64 64 -
code/branches/multiplayerFS15/src/libraries/network/MasterServer.cc
r10434 r10447 44 44 /* forward declaration so the linker doesn't complain */ 45 45 MasterServer *MasterServer::instance = NULL; 46 47 48 49 46 50 47 /* command: list servers */ … … 266 263 char *addrconv = (char *) calloc( 50, 1 ); 267 264 enet_address_get_host_ip( &(event->peer->address), addrconv, 49 ); 265 /* convert to string */ 266 std::string ip = std::string( addrconv ); 267 /* delete addrconv */ 268 if( addrconv ) free( addrconv ); 269 270 /* pointer to full packet data */ 271 char * packetdata = (char *)event->packet->data; 268 272 269 273 /* output debug info about the data that has come */ … … 271 275 272 276 /* GAME SERVER OR CLIENT CONNECTION? */ 273 if( !strncmp( (char *)event->packet->data, MSPROTO_GAME_SERVER, 274 MSPROTO_GAME_SERVER_LEN ) ) 277 if( !strncmp(packetdata, MSPROTO_GAME_SERVER, MSPROTO_GAME_SERVER_LEN ) ) 275 278 { /* Game server */ 276 279 277 if( !strncmp( (char *)event->packet->data 278 + MSPROTO_GAME_SERVER_LEN+1, 279 MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) ) 280 if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) ) 280 281 { /* register new server */ 281 mainlist.addServer( packet::ServerInformation( event ), 282 event->peer ); 282 mainlist.addServer( packet::ServerInformation( event ), event->peer ); 283 283 284 284 /* tell people we did so */ … … 287 287 } 288 288 289 else if( !strncmp( (char *)event->packet->data 290 + MSPROTO_GAME_SERVER_LEN+1, 291 MSPROTO_SERVERDC, MSPROTO_SERVERDC_LEN ) ) 292 { 293 /* create string from peer data */ 294 std::string ip = std::string( addrconv ); 289 else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SERVERDC, MSPROTO_SERVERDC_LEN ) ) 290 { /* disconnect server */ 295 291 296 292 /* remove the server from the list it belongs to */ … … 302 298 /* TODO add hook for disconnect here */ 303 299 304 else if( !strncmp( (char *)event->packet->data 305 + MSPROTO_GAME_SERVER_LEN+1, 306 MSPROTO_SET_NAME, MSPROTO_SET_NAME_LEN ) ) 307 { 300 else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SET_NAME, MSPROTO_SET_NAME_LEN ) ) 301 { /* save server name */ 308 302 /* create string from peer data */ 309 std::string ip = std::string( addrconv );310 303 std::string data (event->packet->data,event->packet->data + event->packet->dataLength ); 311 304 std::string name = data.substr(MSPROTO_GAME_SERVER_LEN+1 + MSPROTO_SET_NAME_LEN + 1); … … 318 311 } 319 312 320 else if( !strncmp( (char *)event->packet->data 321 + MSPROTO_GAME_SERVER_LEN+1, 322 MSPROTO_SET_CLIENTS, MSPROTO_SET_CLIENTS_LEN ) ) 323 { 313 else if( !strncmp( packetdata + MSPROTO_GAME_SERVER_LEN+1, MSPROTO_SET_CLIENTS, MSPROTO_SET_CLIENTS_LEN ) ) 314 { /* save client count from server */ 324 315 /* create string from peer data */ 325 std::string ip = std::string( addrconv );326 316 std::string data (event->packet->data,event->packet->data + event->packet->dataLength ); 327 317 std::string textform= data.substr(MSPROTO_GAME_SERVER_LEN + 1 + MSPROTO_SET_CLIENTS_LEN + 1); … … 334 324 } 335 325 } 336 else if( !strncmp( (char *)event->packet->data, MSPROTO_CLIENT, 337 MSPROTO_CLIENT_LEN) ) 326 else if( !strncmp( packetdata, MSPROTO_CLIENT, MSPROTO_CLIENT_LEN) ) 338 327 { /* client */ 339 if( !strncmp( (char *)event->packet->data + MSPROTO_CLIENT_LEN+1, 340 MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) ) 328 if( !strncmp( packetdata + MSPROTO_CLIENT_LEN+1, MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) ) 341 329 /* send server list */ 342 330 helper_sendlist( event ); … … 344 332 else 345 333 { /* bad message, don't do anything. */ } 346 347 /* delete addrconv */348 if( addrconv ) free( addrconv );349 334 350 335 /* Clean up the packet now that we're done using it. */ -
code/branches/multiplayerFS15/src/libraries/network/MasterServerProtocol.h
r10427 r10447 44 44 45 45 46 47 48 46 /*** GAME SERVER COMMUNICATIONS ***/ 49 47 /* Game server token (shows that the party sending data is a game server) */ … … 77 75 #define MSPROTO_ACK_LEN 3 78 76 77 /* server name */ 79 78 #define MSPROTO_SET_NAME "NAM" 80 79 #define MSPROTO_SET_NAME_LEN 3 81 80 81 /* server number of clients */ 82 82 #define MSPROTO_SET_CLIENTS "CLI" 83 83 #define MSPROTO_SET_CLIENTS_LEN 3 -
code/branches/multiplayerFS15/src/libraries/network/WANDiscoverable.cc
r10434 r10447 59 59 */ 60 60 SetConfigValueExternal(msaddress, "Discovery", "msaddress", "orxonox.net"); 61 SetConfigValueExternal(ownName, "Discovery", "ownName", "tme213"); 62 // SetConfigValue( msaddress, "orxonox.net"); 61 SetConfigValueExternal(ownName, "Discovery", "ownName", "OrxServer"); 63 62 } 64 63 … … 126 125 orxout(verbose, context::master_server) << "Sending new number of clients: " << clientNumber << endl; 127 126 std::string request = MSPROTO_GAME_SERVER " " MSPROTO_SET_CLIENTS " "; 128 std::stringstream ss; 129 ss << clientNumber; 130 request += ss.str(); 127 request += Ogre::StringConverter::toString(clientNumber); 131 128 132 129 this->msc.sendRequest( request ); -
code/branches/multiplayerFS15/src/libraries/network/WANDiscoverable.h
r10434 r10447 32 32 #include "core/config/Configurable.h" 33 33 #include "MasterServerComm.h" 34 #include <OgreStringConverter.h> 34 35 35 36 namespace orxonox
Note: See TracChangeset
for help on using the changeset viewer.