Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 29, 2005, 5:37:00 PM (19 years ago)
Author:
rennerc
Message:

synchronizeable: writeBytes now returns int
converter: converts now 0.0f without endless loop :D

File:
1 edited

Legend:

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

    r6190 r6331  
    3737}
    3838
    39 void Handshake::writeBytes( const byte * data, int length, int sender)
     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.