Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jan 30, 2006, 4:41:19 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the Network back to the trunk.
merged with command
svn merge https://svn.orxonox.net/orxonox/branches/network . -r6817:HEAD
no conflicts

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

Legend:

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

    r6825 r6868  
    9595  else
    9696  {
    97     this->loadModel("models/ships/reap_#.obj");
     97    //this->loadModel("models/ships/reap_#.obj");
     98    this->loadModel( "models/ships/fighter.obj" );
    9899  }
    99100
     
    127128
    128129  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
    129   bFire = false;
     130
    130131  xMouse = yMouse = 0;
    131132  yInvert = 1;
     
    516517#define MASK_bAscend    16
    517518#define MASK_bDescend   32
    518 #define MASK_bFire      64
    519 #define MASK_bRollL    128
    520 #define MASK_bRollR    256
     519#define MASK_bRollL     64
     520#define MASK_bRollR    128
    521521
    522522#define DATA_state       1
     
    525525#define DATA_sync        4
    526526#define DATA_velocity    5
     527#define DATA_playables   6
    527528
    528529int SpaceShip::writeBytes( const byte * data, int length, int sender )
     
    547548    if ( b == DATA_flags )
    548549    {
    549       int flags = 0;
    550       SYNCHELP_READ_INT( flags, NWT_SS_FLAGS );
    551 
    552       bUp = (flags & MASK_bUp) != 0;
    553       bDown = (flags & MASK_bDown) != 0;
    554       bLeft = (flags & MASK_bLeft) != 0;
    555       bRight = (flags & MASK_bRight) != 0;
    556       bAscend = (flags & MASK_bAscend) != 0;
    557       bDescend = (flags & MASK_bDescend) != 0;
    558       bFire = (flags & MASK_bFire) != 0;
    559       bRollL = (flags & MASK_bRollL) != 0;
    560       bRollR = (flags & MASK_bRollR) != 0;
     550      if ( this->getOwner() != this->getHostID() )
     551      {
     552        byte flags = 0;
     553        SYNCHELP_READ_BYTE( flags, NWT_SS_FLAGS );
     554
     555        bUp = (flags & MASK_bUp) != 0;
     556        bDown = (flags & MASK_bDown) != 0;
     557        bLeft = (flags & MASK_bLeft) != 0;
     558        bRight = (flags & MASK_bRight) != 0;
     559        bAscend = (flags & MASK_bAscend) != 0;
     560        bDescend = (flags & MASK_bDescend) != 0;
     561        bRollL = (flags & MASK_bRollL) != 0;
     562        bRollR = (flags & MASK_bRollR) != 0;
     563       
     564      }
     565      else
     566        assert(false);
    561567
    562568      continue;
     
    565571    if ( b == DATA_mouse )
    566572    {
    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 );
     573      if ( this->getOwner() != this->getHostID() )
     574      {
     575        SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
     576        SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
     577        SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
     578        SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
     579      }
     580      else
     581        assert(false);
    571582
    572583      continue;
     
    576587    {
    577588      if ( this->getOwner() != this->getHostID() )
     589      {
    578590        SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC );
     591      }
     592      else
     593        assert(false);
    579594
    580595      continue;
     
    583598    if ( b == DATA_velocity )
    584599    {
    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 );
     600      if ( this->getOwner() != this->getHostID() )
     601      {
     602        SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX );
     603        SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY );
     604        SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ );
     605      }     
     606      else
     607        assert(false);
     608     
     609      continue;
     610    }
     611   
     612    if ( b == DATA_playables )
     613    {
     614      if ( this->getOwner() != this->getHostID() )
     615      {
     616        SYNCHELP_READ_FKT( Playable::writeSync, NWT_SS_PL_SYNC );
     617      }
     618      else
     619        assert(false);
    588620    }
    589621  }
     
    615647
    616648    SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_SS_WE_STATE );
    617     //SYNCHELP_WRITE_FLOAT( cycle );
    618649
    619650    return SYNCHELP_WRITE_N;
    620651  }
    621652
    622   *reciever = 0;
    623 
    624   if ( this->getOwner() == this->getHostID() && PNode::needsReadSync() )
     653  *reciever = -this->getOwner();
     654  bool sentSomething = false;
     655
     656  if ( ( this->getHostID()==0 || this->getOwner() == this->getHostID() ) && PNode::needsReadSync() )
    625657  {
    626658    SYNCHELP_WRITE_BYTE( DATA_sync, NWT_SS_B );
     
    628660  }
    629661
    630   if ( this->getHostID()==this->getOwner() )
    631   {
    632     int mask = 0;
     662  if ( this->getHostID()==0 || this->getHostID()==this->getOwner() )
     663  {
     664    byte mask = 0;
    633665
    634666    if ( bUp )
     
    642674    if ( bAscend )
    643675      mask |= MASK_bAscend;
    644     if ( bFire )
    645       mask |= MASK_bFire;
    646676    if ( bRollL )
    647677      mask |= MASK_bRollL;
     
    650680
    651681
    652     //static float oldxMouse = xMouse + 1.0;
    653     //static float oldyMouse = yMouse + 1.0;
    654 
    655682    if ( mask != oldMask )
    656683    {
    657684      oldMask = mask;
     685      sentSomething = true;
    658686      SYNCHELP_WRITE_BYTE( DATA_flags, NWT_SS_B );
    659       SYNCHELP_WRITE_INT( mask, NWT_SS_FLAGS );
     687      SYNCHELP_WRITE_BYTE( mask, NWT_SS_FLAGS );
    660688    }
    661689#define __OFFSET_MDIR_W 0.01
     
    670698      SYNCHELP_WRITE_BYTE( DATA_mouse, NWT_SS_B );
    671699      PRINTF(0)("SENDING mousedir\n");
     700      sentSomething = true;
    672701      SYNCHELP_WRITE_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
    673702      SYNCHELP_WRITE_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
     
    681710    {
    682711      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   }
     712      //PRINTF(0)("SENDING velocity\n");
     713      //SYNCHELP_WRITE_BYTE( DATA_velocity, NWT_SS_B );
     714      //SYNCHELP_WRITE_FLOAT( velocity.x, NWT_SS_VELX );
     715      //SYNCHELP_WRITE_FLOAT( velocity.y, NWT_SS_VELY );
     716      //SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ );
     717    }
     718   
     719    if ( Playable::needsReadSync() )
     720    {
     721      sentSomething = true;
     722      SYNCHELP_WRITE_BYTE( DATA_playables, NWT_SS_B );
     723      SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC );
     724    }
     725
     726  }
     727 
     728  if ( !sentSomething )
     729    reciever = 0;
    691730
    692731  return SYNCHELP_WRITE_N;
  • trunk/src/world_entities/space_ships/space_ship.h

    r6815 r6868  
    5656    bool                  bAscend;            //!< ascend button pressed.
    5757    bool                  bDescend;           //!< descend button presses.
    58     bool                  bFire;              //!< fire button pressed.
     58//    bool                  bFire;              //!< fire button pressed.(moved to playable)
    5959    bool                  bRollL;             //!< rolling button pressed (left)
    6060    bool                  bRollR;             //!< rolling button pressed (right)
     
    8080    float                 airViscosity;
    8181
    82     int oldMask;
     82    byte                  oldMask;            //!< used for synchronisation
    8383
    8484    ParticleEmitter*      burstEmitter;
Note: See TracChangeset for help on using the changeset viewer.