Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9285 in orxonox.OLD


Ignore:
Timestamp:
Jul 14, 2006, 10:46:13 AM (18 years ago)
Author:
patrick
Message:

another standardisation: less different types with the same content

Location:
branches/proxy/src/lib/network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/monitor/network_monitor.cc

    r9284 r9285  
    157157}
    158158
     159
     160void NetworkMonitor::debug()
     161{
     162  PRINTF(0)("================================= Network Monitor ========\n");
     163  PRINTF(0)(" Total count of network nodes: %i\n", this->playerNumber);
     164
     165}
     166
  • branches/proxy/src/lib/network/monitor/network_monitor.h

    r9282 r9285  
    5656
    5757    void process();
     58    void debug();
    5859
    5960
  • branches/proxy/src/lib/network/network_stream.cc

    r9284 r9285  
    6464  this->init();
    6565  /* initialize the references */
    66   this->nodeType = NET_CLIENT;
     66  this->pInfo->nodeType = NET_CLIENT;
    6767}
    6868
     
    7575NetworkStream::NetworkStream( std::string host, int port )
    7676{
    77   this->nodeType = NET_CLIENT;
    7877  this->init();
     78  // init the peers[0] the server to ceonnect to
    7979  this->peers[0].socket = new UdpSocket( host, port );
    8080  this->peers[0].userId = 0;
    8181  this->peers[0].nodeType = NET_MASTER_SERVER;
    8282  this->peers[0].connectionMonitor = new ConnectionMonitor( 0 );
     83  // and set also the localhost
     84  this->pInfo->nodeType = NET_CLIENT;
    8385}
    8486
     
    9092NetworkStream::NetworkStream( int port )
    9193{
    92   this->nodeType = NET_MASTER_SERVER;
    9394  this->init();
    9495  this->serverSocket = new UdpServerSocket(port);
     96  this->pInfo->nodeType = NET_MASTER_SERVER;
    9597}
    9698
     
    108110
    109111  this->pInfo = new PeerInfo();
    110   this->pInfo->nodeType = NET_CLIENT;
    111112  this->pInfo->userId = 0;
    112113  this->pInfo->lastAckedState = 0;
    113114  this->pInfo->lastRecvedState = 0;
    114115
    115   this->myHostId = 0;
     116
    116117  this->currentState = 0;
    117118
     
    184185void NetworkStream::startHandshake()
    185186{
    186   Handshake* hs = new Handshake(this->nodeType);
     187  Handshake* hs = new Handshake(this->pInfo->nodeType);
    187188  hs->setUniqueID( 0 );
    188189  assert( peers[0].handshake == NULL );
     
    245246  }
    246247
    247   if ( this->nodeType == NET_MASTER_SERVER )
     248  if ( this->pInfo->nodeType == NET_MASTER_SERVER )
    248249  {
    249250    // execute everytthing the master server shoudl do
     
    253254    this->updateConnectionList();
    254255  }
    255   else if( this->nodeType == NET_PROXY_SERVER)
     256  else if( this->pInfo->nodeType == NET_PROXY_SERVER)
    256257  {
    257258    // execute everything the proxy server should do
     
    311312      freeSocketSlots.pop_back();
    312313      peers[clientId].socket = tempNetworkSocket;
    313       peers[clientId].handshake = new Handshake(this->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID() );
     314      peers[clientId].handshake = new Handshake(this->pInfo->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID() );
    314315      peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
    315316      peers[clientId].handshake->setUniqueID(clientId);
     
    326327
    327328      peers[clientId].socket = tempNetworkSocket;
    328       peers[clientId].handshake = new Handshake(this->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
     329      peers[clientId].handshake = new Handshake(this->pInfo->nodeType, clientId, this->networkGameManager->getUniqueID(), MessageManager::getInstance()->getUniqueID());
    329330      peers[clientId].handshake->setUniqueID(clientId);
    330331      peers[clientId].connectionMonitor = new ConnectionMonitor( clientId );
     
    408409{
    409410  if( this->isMasterServer())
    410     PRINT(0)(" Host ist Server with ID: %i\n", this->myHostId);
     411    PRINT(0)(" Host ist Server with ID: %i\n", this->pInfo->userId);
    411412  else
    412     PRINT(0)(" Host ist Client with ID: %i\n", this->myHostId);
     413    PRINT(0)(" Host ist Client with ID: %i\n", this->pInfo->userId);
    413414
    414415  PRINT(0)(" Got %i connected Synchronizeables, showing active Syncs:\n", this->synchronizeables.size());
     
    456457          if ( !it->second.handshake->allowDel() )
    457458          {
    458             if ( this->nodeType == NET_CLIENT )
     459            if ( this->pInfo->nodeType == NET_CLIENT )
    459460            {
    460461              SharedNetworkData::getInstance()->setHostID( it->second.handshake->getHostId() );
    461               myHostId = SharedNetworkData::getInstance()->getHostID();
    462 
    463 //               PRINTF(0)("remote host is a %i\n", it->second.handshake->getRemoteNodeType());
     462              this->pInfo->userId = SharedNetworkData::getInstance()->getHostID();
     463
    464464              it->second.nodeType = it->second.handshake->getRemoteNodeType();
    465465              this->networkMonitor->addNode(&it->second);
     
    480480            if ( it->second.handshake->canDel() )
    481481            {
    482               if ( this->nodeType == NET_MASTER_SERVER )
     482              if ( this->pInfo->nodeType == NET_MASTER_SERVER )
    483483              {
    484484                it->second.nodeType = it->second.handshake->getRemoteNodeType();
  • branches/proxy/src/lib/network/network_stream.h

    r9284 r9285  
    4848
    4949    /* functions for the localhost settings */
    50     inline bool isMasterServer() const { return (this->nodeType == NET_MASTER_SERVER)? true:false; }
    51     inline bool isProxyServer() const { return (this->nodeType == NET_PROXY_SERVER)? true:false; }
    52     inline bool isClient() const { return (this->nodeType == NET_CLIENT)? true:false; }
     50    inline bool isMasterServer() const { return (this->pInfo->nodeType == NET_MASTER_SERVER)? true:false; }
     51    inline bool isProxyServer() const { return (this->pInfo->nodeType == NET_PROXY_SERVER)? true:false; }
     52    inline bool isClient() const { return (this->pInfo->nodeType == NET_CLIENT)? true:false; }
    5353//     inline bool isActive() const { return this->bActive; }
    5454    inline int getMaxConnections(){ return MAX_CONNECTIONS; }
     
    9494
    9595    PeerInfo*                  pInfo;                       //!< the info about the local peer node (not in the PeerList)
    96     int                        nodeType;                    //!< the type of this host (NET_CLIENT, NET_MASTER_SERVER,...)
    97     int                        myHostId;                    //!< the host id of the localhost
    9896
    9997    std::list<int>             freeSocketSlots;             //!< list of free sockets (to ensure not to resycle sockets)
Note: See TracChangeset for help on using the changeset viewer.