Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 14, 2006, 1:58:16 PM (18 years ago)
Author:
patrick
Message:

synchronizeble var ip address finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/synchronizeable_var/synchronizeable_ip.cc

    r9293 r9294  
    4747  int res;
    4848
    49 //   res = Converter::floatToByteArray( vPtrIn->x, buf + n, maxLength - n );
    50 //   assert( res > 0 );
    51 //   n += res;
    52 //
    53 //   res = Converter::floatToByteArray( vPtrIn->y, buf + n, maxLength - n );
    54 //   assert( res > 0 );
    55 //   n += res;
    56 //
    57 //   res = Converter::floatToByteArray( vPtrIn->z, buf + n, maxLength - n );
    58 //   assert( res > 0 );
    59 //   n += res;
    60 //
    61 //   assert( 3*FLOATSIZE == n );
     49  res = Converter::intToByteArray( (int)vPtrIn->host, buf, maxLength );
     50  assert(res > 0);
     51  n += res;
     52
     53  res = Converter::intToByteArray( (int)vPtrIn->port, buf, maxLength);
     54  assert(res > 0);
     55  n += res;
     56
     57  assert( 2 * INTSIZE == n);
    6258
    6359  return n;
     
    7268int SynchronizeableIP::readFromBuf( byte * buf, int maxLength )
    7369{
    74   assert( maxLength >= 3*FLOATSIZE );
     70  assert( maxLength >= 2 * INTSIZE);
    7571
    76   float x,y,z;
     72  int host, port;
    7773
    7874  int res;
    7975  int n = 0;
    8076
    81 //   Vector oldVec = *vPtrOut;
    82 //
    83 //   res = Converter::byteArrayToFloat( buf + n, &x );
    84 //   assert( res > 0 );
    85 //   n += res;
    86 //
    87 //   res = Converter::byteArrayToFloat( buf + n, &y );
    88 //   assert( res > 0 );
    89 //   n += res;
    90 //
    91 //   res = Converter::byteArrayToFloat( buf + n, &z );
    92 //   assert( res > 0 );
    93 //   n += res;
    94 //
    95 //   *vPtrOut = Vector( x, y, z );
    96 //
    97 //   setHasChanged( !(*vPtrOut == oldVec) );
    98 //
    99 //   assert( n == 3*FLOATSIZE );
     77  IPaddress oldIP = *vPtrOut;
     78  IPaddress newIP;
     79
     80  res = Converter::byteArrayToInt( buf + n, &host);
     81  assert( res > 0);
     82  n += res;
     83
     84
     85  res = Converter::byteArrayToInt( buf + n, &port);
     86  assert( res > 0);
     87  n += res;
     88
     89  newIP.host = host;
     90  newIP.port = port;
     91
     92  setHasChanged( (newIP.host != oldIP.host || newIP.port != oldIP.port) );
     93
     94  assert( n == 2 * INTSIZE);
     95
    10096  return n;
    10197}
     
    107103void SynchronizeableIP::SynchronizeableIP::debug( )
    108104{
    109 //   printf( "SYNCHRONIZEABLE_VAR: %s IN: (%f, %f, %f) OUT: (%f %f %f)\n", name.c_str(), vPtrIn->x, vPtrIn->y, vPtrIn->z, vPtrOut->x, vPtrOut->y, vPtrOut->z );
     105  printf("SYNCHRONIZEABLE_VAR: %s IN: %i, %i OUT: %i, %i\n", name.c_str(), vPtrIn->host, vPtrIn->port, vPtrOut->host, vPtrOut->port);
    110106}
    111107
Note: See TracChangeset for help on using the changeset viewer.