Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2006, 2:39:53 PM (18 years ago)
Author:
patrick
Message:

merged the network branche to the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/environments/water.cc

    r6684 r6695  
    2828#include "skybox.h"
    2929
     30#include "network_game_manager.h"
    3031
    3132using namespace std;
     
    238239  this->grid->rebuildNormals(this->height);
    239240}
     241
     242
     243/**
     244 * Writes data from network containing information about the state
     245 * @param data pointer to data
     246 * @param length length of data
     247 * @param sender hostID of sender
     248 */
     249int Water::writeBytes( const byte * data, int length, int sender )
     250{
     251  setRequestedSync( false );
     252  setIsOutOfSync( false );
     253
     254  SYNCHELP_READ_BEGIN();
     255
     256  SYNCHELP_READ_FKT( Water::writeState );
     257
     258  return SYNCHELP_READ_N;
     259}
     260
     261
     262/**
     263 * data copied in data will bee sent to another host
     264 * @param data pointer to data
     265 * @param maxLength max length of data
     266 * @return the number of bytes writen
     267 */
     268int Water::readBytes( byte * data, int maxLength, int * reciever )
     269{
     270  SYNCHELP_WRITE_BEGIN();
     271
     272  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
     273  {
     274    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
     275    setRequestedSync( true );
     276  }
     277
     278  int rec = this->getRequestSync();
     279  if ( rec > 0 )
     280  {
     281    *reciever = rec;
     282    SYNCHELP_WRITE_FKT( Water::readState );
     283  }
     284
     285  *reciever = 0;
     286  return SYNCHELP_WRITE_N;
     287}
     288
     289
     290
     291/**
     292 * data copied in data will bee sent to another host
     293 * @param data pointer to data
     294 * @param maxLength max length of data
     295 * @return the number of bytes writen
     296 */
     297int Water::readState( byte * data, int maxLength )
     298{
     299  SYNCHELP_WRITE_BEGIN();
     300
     301  SYNCHELP_WRITE_FKT( WorldEntity::readState );
     302
     303  // sync the size
     304  SYNCHELP_WRITE_FLOAT( this->sizeX );
     305  SYNCHELP_WRITE_FLOAT( this->sizeY );
     306
     307  //sync resolution
     308  SYNCHELP_WRITE_INT( this->resX );
     309  SYNCHELP_WRITE_INT( this->resY );
     310
     311  //sync the height
     312  SYNCHELP_WRITE_FLOAT( this->height );
     313
     314  return SYNCHELP_WRITE_N;
     315}
     316
     317
     318/**
     319 * Writes data from network containing information about the state
     320 * @param data pointer to data
     321 * @param length length of data
     322 * @param sender hostID of sender
     323 */
     324int Water::writeState( const byte * data, int length, int sender )
     325{
     326  SYNCHELP_READ_BEGIN();
     327
     328  SYNCHELP_READ_FKT( WorldEntity::writeState );
     329
     330  float f1, f2;
     331  int i1, i2;
     332
     333  //read the size
     334  SYNCHELP_READ_FLOAT( f1 );
     335  SYNCHELP_READ_FLOAT( f2 );
     336  this->sizeX = f1;
     337  this->sizeY = f2;
     338  PRINTF(0)("Setting Water to size: %f x %f\n", f1, f2);
     339
     340  //read the resolution
     341  SYNCHELP_READ_INT( i1 );
     342  SYNCHELP_READ_INT( i2 );
     343  this->resX = i1;
     344  this->resY = i2;
     345  PRINTF(0)("Setting Water to resolution: %i x %i\n", i1, i2);
     346
     347  //read the height
     348  SYNCHELP_READ_FLOAT( f1 );
     349  this->height = f1;
     350
     351  this->rebuildGrid();
     352
     353  return SYNCHELP_READ_N;
     354}
     355
     356
Note: See TracChangeset for help on using the changeset viewer.