Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2015, 2:39:05 PM (10 years ago)
Author:
frovelli
Message:

cleanup

Location:
code/branches/multiplayerFS15/src/libraries/network
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/multiplayerFS15/src/libraries/network/LANDiscoverable.cc

    r10434 r10447  
    6060     * has changed.
    6161     */
    62     SetConfigValueExternal(ownName, "Discovery", "ownName", "tme213");
     62    SetConfigValueExternal(ownName, "Discovery", "ownName", "OrxServer");
    6363  }
    6464
  • code/branches/multiplayerFS15/src/libraries/network/MasterServer.cc

    r10434 r10447  
    4444  /* forward declaration so the linker doesn't complain */
    4545  MasterServer *MasterServer::instance = NULL;
    46 
    47 
    48 
    4946
    5047  /* command: list servers */
     
    266263    char *addrconv = (char *) calloc( 50, 1 );
    267264    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;
    268272
    269273    /* output debug info about the data that has come */
     
    271275
    272276    /* 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 ) )
    275278    { /* Game server */
    276279
    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 ) )
    280281      { /* register new server */
    281         mainlist.addServer( packet::ServerInformation( event ),
    282           event->peer );
     282        mainlist.addServer( packet::ServerInformation( event ), event->peer );
    283283
    284284        /* tell people we did so */
     
    287287      }
    288288
    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 */
    295291
    296292        /* remove the server from the list it belongs to */
     
    302298      /* TODO add hook for disconnect here */
    303299
    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 */
    308302        /* create string from peer data */
    309         std::string ip = std::string( addrconv );
    310303        std::string data (event->packet->data,event->packet->data + event->packet->dataLength );
    311304        std::string name = data.substr(MSPROTO_GAME_SERVER_LEN+1 + MSPROTO_SET_NAME_LEN + 1);
     
    318311      }
    319312
    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 */
    324315        /* create string from peer data */
    325         std::string ip = std::string( addrconv );
    326316        std::string data (event->packet->data,event->packet->data + event->packet->dataLength );
    327317        std::string textform= data.substr(MSPROTO_GAME_SERVER_LEN + 1 + MSPROTO_SET_CLIENTS_LEN + 1);
     
    334324      }
    335325    }
    336     else if( !strncmp( (char *)event->packet->data, MSPROTO_CLIENT,
    337       MSPROTO_CLIENT_LEN) )
     326    else if( !strncmp( packetdata, MSPROTO_CLIENT, MSPROTO_CLIENT_LEN) )
    338327    { /* 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 ) )
    341329        /* send server list */
    342330        helper_sendlist( event );
     
    344332    else
    345333    { /* bad message, don't do anything. */ }
    346 
    347     /* delete addrconv */
    348     if( addrconv ) free( addrconv );
    349334
    350335    /* Clean up the packet now that we're done using it. */
  • code/branches/multiplayerFS15/src/libraries/network/MasterServerProtocol.h

    r10427 r10447  
    4444
    4545
    46 
    47 
    4846/*** GAME SERVER COMMUNICATIONS ***/
    4947/* Game server token (shows that the party sending data is a game server) */
     
    7775#define MSPROTO_ACK_LEN 3
    7876
     77/* server name */
    7978#define MSPROTO_SET_NAME "NAM"
    8079#define MSPROTO_SET_NAME_LEN 3
    8180
     81/* server number of clients */
    8282#define MSPROTO_SET_CLIENTS "CLI"
    8383#define MSPROTO_SET_CLIENTS_LEN 3
  • code/branches/multiplayerFS15/src/libraries/network/WANDiscoverable.cc

    r10434 r10447  
    5959     */
    6060    SetConfigValueExternal(msaddress, "Discovery", "msaddress", "orxonox.net");
    61     SetConfigValueExternal(ownName, "Discovery", "ownName", "tme213");
    62 //     SetConfigValue( msaddress, "orxonox.net");
     61    SetConfigValueExternal(ownName, "Discovery", "ownName", "OrxServer");
    6362  }
    6463
     
    126125    orxout(verbose, context::master_server) << "Sending new number of clients: " << clientNumber << endl;
    127126    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);
    131128
    132129    this->msc.sendRequest( request );
  • code/branches/multiplayerFS15/src/libraries/network/WANDiscoverable.h

    r10434 r10447  
    3232#include "core/config/Configurable.h"
    3333#include "MasterServerComm.h"
     34#include <OgreStringConverter.h>
    3435
    3536namespace orxonox
Note: See TracChangeset for help on using the changeset viewer.