Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6685 in orxonox.OLD for branches/network


Ignore:
Timestamp:
Jan 25, 2006, 1:35:29 AM (19 years ago)
Author:
patrick
Message:

network: some more degbug ability for pnode, started work on water synchronization

Location:
branches/network/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/coord/p_node.cc

    r6682 r6685  
    488488      this->children.push_back(child);
    489489    child->parentCoorChanged();
     490
     491//     if(this->getUniqueID() == NET_UID_UNASSIGNED)
     492//     {
     493//       PRINTF(1)("Adding to an UNASSIGNED PNode - looking for next assigned Node\n");
     494//       PNode* node = this->seekNextAssignedPNode(this);
     495//       if( node == NULL)
     496//         PRINTF(1)("    Got NULL - Is this the NULLParent - uid %i\n", this->getUniqueID());
     497//       else
     498//         PRINTF(1)("    Found next assigned node: %i\n", node->getUniqueID());
     499//     }
    490500  }
    491501  else
     
    496506    child->parentCoorChanged();
    497507  }
     508}
     509
     510
     511PNode* PNode::seekNextAssignedPNode(PNode* node) const
     512{
     513  PNode* tmpNode = node->parent;
     514  printf("entering seek PNode loop for name: %s, uid: %i\n", node->getName(), node->getUniqueID());
     515  if(tmpNode)
     516    printf("  @node name: %s, uid: %d\n", tmpNode->getName(), tmpNode->getUniqueID());
     517  while( tmpNode != NULL && tmpNode->getUniqueID() == NET_UID_UNASSIGNED)
     518  {
     519    printf("  @node name: %s, uid: %d\n", tmpNode->getName(), tmpNode->getUniqueID());
     520    tmpNode = tmpNode->parent;
     521  }
     522  printf("leaving PNode loop\n\n");
     523
     524  return tmpNode;
    498525}
    499526
  • branches/network/src/lib/coord/p_node.h

    r6634 r6685  
    147147  void removeNode();
    148148
     149  PNode* seekNextAssignedPNode(PNode* node) const;
     150
    149151  /** @param parent the new parent of this node */
    150152  inline void setParent (PNode* parent) { parent->addChild(this); };
  • branches/network/src/lib/network/netdefs.h

    r6678 r6685  
    2828} NodeType;
    2929
     30
     31typedef enum {
     32  NET_UID_UNASSIGNED = -1,
     33
     34  NET_UID_NUMBER
     35} UidType;
     36
    3037#endif /* _NETWORK_MANAGER */
  • branches/network/src/lib/network/network_game_manager.cc

    r6678 r6685  
    407407  e = this->networkStream->getSyncEnd();
    408408
     409  // send the packet header
    409410  if ( !writeToClientBuffer( outBuffer[userID], (byte)NET_CREATE_ENTITY_LIST ) )
    410411    return;
    411412
    412   // -2 because you must not send network_game_manager and handshake
     413  // send the number of entities: -2 because you must not send network_game_manager and handshake
    413414  if ( !writeToClientBuffer( outBuffer[userID], networkStream->getSyncCount() ) )
    414415    return;
     
    416417  //PRINTF(0)("SendEntityList: n = %d\n", networkStream->getSyncCount()-2 );
    417418
    418   int n = 0;
    419 
     419  // first send the NullParent
     420  if ( !writeToClientBuffer( outBuffer[userID], (int)PNode::getNullParent()->getLeafClassID()) )
     421    return;
     422  if ( !writeToClientBuffer( outBuffer[userID], (int)PNode::getNullParent()->getUniqueID()) )
     423    return;
     424  if ( !writeToClientBuffer( outBuffer[userID], (int)PNode::getNullParent()->getOwner()) )
     425    return;
     426
     427  // now send the rest of the entities
    420428  while ( it != e )
    421429  {
    422     if( (*it)->beSynchronized())
     430    if( (*it)->beSynchronized() && (*it) != PNode::getNullParent())
    423431    {
    424432      PRINTF(0)("SENDING ENTITY %s classid: %x, uniqueid %d\n", (*it)->getClassName(), (*it)->getLeafClassID(), (*it)->getUniqueID() );
     
    489497  if( classID == CL_NULL_PARENT)
    490498  {
    491     b = PNode::getNullParent();
     499    b = (BaseObject*)PNode::getNullParent();
    492500  }
    493501  else
     
    806814    {
    807815      BaseObject* b = doCreateEntity( (ClassID)classID, uniqueID, owner );
    808 
    809       /*if ( b != NULL )
    810       {
    811         if ( b->isA(CL_WORLD_ENTITY) )
    812         {
    813           int n = dynamic_cast<WorldEntity*>(b)->writeState( data, length, sender );
    814 
    815           i += n;
    816         }
    817     }*/
    818816    }
    819817
  • branches/network/src/lib/network/synchronizeable.cc

    r6683 r6685  
    3939  this->hostID = SharedNetworkData::getInstance()->getHostID();
    4040  this->setIsServer(this->hostID == 0);
    41   this->uniqueID = -1;
     41  this->uniqueID = NET_UID_UNASSIGNED;
    4242  this->networkStream = NULL;
    4343  this->setRequestedSync( false );
  • branches/network/src/orxonox.cc

    r6683 r6685  
    279279  if( this->serverName != NULL) // we are a client
    280280  {
     281    State::setOnline(true);
    281282    NetworkManager::getInstance()->establishConnection(this->serverName, port);
     283  }
     284  else if( this->port > 0) {    // we are a server
    282285    State::setOnline(true);
    283   }
    284   else if( this->port > 0) {    // we are a server
    285286    NetworkManager::getInstance()->createServer(port);
    286     State::setOnline(true);
    287287  }
    288288  return 0;
  • branches/network/src/world_entities/environments/water.cc

    r6610 r6685  
    219219  this->grid->rebuildNormals(this->height);
    220220}
     221
     222
     223/**
     224 * Writes data from network containing information about the state
     225 * @param data pointer to data
     226 * @param length length of data
     227 * @param sender hostID of sender
     228 */
     229int Water::writeBytes( const byte * data, int length, int sender )
     230{
     231//   setRequestedSync( false );
     232//   setIsOutOfSync( false );
     233//
     234//   SYNCHELP_READ_BEGIN();
     235//
     236//   SYNCHELP_READ_FKT( WorldEntity::writeState );
     237//
     238//   return SYNCHELP_READ_N;
     239}
     240
     241
     242/**
     243 * data copied in data will bee sent to another host
     244 * @param data pointer to data
     245 * @param maxLength max length of data
     246 * @return the number of bytes writen
     247 */
     248int Water::readBytes( byte * data, int maxLength, int * reciever )
     249{
     250//   SYNCHELP_WRITE_BEGIN();
     251//
     252//   if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     253//   {
     254//     (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     255//     setRequestedSync( true );
     256//   }
     257//
     258//   int rec = this->getRequestSync();
     259//   if ( rec > 0 )
     260//   {
     261//     *reciever = rec;
     262//
     263//     SYNCHELP_WRITE_FKT( WorldEntity::readState );
     264//
     265//   }
     266//
     267//   *reciever = 0;
     268//   return SYNCHELP_WRITE_N;
     269}
  • branches/network/src/world_entities/environments/water.h

    r6518 r6685  
    3535   void tick(float dt);
    3636
     37   virtual int writeBytes(const byte* data, int length, int sender);
     38   virtual int readBytes(byte* data, int maxLength, int * reciever);
     39
     40
    3741  private:
    3842    Grid*           grid;            //!< The water-surface-model to render with
Note: See TracChangeset for help on using the changeset viewer.