Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7657


Ignore:
Timestamp:
Nov 24, 2010, 2:07:53 PM (13 years ago)
Author:
smerkli
Message:

it has compiled.

Location:
code/branches/masterserver/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/masterserver/src/libraries/network/MasterServerProtocol.h

    r7650 r7657  
    3737
    3838#define MSPROTO_REQ_LIST "REQ:LIST"
     39#define MSPROTO_REQ_LIST_LEN 8
    3940
    4041
  • code/branches/masterserver/src/libraries/network/WANDiscovery.cc

    r7651 r7657  
    6262
    6363  /* callback for the network reply poller */
    64   /* WORK MARK WORK WORK */
    65   /* NOTE implement protocol-specific part here. */
    66   int WANDiscovery::rhandler( char *addr, ENetEvent *ev )
     64  int rhandler( char *addr, ENetEvent *ev )
    6765  {
     66    /* error recognition */
     67    if( !ev || !ev->packet || !ev->packet->data )
     68    { COUT(2) << "Bad arguments received in WANDiscovery's reply handler.\n";
     69      return 0;
     70    }
     71
    6872    /* handle incoming data */
    6973    /* if a list entry arrives add to list */
     
    8185
    8286      /* add to list */
    83       this->servers_.push_back( toadd );
     87      WANDiscovery::getInstance().servers_.push_back( toadd );
    8488    }
    8589    else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END,
     
    97101
    98102    /* send request to server */
    99     msc.sendRequest( MSPROTO_CLIENT " " MSPROTO_REQ_LIST );
     103    this->msc.sendRequest( MSPROTO_CLIENT " " MSPROTO_REQ_LIST );
    100104
    101105    /* deal with replies */
    102     while( !msc.pollForReply( WANDiscovery::rhandler ) )
     106    while( !(this->msc).pollForReply( rhandler ) )
    103107      /* nothing */;
    104108
  • code/branches/masterserver/src/libraries/network/WANDiscovery.h

    r7651 r7657  
    7878      static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export
    7979   
    80       int rhandler( char *addr, ENetEvent *ev );
     80      /** game server list */
     81      std::vector<packet::ServerInformation> servers_;
    8182     
    8283    private:
     
    8788      MasterServerComm msc;
    8889
    89       /** game server list */
    90       std::vector<packet::ServerInformation> servers_;
    91 
    9290  }; // tolua_export
    9391
  • code/branches/masterserver/src/modules/masterserver/MasterServer.cc

    r7651 r7657  
    8080
    8181    /* remove the server from the list it belongs to */
    82     this->mainlist->delServerByName( name );
     82    this->mainlist.delServerByName( name );
    8383
    8484    /* Reset the peer's client information. */
     
    141141        MSPROTO_REGISTER_SERVER, MSPROTO_REGISTER_SERVER_LEN ) )
    142142      { /* register new server */
    143         mainlist->addServer( packet::ServerInformation( event ) );
     143        mainlist.addServer( packet::ServerInformation( event ) );
    144144      }
    145145    }
     
    149149     
    150150      if( !strncmp( (char *)event->packet->data + MSPROTO_CLIENT_LEN+1,
    151         MSPROTO_REQ_LIST ) )
     151        MSPROTO_REQ_LIST, MSPROTO_REQ_LIST_LEN ) )
    152152      { /* send server list */
    153153       
    154154        /* get an iterator */
    155         std::list<packet::ServerInformation *>::iterator i;
     155        std::list<packet::ServerInformation>::iterator i;
    156156
    157157        /* loop through list elements */
    158         for( i = serverlist.begin(); i != serverlist.end(); ++i )
     158        for( i = mainlist.serverlist.begin(); i != mainlist.serverlist.end(); ++i )
    159159        {
    160160          /* WORK MARK */
    161161          /* send this particular server */
    162162          /* build reply string */
    163           char *tosend = (char *)calloc( (*i)->getServerIP().length() + 1,1 );
    164           snprintf( "%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() );
    165165
    166166          /* create packet from it */
     
    258258
    259259    /***** INITIALIZE GAME SERVER AND PEER LISTS *****/
    260     this->mainlist = new ServerList();
     260    //this->mainlist = new ServerList();
    261261    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    //}
    266266
    267267    /* run the main method */
  • code/branches/masterserver/src/modules/masterserver/MasterServer.h

    r7651 r7657  
    7373      ENetAddress address;
    7474      ENetHost *server;
    75       ServerList *mainlist;
     75      ServerList mainlist;
    7676      PeerList *peers;
    7777
  • code/branches/masterserver/src/modules/masterserver/ServerList.cc

    r7611 r7657  
    4040
    4141  int
    42   ServerList::addServer( packet::ServerInformation *toadd )
     42  ServerList::addServer( packet::ServerInformation toadd )
    4343  { this->serverlist.push_back( toadd );
    4444    return 0;
     
    4949  {
    5050    /* get an iterator */
    51     std::list<packet::ServerInformation *>::iterator i;
     51    std::list<packet::ServerInformation>::iterator i;
    5252
    5353    /* loop through list elements */
    5454    for( i = serverlist.begin(); i != serverlist.end(); ++i )
    55       if( (*i)->getServerName() == name )
     55      if( (*i).getServerName() == name )
    5656      { /* found this name, remove and quit */
    57         this->serverlist.remove( *i );
     57        this->serverlist.erase( i );
    5858        return true;
    5959      }
     
    6464  {
    6565    /* get an iterator */
    66     std::list<packet::ServerInformation *>::iterator i;
     66    std::list<packet::ServerInformation>::iterator i;
    6767
    6868    /* loop through list elements */
    6969    for( i=serverlist.begin(); i != serverlist.end(); ++i )
    70       if( (*i)->getServerIP() == address )
     70      if( (*i).getServerIP() == address )
    7171      { /* found this name, remove and quit */
    72         this->serverlist.remove( *i );
     72        this->serverlist.erase( i );
    7373        return true;
    7474      }
     
    7878
    7979  /* 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(); }
    8383
    8484  void ServerList::sortByName()
     
    8888 
    8989  /* 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 )
    9292  {
    9393    /* TODO */
    94     return no1->getServerName() > no2->getServerName();
     94    return no1.getServerName() > no2.getServerName();
    9595  }
    9696
  • code/branches/masterserver/src/modules/masterserver/ServerList.h

    r7651 r7657  
    5454       * Add server to the game server list
    5555       */
    56       int addServer( packet::ServerInformation *toadd );
     56      int addServer( packet::ServerInformation toadd );
    5757
    5858      /** \param name Name of the server to remove
     
    7878
    7979      /** the list of servers for internal storage */
    80       std::list<packet::ServerInformation *> serverlist;
     80      std::list<packet::ServerInformation> serverlist;
    8181    private:
    8282  };
  • code/branches/masterserver/src/orxonox/Main.cc

    r7431 r7657  
    9090            else if (CommandLineParser::getValue("dedicatedClient").getBool())
    9191                Game::getInstance().requestStates("client, level");
     92            //else if (CommandLineParser::getValue("masterserver").getBool())
     93                //Game::getInstance().requestStates("client, level");
    9294            else
    9395            {
Note: See TracChangeset for help on using the changeset viewer.