Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7575 in orxonox.OLD


Ignore:
Timestamp:
May 10, 2006, 4:48:27 PM (18 years ago)
Author:
rennerc
Message:

fixed some bugs

Location:
branches/network/src/lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/lang/base_object.cc

    r7444 r7575  
    8383  assert (!(this->classID & classID & !CL_MASK_SUBSUPER_CLASS_IDA ));
    8484
     85  this->leafClassID = classID;
    8586  this->classID |= (long)classID;
    8687  this->className = className;
     
    106107 * Factory::fabricate(Object->getLeafClassID());
    107108 */
    108 ClassID BaseObject::getLeafClassID() const
     109const ClassID& BaseObject::getLeafClassID() const
    109110{
    110   assert (this->classList != NULL);
    111   return this->classList->getLeafClassID();
     111  return this->leafClassID;
    112112}
    113113
  • branches/network/src/lib/lang/base_object.h

    r7444 r7575  
    4141  /** @returns the classID of the corresponding Object */
    4242  inline int getClassID() const { return this->classID; };
    43   ClassID    getLeafClassID() const;
     43  const ClassID& getLeafClassID() const;
    4444
    4545  bool isA (ClassID classID) const;
     
    5858    std::string        className;        //!< the name of the class
    5959    long               classID;          //!< this is the id from the class_id.h enumeration
     60    ClassID            leafClassID;      //!< The Leaf Class ID
    6061
    6162    ClassList*         classList;        //!< Pointer to the ClassList this Object is inside of
  • branches/network/src/lib/network/network_stream.cc

    r7571 r7575  
    6464  this->networkProtocol = new NetworkProtocol();
    6565  this->connectionMonitor = new ConnectionMonitor();
    66   this->maxConnections = MAX_CONNECTIONS;
    6766}
    6867
     
    131130  // setUniqueID( maxCon+2 ) because we need one id for every handshake
    132131  // and one for handshake to reject client maxCon+1
    133   this->networkGameManager->setUniqueID( this->maxConnections + 2 );
     132  this->networkGameManager->setUniqueID( MAX_CONNECTIONS + 2 );
    134133
    135134}
     
    142141  assert( peers[0].handshake == NULL );
    143142  peers[0].handshake = hs;
     143//   peers[0].handshake->setSynchronized( true );
     144  this->connectSynchronizeable(*hs);
    144145  //this->connectSynchronizeable(*hs);
    145   PRINTF(0)("NetworkStream: %s\n", hs->getName());
     146  PRINTF(0)("NetworkStream: Handshake created: %s\n", hs->getName());
    146147}
    147148
     
    194195  }
    195196
     197  handleHandshakes();
     198  handleUpstream();
     199  handleDownstream();
    196200
    197201
     
    354358    } else
    355359    {
    356       clientId = 0;
     360      clientId = 1;
    357361     
    358362      for ( PeerList::iterator it = peers.begin(); it != peers.end(); it++ )
     
    366370    }
    367371
    368     if ( clientId > this->maxConnections )
     372    if ( clientId > MAX_CONNECTIONS )
    369373    {
    370374      peers[clientId].handshake->doReject( "too many connections" );
     
    419423               (*it)->getUniqueID(), (*it)->beSynchronized());
    420424  }
    421   PRINT(0)(" Maximal Connections: %i\n", this->maxConnections);
     425  PRINT(0)(" Maximal Connections: %i\n", MAX_CONNECTIONS );
    422426
    423427}
     
    486490    offset = INTSIZE; //make already space for length
    487491   
    488     if ( peer->second.socket )
     492    if ( !peer->second.socket )
    489493      continue;
    490494   
     
    504508    {
    505509      Synchronizeable & sync = **it;
     510
     511      if ( !sync.beSynchronized() || sync.getUniqueID() < 0 )
     512        continue;
     513
     514      //if handshake not finished only sync handshake
     515      if ( peer->second.handshake && sync.getLeafClassID() != CL_HANDSHAKE )
     516        continue;
     517
     518      PRINTF(0)("syncing: id:%d name:%s\n", sync.getUniqueID(), sync.getClassName());
    506519     
    507520      assert( offset + INTSIZE <= UDP_PACKET_SIZE );
    508521     
    509       n = Converter::intToByteArray( sync.getUniqueID(), buf + offset, UDP_PACKET_SIZE - offset );
     522      //server fakes uniqueid=0 for handshake
     523      if ( this->isServer() && sync.getUniqueID() < MAX_CONNECTIONS - 1 )
     524        n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset );
     525      else
     526        n = Converter::intToByteArray( sync.getUniqueID(), buf + offset, UDP_PACKET_SIZE - offset );
    510527      assert( n == INTSIZE );
    511528      offset += n;
     
    517534   
    518535    assert( peer->second.socket->writePacket( buf, offset ) );
     536    PRINTF(0)("send packet: %d\n", offset);
    519537  }
    520538}
     
    537555  for ( PeerList::iterator peer = peers.begin(); peer != peers.end(); peer++ )
    538556  {
     557    if ( !peer->second.socket )
     558      continue;
     559
    539560    packetLength = peer->second.socket->readPacket( buf, UDP_PACKET_SIZE );
     561
     562    if ( packetLength < 4*INTSIZE )
     563    {
     564      if ( packetLength != 0 )
     565        PRINTF(1)("got too small packet: %d\n", packetLength);
     566      continue;
     567    }
    540568   
    541569    assert( Converter::byteArrayToInt( buf, &length ) == INTSIZE );
     
    543571    assert( Converter::byteArrayToInt( buf + 2*INTSIZE, &fromState ) == INTSIZE );
    544572    assert( Converter::byteArrayToInt( buf + 3*INTSIZE, &ackedState ) == INTSIZE );
     573
     574    PRINTF(0)("got packet: %d, %d\n", length, packetLength);
    545575   
    546576    //if this is an old state drop it
     
    565595     
    566596      for ( SynchronizeableList::iterator it = synchronizeables.begin(); it != synchronizeables.end(); it++ )
    567       {
    568         if ( (*it)->getUniqueID() == uniqueId )
     597      {
     598        //                                        client thinks his handshake has id 0!!!!!
     599        if ( (*it)->getUniqueID() == uniqueId || ( uniqueId == 0 && (*it)->getUniqueID() == peer->second.userId ) )
    569600        {
    570601          sync = *it;
  • branches/network/src/lib/network/network_stream.h

    r7565 r7575  
    6060    inline bool isActive() const { return this->bActive; }
    6161
    62     inline int getMaxConnections(){ return maxConnections; }
     62    inline int getMaxConnections(){ return MAX_CONNECTIONS; }
    6363
    6464    virtual void processData();
     
    9494
    9595    int                        myHostId;
    96     int                        maxConnections;
    9796   
    9897    int                        currentState;
  • branches/network/src/lib/network/synchronizeable.cc

    r7565 r7575  
    4141  this->networkStream = NULL;
    4242  this->bSynchronize = false;
    43   this->mLeafClassId = getLeafClassID();
    44 
     43 
    4544  if( State::isOnline())
    4645  {
     
    5352  /* make sure loadClassId is first synced var because this is read by networkStream */
    5453  assert( syncVarList.size() == 0 );
    55   this->registerVar( new SynchronizeableInt( &this->mLeafClassId, &this->mLeafClassId, "leafClassId" ) );
    56  
     54  this->registerVar( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) );
     55   
    5756  this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) );
    5857  this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) );
     
    309308  this->varChangeHandler( changes );
    310309
    311   assert( i == length -1 );
     310  assert( i == length );
    312311
    313312  return length;
  • branches/network/src/lib/network/udp_server_socket.h

    r7565 r7575  
    2020#include <vector>
    2121
    22 #define UDP_PACKET_SIZE 1024
     22#define UDP_PACKET_SIZE 10240
    2323#define MAX_NEW_CONNECTIONS 8
    2424
Note: See TracChangeset for help on using the changeset viewer.