Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6341 in orxonox.OLD for trunk/src/lib/network/handshake.cc


Ignore:
Timestamp:
Dec 30, 2005, 1:57:12 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the network branche back to the trunk, so we do not get away from each other to fast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/network/handshake.cc

    r6139 r6341  
    3737}
    3838
    39 void Handshake::writeBytes( const byte * data, int length )
     39int Handshake::writeBytes( const byte * data, int length, int sender)
    4040{
    4141  PRINTF(5)("Handshake::writeBytes states = %d %d %d %d (%d)\n", hasState( HS_RECVD_INIT ), hasState( HS_RECVD_VER ), hasState( HS_RECVD_HID ), hasState( HS_COMPLETED ), state);
    4242
     43  SYNCHELP_READ_BEGIN();
     44
    4345  if ( hasState( HS_COMPLETED ) )
    44        return;
     46       return 0;
    4547
    4648  if ( !hasState( HS_RECVD_INIT ) )
     
    5052      PRINTF(0)("initial packet has wrong size %d instead of %d\n", length, _INITIAL_DATA_LENGTH);
    5153      setState( HS_COMPLETED );
    52       return;
     54      return 0;
    5355    }
    5456
     
    5759      PRINTF(0)("initial packed does not match\n");
    5860      setState( HS_COMPLETED );
    59       return;
     61      return length;
    6062    }
    6163
    6264    setState( HS_RECVD_INIT );
    6365    PRINTF(0)("got valid initial packet from client %d\n", clientId);
    64     return;
     66    return length;
    6567  }
    6668
     
    7173      PRINTF(0)("version number packet has wrong size %d instead of %d\n", length, _ORXONOX_VERSION_LENGTH);
    7274      setState( HS_COMPLETED );
    73       return;
     75      return 0;
    7476    }
    7577
     
    7880      PRINTF(0)("versions do not match\n");
    7981      setState( HS_COMPLETED );
    80       return;
     82      return length;
    8183    }
    8284
     
    8486
    8587    PRINTF(0)("client %d's version does match\n", clientId);
    86     return;
     88    return length;
    8789  }
    8890
    8991  if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) )
    9092  {
    91     if ( length != 2 )
     93    if ( length != INTSIZE+INTSIZE )
    9294    {
    9395      PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, 1);
    9496      setState( HS_COMPLETED );
    95       return;
     97      return 0;
    9698    }
    9799
     
    99101    setState( HS_RECVD_HID );
    100102    this->isOk = true;
    101     this->newHostId = data[0];
    102     this->newNetworkGameManagerId = data[1];
     103    SYNCHELP_READ_INT( this->newHostId );
     104    SYNCHELP_READ_INT( this->newNetworkGameManagerId );
    103105
    104106    if ( newHostId == 0 )
     
    112114      PRINTF(0)("got my hostID: %d and networkGameManagerId: %d\n", newHostId, newNetworkGameManagerId);
    113115    }
    114     return;
     116    return SYNCHELP_READ_N;
    115117  }
    116118
     
    120122{
    121123  PRINTF(5)("Handshake::readBytes states = %d %d %d %d (%d)\n", hasState( HS_SENT_INIT ), hasState( HS_SENT_VER ), hasState( HS_SENT_HID ), hasState( HS_COMPLETED ), state);
     124
     125  SYNCHELP_WRITE_BEGIN();
    122126
    123127  if ( hasState( HS_COMPLETED ) )
     
    172176      isOk = false;
    173177      //memcpy(data, (byte*)0, 4);
    174       data[0] = 0;
     178      SYNCHELP_WRITE_INT( 0 );
     179      SYNCHELP_WRITE_INT( 0 );
    175180    }
    176181    else
     
    178183      isOk = true;
    179184      //memcpy(data, &clientId, 4);
    180       data[0] = (byte)clientId;
    181       data[1] = (byte)networkGameManagerId;
     185      SYNCHELP_WRITE_INT( clientId );
     186      SYNCHELP_WRITE_INT( networkGameManagerId );
    182187    }
    183188    *reciever = clientId;
    184     return 2;
     189    return SYNCHELP_WRITE_N;
    185190  }
    186191
Note: See TracChangeset for help on using the changeset viewer.