Index: trunk/src/world_entities/environments/water.cc
===================================================================
--- trunk/src/world_entities/environments/water.cc	(revision 7796)
+++ trunk/src/world_entities/environments/water.cc	(revision 7954)
@@ -59,4 +59,10 @@
   // To test the Wave equation
   //this->wave(5.0,4.0, 1, 10);
+  
+  height_handle = registerVarId( new SynchronizeableFloat( &height, &height, "height" ) );
+  resX_handle = registerVarId( new SynchronizeableUInt( &resX, &resX, "resX" ) );
+  resY_handle = registerVarId( new SynchronizeableUInt( &resY, &resY, "resY" ) );
+  sizeX_handle = registerVarId( new SynchronizeableFloat( &sizeX, &sizeX, "sizeX" ) );
+  sizeY_handle = registerVarId( new SynchronizeableFloat( &sizeY, &sizeY, "sizeY" ) );
 }
 
@@ -291,116 +297,21 @@
 
 
-/**
- * Writes data from network containing information about the state
- * @param data pointer to data
- * @param length length of data
- * @param sender hostID of sender
- */
-int Water::writeBytes( const byte * data, int length, int sender )
-{
-  setRequestedSync( false );
-  setIsOutOfSync( false );
-
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( Water::writeState, NWT_WAT_STATE );
-
-  return SYNCHELP_READ_N;
-}
-
-
-/**
- * data copied in data will bee sent to another host
- * @param data pointer to data
- * @param maxLength max length of data
- * @return the number of bytes writen
- */
-int Water::readBytes( byte * data, int maxLength, int * reciever )
-{
-  SYNCHELP_WRITE_BEGIN();
-
-  if ( isOutOfSync() && !requestedSync() && this->getHostID()!=this->getOwner() )
-  {
-    (NetworkGameManager::getInstance())->sync( this->getUniqueID(), this->getOwner() );
-    setRequestedSync( true );
-  }
-
-  int rec = this->getRequestSync();
-  if ( rec > 0 )
-  {
-    *reciever = rec;
-    SYNCHELP_WRITE_FKT( Water::readState, NWT_WAT_STATE );
-  }
-
-  *reciever = 0;
-  return SYNCHELP_WRITE_N;
-}
-
-
-
-/**
- * data copied in data will bee sent to another host
- * @param data pointer to data
- * @param maxLength max length of data
- * @return the number of bytes writen
- */
-int Water::readState( byte * data, int maxLength )
-{
-  SYNCHELP_WRITE_BEGIN();
-
-  SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_WAT_WE_STATE );
-
-  // sync the size
-  SYNCHELP_WRITE_FLOAT( this->sizeX, NWT_WAT_SIZEX );
-  SYNCHELP_WRITE_FLOAT( this->sizeY, NWT_WAT_SIZEY );
-
-  //sync resolution
-  SYNCHELP_WRITE_INT( this->resX, NWT_WAT_RESX );
-  SYNCHELP_WRITE_INT( this->resY, NWT_WAT_RESY );
-
-  //sync the height
-  SYNCHELP_WRITE_FLOAT( this->height, NWT_WAT_HEIGHT );
-
-  return SYNCHELP_WRITE_N;
-}
-
-
-/**
- * Writes data from network containing information about the state
- * @param data pointer to data
- * @param length length of data
- * @param sender hostID of sender
- */
-int Water::writeState( const byte * data, int length, int sender )
-{
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_WAT_WE_STATE );
-
-  float f1, f2;
-  int i1, i2;
-
-  //read the size
-  SYNCHELP_READ_FLOAT( f1, NWT_WAT_SIZEX );
-  SYNCHELP_READ_FLOAT( f2, NWT_WAT_SIZEY );
-  this->sizeX = f1;
-  this->sizeY = f2;
-  PRINTF(0)("Setting Water to size: %f x %f\n", f1, f2);
-
-  //read the resolution
-  SYNCHELP_READ_INT( i1, NWT_WAT_RESX );
-  SYNCHELP_READ_INT( i2, NWT_WAT_RESY );
-  this->resX = i1;
-  this->resY = i2;
-  PRINTF(0)("Setting Water to resolution: %i x %i\n", i1, i2);
-
-  //read the height
-  SYNCHELP_READ_FLOAT( f1, NWT_WAT_HEIGHT );
-  this->height = f1;
-
-  this->rebuildGrid();
-
-  return SYNCHELP_READ_N;
-}
-
-
+
+/**
+ * function to handle changes in synced vars
+ * @param id ids which have changed
+ */
+void Water::varChangeHandler( std::list< int > & id )
+{
+  if ( std::find( id.begin(), id.end(), height_handle ) != id.end() ||
+       std::find( id.begin(), id.end(), resX_handle ) != id.end() ||
+       std::find( id.begin(), id.end(), resY_handle ) != id.end() ||
+       std::find( id.begin(), id.end(), sizeX_handle ) != id.end() ||
+       std::find( id.begin(), id.end(), sizeY_handle ) != id.end()
+     )
+  {
+    this->rebuildGrid();
+  }
+  
+  WorldEntity::varChangeHandler( id );
+}
Index: trunk/src/world_entities/environments/water.h
===================================================================
--- trunk/src/world_entities/environments/water.h	(revision 7796)
+++ trunk/src/world_entities/environments/water.h	(revision 7954)
@@ -38,10 +38,6 @@
    void draw() const;
    void tick(float dt);
-
-   virtual int writeBytes(const byte* data, int length, int sender);
-   virtual int readBytes(byte* data, int maxLength, int * reciever);
-
-   int writeState( const byte * data, int length, int sender );
-   int readState( byte * data, int maxLength );
+   
+   virtual void varChangeHandler( std::list<int> & id );
 
   private:
@@ -56,8 +52,14 @@
     Material        waterMaterial;
     Shader*         waterShader;
+    
     float           height;          //!< The hight of the Water
+    int             height_handle;   //!< Handle to notify about changes of height
 
-    unsigned int    resX, resY;
-    float           sizeX, sizeY;
+    unsigned int    resX, resY;      //!< Grid resolution
+    int             resX_handle;     //!< Handle to notify about changes of resX
+    int             resY_handle;     //!< Handle to notify about changes of resY
+    float           sizeX, sizeY;    //!< waters size
+    int             sizeX_handle;    //!< Handle to notify about changes of sizeX
+    int             sizeY_handle;    //!< Handle to notify about changes of sizeY
 
     float phase;
