Changeset 7580
- Timestamp:
- Oct 24, 2010, 8:33:58 PM (14 years ago)
- Location:
- code/branches/masterserver/src/modules/masterserver
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/masterserver/src/modules/masterserver/MasterServer.cpp
r7569 r7580 41 41 42 42 /* output debug info */ 43 printf( "A new client connected from %x:%u.\n",44 event->peer->address.host,45 event->peer->address.port);43 //printf( "A new client connected from %x:%u.\n", 44 //event->peer->address.host, 45 //event->peer->address.port); 46 46 47 47 /* game server or client connection? */ … … 69 69 70 70 /* output that the disconnect happened, to be removed at a later time. */ 71 printf ("%s disconnected.\n", event.peer -> data);71 //printf ("%s disconnected.\n", event->peer -> data); 72 72 73 73 /* remove the server from the list it belongs to */ … … 87 87 88 88 /* output debug info about the data that has come, to be removed */ 89 printf( "A packet of length %u containing %s was received from %s on channel %u.\n",90 event->packet->dataLength,91 event->packet->data,92 event->peer->data,93 event->channelID );89 //printf( "A packet of length %u containing %s was received from %s on channel %u.\n", 90 //event->packet->dataLength, 91 //event->packet->data, 92 //event->peer->data, 93 //event->channelID ); 94 94 95 95 /* game server or client connection? */ … … 155 155 156 156 /***** ENTER MAIN LOOP *****/ 157 ENetEvent *event = calloc(sizeof(ENetEvent), sizeof(char));157 ENetEvent *event = (ENetEvent *)calloc(sizeof(ENetEvent), sizeof(char)); 158 158 if( event == NULL ) 159 159 { fprintf( stderr, "Could not create ENetEvent structure, exiting.\n" ); -
code/branches/masterserver/src/modules/masterserver/PeerList.cpp
r7574 r7580 28 28 29 29 #include "PeerList.h" 30 #include <cstdio> 30 31 31 32 namespace orxonox … … 36 37 int 37 38 PeerList::addPeer( ENetPeer *toadd ) 38 { 39 { /* error correction */ 40 if( toadd == NULL ) 41 { fprintf( stderr, "PeerList::addPeer: empty peer given.\n" ); 42 return -1; 43 } 39 44 40 45 /* if all went well, push to back of list */ 46 this->peerlist.push_back( toadd ); 41 47 return 0; 42 48 } 43 49 44 int 50 bool sub_compAddr( ENetAddress addr1, ENetAddress addr2 ) 51 { return ( (addr1.host == addr2.host) && (addr1.port == addr2.port) ); } 52 53 bool 45 54 PeerList::remPeerByAddr( ENetAddress addr ) 46 { 55 { /* get an iterator */ 56 list<packet::ENetPeer *>::iterator i; 47 57 58 /* loop through list elements */ 59 for( i = peerlist.begin(); i != peerlist.end(); ++i ) 60 if( sub_compAddr((*i)->address, addr ) ) 61 { /* found this name, remove and quit */ 62 this->peerlist.remove( i ); 63 return true; 64 } 48 65 49 50 return 0;66 /* not found */ 67 return false; 51 68 } 52 69 53 70 ENetPeer * 54 71 PeerList::findPeerByAddr( ENetAddress addr ) 55 { 72 { /* get an iterator */ 73 list<packet::ENetPeer *>::iterator i; 56 74 75 /* loop through list elements */ 76 for( i = peerlist.begin(); i != peerlist.end(); ++i ) 77 if( sub_compAddr((*i)->address, addr ) ) 78 /* found this name, remove and quit */ 79 return i; 57 80 58 81 /* not found */ 59 82 return NULL; 60 83 } -
code/branches/masterserver/src/modules/masterserver/PeerList.h
r7574 r7580 49 49 50 50 /** \param toadd The peer to add 51 * \return 0 for success, -1 for error. 51 52 * 52 53 * Add new peer to list … … 55 56 56 57 /** \param addr Address to look for 58 * \return if the peer was found or not 57 59 * 58 60 * Remove peer from list by address 59 61 */ 60 intremPeerByAddr( ENetAddress addr );62 bool remPeerByAddr( ENetAddress addr ); 61 63 62 64 /** \param addr The address to find by
Note: See TracChangeset
for help on using the changeset viewer.