Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 24, 2005, 2:15:49 PM (18 years ago)
Author:
rennerc
Message:

synchronizeable: added macros to help write/read data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/world_entities/skybox.cc

    r6273 r6275  
    218218  setIsOutOfSync( false );
    219219
    220   int flsize = Converter::byteArrayToFloat( data, &size );
    221   Converter::byteArrayToString( data+flsize, textureName, length-flsize );
    222 
    223   PRINT(0)("GOT DATA: size=%f texture=%s\n", size, textureName);
     220  /*int flsize = Converter::byteArrayToFloat( data, &size );
     221  Converter::byteArrayToString( data+flsize, textureName, length-flsize );*/
     222
     223  SYNCHELP_READ_BEGIN();
     224  SYNCHELP_READ_FLOAT(size);
     225  SYNCHELP_READ_STRING( textureName, 1024 );
     226
     227  //PRINT(0)("GOT DATA: size=%f texture=%s\n", size, textureName);
    224228
    225229  this->setSize( size );
     
    228232}
    229233
     234
     235
    230236int SkyBox::readBytes( byte * data, int maxLength, int * reciever )
    231237{
    232238  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
    233239  {
    234     PRINTF(0)("Requesting sync! %d\n", this->getUniqueID());
     240    //PRINTF(0)("Requesting sync! %d\n", this->getUniqueID());
    235241    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
    236242    setRequestedSync( true );
     
    240246  if ( rec > 0 )
    241247  {
    242     PRINTF(0)("Serving client %d which requested sync %d size=%f texture=%s\n", rec, this->getUniqueID(), this->size, this->textureName);
     248    //PRINTF(0)("Serving client %d which requested sync %d size=%f texture=%s\n", rec, this->getUniqueID(), this->size, this->textureName);
    243249    *reciever = rec;
    244250
    245     int flsize = Converter::floatToByteArray( this->size, data, maxLength );
    246 
    247     if ( flsize <= 0 )
    248     {
    249       PRINTF(1)("Byte array is too small (%d) to store float\n", maxLength );
    250       return 0;
    251     }
    252 
    253     if ( strlen(textureName)+INTSIZE+flsize > maxLength )
    254     {
    255       PRINTF(1)("Byte array is too small (%d) to store data\n", maxLength );
    256       return 0;
    257     }
    258 
    259     return flsize + Converter::stringToByteArray( textureName, data+flsize, strlen(textureName), maxLength-flsize );
    260 
     251    SYNCHELP_WRITE_BEGIN();
     252    SYNCHELP_WRITE_FLOAT(this->size);
     253    SYNCHELP_WRITE_STRING(this->textureName);
     254
     255    return SYNCHELP_WRITE_N;
    261256  }
    262257
Note: See TracChangeset for help on using the changeset viewer.