Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 27, 2006, 1:21:35 PM (19 years ago)
Author:
rennerc
Message:

spaceship: first atemp to fix strange movement

Location:
branches/network/src/world_entities/space_ships
Files:
2 edited

Legend:

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

    r6789 r6790  
    552552#define DATA_mouse       3
    553553#define DATA_sync        4
     554#define DATA_velocity    5
    554555
    555556int SpaceShip::writeBytes( const byte * data, int length, int sender )
     
    607608      continue;
    608609    }
     610   
     611    if ( b == DATA_velocity )
     612    {
     613      SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX );
     614      SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY );
     615      SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ );
     616    }
    609617  }
    610618 
    611 #if 0
    612   if ( SYNCHELP_READ_REMAINING()>0 && SYNCHELP_READ_NEXTBYTE() == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ )
    613   {
    614     PRINTF(0)("GOT STATE %d\n", this->getUniqueID());
    615     setRequestedSync( false );
    616     setIsOutOfSync( false );
    617     SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SS_WE_STATE );
    618      //SYNCHELP_READ_FLOAT( cycle );
    619 
    620     return SYNCHELP_READ_N;
    621   }
    622  
    623   if ( this->getOwner() != this->getHostID() )
    624     SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC );
    625 
    626   while ( SYNCHELP_READ_REMAINING()>0 )
    627   {
    628     SYNCHELP_READ_BYTE( b, NWT_SS_B );
    629 
    630     //TODO: do not recieve data if you are the owner
    631     if ( b == DATA_flags /*&& this->getHostID()!=this->getOwner()*/ )
    632     {
    633       int flags = 0;
    634       SYNCHELP_READ_INT( flags, NWT_SS_FLAGS );
    635 
    636       bUp = (flags & MASK_bUp) != 0;
    637       bDown = (flags & MASK_bDown) != 0;
    638       bLeft = (flags & MASK_bLeft) != 0;
    639       bRight = (flags & MASK_bRight) != 0;
    640       bAscend = (flags & MASK_bAscend) != 0;
    641       bDescend = (flags & MASK_bDescend) != 0;
    642       bFire = (flags & MASK_bFire) != 0;
    643       bRollL = (flags & MASK_bRollL) != 0;
    644       bRollR = (flags & MASK_bRollR) != 0;
    645 
    646     }
    647 
    648     //TODO: do not recieve data if you are the owner
    649     if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/ )
    650     {
    651       SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
    652       SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
    653       SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
    654       SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
    655     }
    656   };
    657 #endif
    658619  return SYNCHELP_READ_N;
    659620}
     
    740701      SYNCHELP_WRITE_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
    741702    }
     703#define __OFFSET_VEL 0.5
     704    if ( fabs( oldVelocity.x - velocity.x ) > __OFFSET_VEL ||
     705         fabs( oldVelocity.y - velocity.y ) > __OFFSET_VEL ||
     706         fabs( oldVelocity.z - velocity.z ) > __OFFSET_VEL )
     707    {
     708      SYNCHELP_WRITE_BYTE( DATA_velocity, NWT_SS_B );
     709      SYNCHELP_WRITE_FLOAT( velocity.x, NWT_SS_VELX );
     710      SYNCHELP_WRITE_FLOAT( velocity.y, NWT_SS_VELY );
     711      SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ );
     712    }
    742713
    743714  }
  • branches/network/src/world_entities/space_ships/space_ship.h

    r6788 r6790  
    7272
    7373    Vector                velocity;           //!< the velocity of the player.
     74    Vecotr                oldVelocity;        //!< the velocity the player had last synced
    7475    Quaternion            mouseDir;           //!< the direction where the player wants to fly
    7576    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
Note: See TracChangeset for help on using the changeset viewer.