Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 30, 2006, 10:24:20 AM (18 years ago)
Author:
rennerc
Message:

fire over network works again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/world_entities/space_ships/space_ship.cc

    r6820 r6861  
    128128
    129129  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
    130   bFire = false;
     130
    131131  xMouse = yMouse = 0;
    132132  yInvert = 1;
     
    517517#define MASK_bAscend    16
    518518#define MASK_bDescend   32
    519 #define MASK_bFire      64
    520 #define MASK_bRollL    128
    521 #define MASK_bRollR    256
     519#define MASK_bRollL     64
     520#define MASK_bRollR    128
    522521
    523522#define DATA_state       1
     
    526525#define DATA_sync        4
    527526#define DATA_velocity    5
     527#define DATA_playables   6
    528528
    529529int SpaceShip::writeBytes( const byte * data, int length, int sender )
     
    548548    if ( b == DATA_flags )
    549549    {
    550       int flags = 0;
    551       SYNCHELP_READ_INT( flags, NWT_SS_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;
     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      }
    562565     
    563566      continue;
     
    566569    if ( b == DATA_mouse )
    567570    {
    568       SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
    569       SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
    570       SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
    571       SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
     571      if ( this->getOwner() != this->getHostID() )
     572      {
     573        SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
     574        SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
     575        SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
     576        SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
     577      }
    572578     
    573579      continue;
     
    584590    if ( b == DATA_velocity )
    585591    {
    586       SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX );
    587       SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY );
    588       SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ );
     592      if ( this->getOwner() != this->getHostID() )
     593      {
     594        SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX );
     595        SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY );
     596        SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ );
     597      }
     598     
     599      continue;
     600    }
     601   
     602    if ( b == DATA_playables )
     603    {
     604      if ( this->getOwner() != this->getHostID() )
     605        SYNCHELP_READ_FKT( Playable::writeSync, NWT_SS_PL_SYNC );
    589606    }
    590607  }
     
    616633
    617634    SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_SS_WE_STATE );
    618     //SYNCHELP_WRITE_FLOAT( cycle );
    619635
    620636    return SYNCHELP_WRITE_N;
     
    631647  if ( this->getHostID()==this->getOwner() )
    632648  {
    633     int mask = 0;
     649    byte mask = 0;
    634650
    635651    if ( bUp )
     
    643659    if ( bAscend )
    644660      mask |= MASK_bAscend;
    645     if ( bFire )
    646       mask |= MASK_bFire;
    647661    if ( bRollL )
    648662      mask |= MASK_bRollL;
     
    651665
    652666
    653     //static float oldxMouse = xMouse + 1.0;
    654     //static float oldyMouse = yMouse + 1.0;
    655 
    656667    if ( mask != oldMask )
    657668    {
    658669      oldMask = mask;
    659670      SYNCHELP_WRITE_BYTE( DATA_flags, NWT_SS_B );
    660       SYNCHELP_WRITE_INT( mask, NWT_SS_FLAGS );
     671      SYNCHELP_WRITE_BYTE( mask, NWT_SS_FLAGS );
    661672    }
    662673#define __OFFSET_MDIR_W 0.01
     
    688699      SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ );
    689700    }
     701   
     702    if ( Playable::needsReadSync() )
     703    {
     704      SYNCHELP_WRITE_BYTE( DATA_playables, NWT_SS_B );
     705      SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC );
     706    }
    690707
    691708  }
Note: See TracChangeset for help on using the changeset viewer.