Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 24, 2010, 8:33:58 PM (14 years ago)
Author:
smerkli
Message:

Further implementation, constructing a testing environment soon.

Location:
code/branches/masterserver/src/modules/masterserver
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/masterserver/src/modules/masterserver/MasterServer.cpp

    r7569 r7580  
    4141
    4242  /* 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);
    4646
    4747  /* game server or client connection? */
     
    6969
    7070  /* 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);
    7272
    7373  /* remove the server from the list it belongs to */
     
    8787
    8888  /* 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 );
    9494 
    9595  /* game server or client connection? */
     
    155155
    156156  /***** ENTER MAIN LOOP *****/
    157   ENetEvent *event = calloc(sizeof(ENetEvent), sizeof(char));
     157  ENetEvent *event = (ENetEvent *)calloc(sizeof(ENetEvent), sizeof(char));
    158158  if( event == NULL )
    159159  { fprintf( stderr, "Could not create ENetEvent structure, exiting.\n" );
  • code/branches/masterserver/src/modules/masterserver/PeerList.cpp

    r7574 r7580  
    2828
    2929#include "PeerList.h"
     30#include <cstdio>
    3031
    3132namespace orxonox
     
    3637  int
    3738  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    }
    3944
    40 
     45    /* if all went well, push to back of list */
     46    this->peerlist.push_back( toadd );
    4147    return 0;
    4248  }
    4349
    44   int
     50  bool sub_compAddr( ENetAddress addr1, ENetAddress addr2 )
     51  { return ( (addr1.host == addr2.host) && (addr1.port == addr2.port) ); }
     52
     53  bool
    4554  PeerList::remPeerByAddr( ENetAddress addr )
    46   {
     55  { /* get an iterator */
     56    list<packet::ENetPeer *>::iterator i;
    4757
     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      }
    4865
    49 
    50     return 0;
     66    /* not found */
     67    return false;
    5168  }
    5269
    5370  ENetPeer *
    5471  PeerList::findPeerByAddr( ENetAddress addr )
    55   {
     72  { /* get an iterator */
     73    list<packet::ENetPeer *>::iterator i;
    5674
     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;
    5780
    58 
     81    /* not found */
    5982    return NULL;
    6083  }
  • code/branches/masterserver/src/modules/masterserver/PeerList.h

    r7574 r7580  
    4949
    5050      /** \param toadd The peer to add
     51       * \return 0 for success, -1 for error.
    5152       *
    5253       * Add new peer to list
     
    5556
    5657      /** \param addr Address to look for
     58       * \return if the peer was found or not
    5759       *
    5860       * Remove peer from list by address
    5961       */
    60       int remPeerByAddr( ENetAddress addr );
     62      bool remPeerByAddr( ENetAddress addr );
    6163
    6264      /** \param addr The address to find by
Note: See TracChangeset for help on using the changeset viewer.