Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 25, 2006, 9:29:45 PM (19 years ago)
Author:
patrick
Message:

trunk: merged network back to trunk

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

Legend:

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

    r6724 r6737  
    289289  this->weaponAction();
    290290
    291   if( xMouse != 0 || yMouse != 0)
     291  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner()==this->getHostID() )
    292292   {
    293293    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
     
    532532
    533533  byte b;
    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   if ( b == DATA_flags /*&& this->getHostID()!=this->getOwner()*/ )
    549   {
    550     int flags = 0;
    551     SYNCHELP_READ_INT( flags );
    552 
    553     bUp = (flags & MASK_bUp) != 0;
    554     bDown = (flags & MASK_bDown) != 0;
    555     bLeft = (flags & MASK_bLeft) != 0;
    556     bRight = (flags & MASK_bRight) != 0;
    557     bAscend = (flags & MASK_bAscend) != 0;
    558     bDescend = (flags & MASK_bDescend) != 0;
    559     bFire = (flags & MASK_bFire) != 0;
    560     bRollL = (flags & MASK_bRollL) != 0;
    561     bRollR = (flags & MASK_bRollR) != 0;
    562 
    563   }
     534
     535  do
     536  {
     537    SYNCHELP_READ_BYTE( b );
     538
     539    if ( b == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ )
     540    {
     541     PRINTF(0)("GOT STATE %d\n", this->getUniqueID());
     542     setRequestedSync( false );
     543     setIsOutOfSync( false );
     544     SYNCHELP_READ_FKT( WorldEntity::writeState );
     545     //SYNCHELP_READ_FLOAT( cycle );
     546
     547      return SYNCHELP_READ_N;
     548    }
     549
     550
     551    //TODO: do not recieve data if you are the owner
     552    if ( b == DATA_flags /*&& this->getHostID()!=this->getOwner()*/ )
     553    {
     554      int flags = 0;
     555      SYNCHELP_READ_INT( flags );
     556
     557      //bUp = (flags & MASK_bUp) != 0;
     558      //bDown = (flags & MASK_bDown) != 0;
     559      //bLeft = (flags & MASK_bLeft) != 0;
     560      //bRight = (flags & MASK_bRight) != 0;
     561      //bAscend = (flags & MASK_bAscend) != 0;
     562      //bDescend = (flags & MASK_bDescend) != 0;
     563      //bFire = (flags & MASK_bFire) != 0;
     564      //bRollL = (flags & MASK_bRollL) != 0;
     565      //bRollR = (flags & MASK_bRollR) != 0;
     566
     567    }
     568
     569    //TODO: do not recieve data if you are the owner
     570    if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/ )
     571    {
     572      float asdf;
     573      SYNCHELP_READ_FLOAT( asdf );
     574      SYNCHELP_READ_FLOAT( asdf );
     575      SYNCHELP_READ_FLOAT( asdf );
     576      SYNCHELP_READ_FLOAT( asdf );
     577      //SYNCHELP_READ_FLOAT( mouseDir.w );
     578      //SYNCHELP_READ_FLOAT( mouseDir.v.x );
     579      //SYNCHELP_READ_FLOAT( mouseDir.v.y );
     580      //SYNCHELP_READ_FLOAT( mouseDir.v.z );
     581    }
     582  } while( b != 0 );
    564583
    565584  /*if ( b == DATA_mouse && this->getHostID()!=this->getOwner() )
     
    638657      SYNCHELP_WRITE_INT( mask );
    639658    }
    640     else
    641     {
    642       SYNCHELP_WRITE_BYTE( 0 );
    643     }
    644 
    645     /*if ( oldxMouse != xMouse || oldyMouse != yMouse )
    646     {
    647       oldxMouse = xMouse;
    648       oldyMouse = yMouse;
     659#define __OFFSET_ROT 0.05
     660    if ( fabs( oldMouseDir.w - mouseDir.w ) > __OFFSET_ROT ||
     661         fabs( oldMouseDir.v.x - mouseDir.v.x ) > __OFFSET_ROT ||
     662         fabs( oldMouseDir.v.y - mouseDir.v.y ) > __OFFSET_ROT ||
     663         fabs( oldMouseDir.v.z - mouseDir.v.z ) > __OFFSET_ROT )
     664    {
     665      oldMouseDir = mouseDir;
     666
    649667      SYNCHELP_WRITE_BYTE( DATA_mouse );
    650       SYNCHELP_WRITE_FLOAT( xMouse );
    651       SYNCHELP_WRITE_FLOAT( yMouse );
    652       SYNCHELP_WRITE_FLOAT( mouseSensitivity );
    653       SYNCHELP_WRITE_FLOAT( cycle );
    654     }*/
    655   }
    656   else
    657   {
    658     SYNCHELP_WRITE_BYTE( 0 );
    659   }
     668      SYNCHELP_WRITE_FLOAT( mouseDir.w );
     669      SYNCHELP_WRITE_FLOAT( mouseDir.v.x );
     670      SYNCHELP_WRITE_FLOAT( mouseDir.v.y );
     671      SYNCHELP_WRITE_FLOAT( mouseDir.v.z );
     672    }
     673
     674  }
     675
     676  SYNCHELP_WRITE_BYTE( 0 );
     677
    660678
    661679  if ( this->getOwner() == this->getHostID() )
  • trunk/src/world_entities/space_ships/space_ship.h

    r6637 r6737  
    7272    Vector                velocity;           //!< the velocity of the player.
    7373    Quaternion            mouseDir;           //!< the direction where the player wants to fly
     74    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
    7475    float                 shipInertia;        //!< the inertia of the ship(how fast the ship reacts to a mouse input)
    7576    Quaternion            rotQuat;
Note: See TracChangeset for help on using the changeset viewer.