Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 26, 2006, 8:03:40 PM (19 years ago)
Author:
rennerc
Message:

sync: added debug feature

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

    r6764 r6784  
    557557
    558558  byte b;
    559 
    560   do
    561   {
    562     SYNCHELP_READ_BYTE( b );
    563 
    564     if ( b == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ )
    565     {
    566      PRINTF(0)("GOT STATE %d\n", this->getUniqueID());
    567      setRequestedSync( false );
    568      setIsOutOfSync( false );
    569      SYNCHELP_READ_FKT( WorldEntity::writeState );
     559 
     560  if ( SYNCHELP_READ_REMAINING()>0 && SYNCHELP_READ_NEXTBYTE() == DATA_state /*&& (this->getHostID()!=this->getOwner() || sender==0)*/ )
     561  {
     562    PRINTF(0)("GOT STATE %d\n", this->getUniqueID());
     563    setRequestedSync( false );
     564    setIsOutOfSync( false );
     565    SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SS_WE_STATE );
    570566     //SYNCHELP_READ_FLOAT( cycle );
    571567
    572       return SYNCHELP_READ_N;
    573     }
    574 
     568    return SYNCHELP_READ_N;
     569  }
     570 
     571  if ( this->getOwner() != this->getHostID() )
     572    SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC );
     573
     574  while ( SYNCHELP_READ_REMAINING()>0 )
     575  {
     576    SYNCHELP_READ_BYTE( b, NWT_SS_B );
    575577
    576578    //TODO: do not recieve data if you are the owner
     
    578580    {
    579581      int flags = 0;
    580       SYNCHELP_READ_INT( flags );
     582      SYNCHELP_READ_INT( flags, NWT_SS_FLAGS );
    581583
    582584      bUp = (flags & MASK_bUp) != 0;
     
    595597    if ( b == DATA_mouse /*&& this->getHostID()!=this->getOwner()*/ )
    596598    {
    597       SYNCHELP_READ_FLOAT( mouseDir.w );
    598       SYNCHELP_READ_FLOAT( mouseDir.v.x );
    599       SYNCHELP_READ_FLOAT( mouseDir.v.y );
    600       SYNCHELP_READ_FLOAT( mouseDir.v.z );
     599      SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
     600      SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
     601      SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
     602      SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
    601603    }
    602   } while( b != 0 );
     604  };
    603605
    604606  /*if ( b == DATA_mouse && this->getHostID()!=this->getOwner() )
     
    610612}*/
    611613
    612   if ( this->getOwner() != this->getHostID() )
    613     SYNCHELP_READ_FKT( PNode::writeSync );
    614 
    615614  return SYNCHELP_READ_N;
    616615}
     
    636635    PRINTF(0)("SEND STATE %d %d\n", this->getUniqueID(), rec);
    637636
    638     SYNCHELP_WRITE_BYTE( (byte)DATA_state );
    639 
    640     SYNCHELP_WRITE_FKT( WorldEntity::readState );
     637    SYNCHELP_WRITE_BYTE( (byte)DATA_state, NWT_SS_B );
     638
     639    SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_SS_WE_STATE );
    641640    //SYNCHELP_WRITE_FLOAT( cycle );
    642641
     
    645644
    646645  *reciever = 0;
     646 
     647  if ( this->getOwner() == this->getHostID() )
     648    SYNCHELP_WRITE_FKT( PNode::readSync, NWT_SS_PN_SYNC );
    647649
    648650  if ( this->getHostID()==this->getOwner() )
     
    674676    {
    675677      oldMask = mask;
    676       SYNCHELP_WRITE_BYTE( DATA_flags );
    677       SYNCHELP_WRITE_INT( mask );
     678      SYNCHELP_WRITE_BYTE( DATA_flags, NWT_SS_B );
     679      SYNCHELP_WRITE_INT( mask, NWT_SS_FLAGS );
    678680    }
    679681#define __OFFSET_ROT 0.05
     
    685687      oldMouseDir = mouseDir;
    686688
    687       SYNCHELP_WRITE_BYTE( DATA_mouse );
    688       SYNCHELP_WRITE_FLOAT( mouseDir.w );
    689       SYNCHELP_WRITE_FLOAT( mouseDir.v.x );
    690       SYNCHELP_WRITE_FLOAT( mouseDir.v.y );
    691       SYNCHELP_WRITE_FLOAT( mouseDir.v.z );
     689      SYNCHELP_WRITE_BYTE( DATA_mouse, NWT_SS_B );
     690      SYNCHELP_WRITE_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
     691      SYNCHELP_WRITE_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
     692      SYNCHELP_WRITE_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
     693      SYNCHELP_WRITE_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
    692694    }
    693695
    694696  }
    695697
    696   SYNCHELP_WRITE_BYTE( 0 );
    697 
    698 
    699   if ( this->getOwner() == this->getHostID() )
    700     SYNCHELP_WRITE_FKT( PNode::readSync );
    701 
    702698  return SYNCHELP_WRITE_N;
    703699}
     700
     701int SpaceShip::writeState(const byte* data, int length, int sender)
     702{
     703  SYNCHELP_READ_BEGIN();
     704 
     705  return SYNCHELP_READ_N;
     706}
     707
     708int SpaceShip::readState(byte* data, int maxLength )
     709{
     710  SYNCHELP_WRITE_BEGIN();
     711 
     712  return SYNCHELP_WRITE_N;
     713}
     714
     715int SpaceShip::writeSync(const byte* data, int length, int sender)
     716{
     717  SYNCHELP_READ_BEGIN();
     718 
     719  return SYNCHELP_READ_N;
     720}
     721
     722int SpaceShip::readSync(byte* data, int maxLength )
     723{
     724  SYNCHELP_WRITE_BEGIN();
     725 
     726  return SYNCHELP_WRITE_N;
     727}
  • branches/network/src/world_entities/space_ships/space_ship.h

    r6756 r6784  
    4444    virtual int       writeBytes(const byte* data, int length, int sender);
    4545    virtual int       readBytes(byte* data, int maxLength, int * reciever);
     46   
     47    int       writeState(const byte* data, int length, int sender);
     48    int       readState(byte* data, int maxLength );
     49    int       writeSync(const byte* data, int length, int sender);
     50    int       readSync(byte* data, int maxLength );
    4651
    4752
Note: See TracChangeset for help on using the changeset viewer.