Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6815 in orxonox.OLD for trunk/src/world_entities/space_ships


Ignore:
Timestamp:
Jan 28, 2006, 5:11:51 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged branches/network back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/network . -r6774:HEAD

no conflicts…
thats what i call orthogonal work

Location:
trunk/src/world_entities/space_ships
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/space_ships/space_ship.cc

    r6807 r6815  
    523523#define DATA_flags       2
    524524#define DATA_mouse       3
     525#define DATA_sync        4
     526#define DATA_velocity    5
    525527
    526528int SpaceShip::writeBytes( const byte * data, int length, int sender )
     
    529531
    530532  byte b;
    531 
    532   do
    533   {
    534     SYNCHELP_READ_BYTE( b );
    535 
    536     if ( b == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ )
    537     {
    538      PRINTF(0)("GOT STATE %d\n", this->getUniqueID());
    539      setRequestedSync( false );
    540      setIsOutOfSync( false );
    541      SYNCHELP_READ_FKT( WorldEntity::writeState );
    542      //SYNCHELP_READ_FLOAT( cycle );
    543 
    544       return SYNCHELP_READ_N;
    545     }
    546 
    547 
    548     //TODO: do not recieve data if you are the owner
    549     if ( b == DATA_flags /*&& this->getHostID()!=this->getOwner()*/ )
     533 
     534  while ( SYNCHELP_READ_REMAINING()>0 )
     535  {
     536    SYNCHELP_READ_BYTE( b, NWT_SS_B );
     537   
     538    if ( b == DATA_state )
     539    {
     540      setRequestedSync( false );
     541      setIsOutOfSync( false );
     542      SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SS_WE_STATE );
     543
     544      continue;
     545    }
     546   
     547    if ( b == DATA_flags )
    550548    {
    551549      int flags = 0;
    552       SYNCHELP_READ_INT( flags );
     550      SYNCHELP_READ_INT( flags, NWT_SS_FLAGS );
    553551
    554552      bUp = (flags & MASK_bUp) != 0;
     
    561559      bRollL = (flags & MASK_bRollL) != 0;
    562560      bRollR = (flags & MASK_bRollR) != 0;
    563 
    564     }
    565 
    566     //TODO: do not recieve data if you are the owner
    567     if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/ )
    568     {
    569       SYNCHELP_READ_FLOAT( mouseDir.w );
    570       SYNCHELP_READ_FLOAT( mouseDir.v.x );
    571       SYNCHELP_READ_FLOAT( mouseDir.v.y );
    572       SYNCHELP_READ_FLOAT( mouseDir.v.z );
    573     }
    574   } while( b != 0 );
    575 
    576   /*if ( b == DATA_mouse && this->getHostID()!=this->getOwner() )
    577   {
    578     SYNCHELP_READ_FLOAT( xMouse );
    579     SYNCHELP_READ_FLOAT( yMouse );
    580     SYNCHELP_READ_FLOAT( mouseSensitivity );
    581     SYNCHELP_READ_FLOAT( cycle );
    582 }*/
    583 
    584   if ( this->getOwner() != this->getHostID() )
    585     SYNCHELP_READ_FKT( PNode::writeSync );
    586 
     561     
     562      continue;
     563    }
     564   
     565    if ( b == DATA_mouse )
     566    {
     567      SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
     568      SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
     569      SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
     570      SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
     571     
     572      continue;
     573    }
     574   
     575    if ( b == DATA_sync )
     576    {
     577      if ( this->getOwner() != this->getHostID() )
     578        SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC );
     579     
     580      continue;
     581    }
     582   
     583    if ( b == DATA_velocity )
     584    {
     585      SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX );
     586      SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY );
     587      SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ );
     588    }
     589  }
     590 
    587591  return SYNCHELP_READ_N;
    588592}
     
    608612    PRINTF(0)("SEND STATE %d %d\n", this->getUniqueID(), rec);
    609613
    610     SYNCHELP_WRITE_BYTE( (byte)DATA_state );
    611 
    612     SYNCHELP_WRITE_FKT( WorldEntity::readState );
     614    SYNCHELP_WRITE_BYTE( (byte)DATA_state, NWT_SS_B );
     615
     616    SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_SS_WE_STATE );
    613617    //SYNCHELP_WRITE_FLOAT( cycle );
    614618
     
    617621
    618622  *reciever = 0;
     623 
     624  if ( this->getOwner() == this->getHostID() && PNode::needsReadSync() )
     625  {
     626    SYNCHELP_WRITE_BYTE( DATA_sync, NWT_SS_B );
     627    SYNCHELP_WRITE_FKT( PNode::readSync, NWT_SS_PN_SYNC );
     628  }
    619629
    620630  if ( this->getHostID()==this->getOwner() )
     
    646656    {
    647657      oldMask = mask;
    648       SYNCHELP_WRITE_BYTE( DATA_flags );
    649       SYNCHELP_WRITE_INT( mask );
    650     }
    651 #define __OFFSET_ROT 0.05
    652     if ( fabs( oldMouseDir.w - mouseDir.w ) > __OFFSET_ROT ||
    653          fabs( oldMouseDir.v.x - mouseDir.v.x ) > __OFFSET_ROT ||
    654          fabs( oldMouseDir.v.y - mouseDir.v.y ) > __OFFSET_ROT ||
    655          fabs( oldMouseDir.v.z - mouseDir.v.z ) > __OFFSET_ROT )
     658      SYNCHELP_WRITE_BYTE( DATA_flags, NWT_SS_B );
     659      SYNCHELP_WRITE_INT( mask, NWT_SS_FLAGS );
     660    }
     661#define __OFFSET_MDIR_W 0.01
     662#define __OFFSET_MDIR_V 0.01
     663    if ( fabs( oldMouseDir.w - mouseDir.w ) > __OFFSET_MDIR_W ||
     664         fabs( oldMouseDir.v.x - mouseDir.v.x ) > __OFFSET_MDIR_V ||
     665         fabs( oldMouseDir.v.y - mouseDir.v.y ) > __OFFSET_MDIR_V ||
     666         fabs( oldMouseDir.v.z - mouseDir.v.z ) > __OFFSET_MDIR_V )
    656667    {
    657668      oldMouseDir = mouseDir;
    658669
    659       SYNCHELP_WRITE_BYTE( DATA_mouse );
    660       SYNCHELP_WRITE_FLOAT( mouseDir.w );
    661       SYNCHELP_WRITE_FLOAT( mouseDir.v.x );
    662       SYNCHELP_WRITE_FLOAT( mouseDir.v.y );
    663       SYNCHELP_WRITE_FLOAT( mouseDir.v.z );
    664     }
    665 
    666   }
    667 
    668   SYNCHELP_WRITE_BYTE( 0 );
    669 
    670 
    671   if ( this->getOwner() == this->getHostID() )
    672     SYNCHELP_WRITE_FKT( PNode::readSync );
     670      SYNCHELP_WRITE_BYTE( DATA_mouse, NWT_SS_B );
     671      PRINTF(0)("SENDING mousedir\n");
     672      SYNCHELP_WRITE_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
     673      SYNCHELP_WRITE_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
     674      SYNCHELP_WRITE_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
     675      SYNCHELP_WRITE_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
     676    }
     677#define __OFFSET_VEL 0.05
     678    if ( fabs( oldVelocity.x - velocity.x ) > __OFFSET_VEL*velocity.x ||
     679         fabs( oldVelocity.y - velocity.y ) > __OFFSET_VEL*velocity.y ||
     680         fabs( oldVelocity.z - velocity.z ) > __OFFSET_VEL*velocity.z )
     681    {
     682      oldVelocity = velocity;
     683      PRINTF(0)("SENDING velocity\n");
     684      SYNCHELP_WRITE_BYTE( DATA_velocity, NWT_SS_B );
     685      SYNCHELP_WRITE_FLOAT( velocity.x, NWT_SS_VELX );
     686      SYNCHELP_WRITE_FLOAT( velocity.y, NWT_SS_VELY );
     687      SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ );
     688    }
     689
     690  }
    673691
    674692  return SYNCHELP_WRITE_N;
    675693}
     694
     695
  • trunk/src/world_entities/space_ships/space_ship.h

    r6807 r6815  
    4242    virtual int       readBytes(byte* data, int maxLength, int * reciever);
    4343
    44 
    4544  private:
    4645    void init();
     
    7069
    7170    Vector                velocity;           //!< the velocity of the player.
     71    Vector                oldVelocity;        //!< the velocity the player had last synced
    7272    Quaternion            mouseDir;           //!< the direction where the player wants to fly
    7373    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
Note: See TracChangeset for help on using the changeset viewer.