Index: /branches/network/src/lib/coord/p_node.cc
===================================================================
--- /branches/network/src/lib/coord/p_node.cc	(revision 7443)
+++ /branches/network/src/lib/coord/p_node.cc	(revision 7444)
@@ -59,4 +59,7 @@
   if (parent != NULL)
     parent->addChild(this);
+  
+  this->relCoordinate_handle = this->registerVarId( new SynchronizeableVector( &relCoordinate, &relCoordinate_write, "coordinate" ) );
+  this->relDirection_handle = this->registerVarId( new SynchronizeableQuaternion( &relDirection, &relDirection_write, "direction" ) );
 }
 
@@ -1083,256 +1086,11 @@
 
 /**
- * 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 PNode::writeState( const byte * data, int length, int sender )
-{
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( BaseObject::writeState, NWT_PN_BO_WRITESTATE );
-
-  //   char * parentName = NULL;
-  //   SYNCHELP_READ_STRINGM( parentName );
-  //
-  //   if ( strcmp(parentName, "")==0 )
-  //   {
-  //     setParent( (char*)NULL );
-  //   }
-  //   else
-  //   {
-  //     setParent( parentName );
-  //   }
-  //
-  //  delete[] parentName;
-
-  int parentMode;
-  SYNCHELP_READ_INT( parentMode, NWT_PN_PARENTMODE );
-  this->setParentMode((PARENT_MODE)parentMode);
-
-  float f1, f2, f3, f4;
-
-  SYNCHELP_READ_FLOAT( f1, NWT_PN_COORX );
-  SYNCHELP_READ_FLOAT( f2, NWT_PN_COORY );
-  SYNCHELP_READ_FLOAT( f3, NWT_PN_COORZ );
-  this->setRelCoor( f1, f2, f3 );
-
-
-  SYNCHELP_READ_FLOAT( f1, NWT_PN_ROTV );
-  SYNCHELP_READ_FLOAT( f2, NWT_PN_ROTX );
-  SYNCHELP_READ_FLOAT( f3, NWT_PN_ROTY );
-  SYNCHELP_READ_FLOAT( f4, NWT_PN_ROTZ );
-  this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
-
-  //   int n;
-  //   char * childName;
-  //
-  //   PRINTF(0)("JKLO %d %d %d %d\n", data[__synchelp_read_i], data[__synchelp_read_i+1], data[__synchelp_read_i+2], data[__synchelp_read_i+3]);
-  //   SYNCHELP_READ_INT( n );
-  //   PRINTF(0)("read %s:n=%d\n", this->getName(), n);
-  //
-  //   for (int i = 0; i<n; i++)
-  //   {
-  //     SYNCHELP_READ_STRINGM( childName );
-  //     PRINTF(0)("RCVD CHILD = %s\n", childName);
-  //     addChild( childName );
-  //     delete childName;
-  //     childName = NULL;
-  //   }
-
-  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 PNode::readState( byte * data, int maxLength )
-{
-  SYNCHELP_WRITE_BEGIN();
-
-  SYNCHELP_WRITE_FKT( BaseObject::readState, NWT_PN_BO_WRITESTATE );
-
-  //   if ( this->parent )
-  //   {
-  //     SYNCHELP_WRITE_STRING( parent->getName() );
-  //   }
-  //   else
-  //   {
-  //     SYNCHELP_WRITE_STRING( "" );
-  //   }
-
-  SYNCHELP_WRITE_INT( this->parentMode, NWT_PN_PARENTMODE );
-
-  SYNCHELP_WRITE_FLOAT( this->relCoordinate.x, NWT_PN_COORX );
-  SYNCHELP_WRITE_FLOAT( this->relCoordinate.y, NWT_PN_COORY );
-  SYNCHELP_WRITE_FLOAT( this->relCoordinate.z, NWT_PN_COORZ );
-
-  SYNCHELP_WRITE_FLOAT( this->relDirection.w, NWT_PN_ROTV );
-  SYNCHELP_WRITE_FLOAT( this->relDirection.v.x, NWT_PN_ROTX );
-  SYNCHELP_WRITE_FLOAT( this->relDirection.v.y, NWT_PN_ROTY );
-  SYNCHELP_WRITE_FLOAT( this->relDirection.v.z, NWT_PN_ROTZ );
-
-  //   int n = children.size();
-  //   //check if camera is in children
-  //   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
-  //   {
-  //     if ( (*it)->isA(CL_CAMERA) )
-  //       n--;
-  //   }
-  //   PRINTF(0)("write %s:n=%d\n", this->getName(), n);
-  //   SYNCHELP_WRITE_INT( n );
-  //   PRINTF(0)("ASDF %d %d %d %d\n", data[__synchelp_write_i-4], data[__synchelp_write_i-3], data[__synchelp_write_i-2], data[__synchelp_write_i-1]);
-  //
-  //
-  //   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
-  //   {
-  //     //dont add camera because there is only one camera attached to local player
-  //     if ( !(*it)->isA(CL_CAMERA) )
-  //     {
-  //       PRINTF(0)("SENDING CHILD: %s\n", (*it)->getName());
-  //       SYNCHELP_WRITE_STRING( (*it)->getName() );
-  //     }
-  //   }
-
-  return SYNCHELP_WRITE_N;
-}
-
-#define __FLAG_COOR 1
-#define __FLAG_ROT  2
-
-#define __OFFSET_POS 1
-#define __OFFSET_ROT 0.05
-
-/**
- * Writes data from network containing information about the state which has changed
- * @param data pointer to data
- * @param length length of data
- * @param sender hostID of sender
- */
-int PNode::writeSync( const byte * data, int length, int sender )
-{
-  SYNCHELP_READ_BEGIN();
-
-  if ( this->getHostID()==this->getOwner() )
-  {
-    return SYNCHELP_READ_N;
-  }
-
-  byte flags = 0;
-  SYNCHELP_READ_BYTE( flags, NWT_PN_FLAGS );
-  //PRINTF(0)("%s::FLAGS = %d\n", this->getName(), flags);
-
-  float f1, f2, f3, f4;
-
-  if ( flags & __FLAG_COOR )
-  {
-    SYNCHELP_READ_FLOAT( f1, NWT_PN_SCOORX );
-    SYNCHELP_READ_FLOAT( f2, NWT_PN_SCOORY );
-    SYNCHELP_READ_FLOAT( f3, NWT_PN_SCOORZ );
-    PRINTF(0)("RCVD COOR: %f %f %f\n", f1, f2, f3);
-    this->setRelCoor( f1, f2, f3 );
-  }
-
-  if ( flags & __FLAG_ROT )
-  {
-    SYNCHELP_READ_FLOAT( f1, NWT_PN_SROTV );
-    SYNCHELP_READ_FLOAT( f2, NWT_PN_SROTX );
-    SYNCHELP_READ_FLOAT( f3, NWT_PN_SROTY );
-    SYNCHELP_READ_FLOAT( f4, NWT_PN_SROTZ );
-    PRINTF(0)("RCVD QUAT: %f %f %f %f\n", f1, f2, f3, f4);
-    //this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
-    Quaternion q;
-    q.w = f1;
-    q.v.x = f2;
-    q.v.y = f3;
-    q.v.z = f4;
-    this->setAbsDir( q );
-  }
-
-  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 PNode::readSync( byte * data, int maxLength )
-{
-  //WARNING: if you change this file make sure you also change needsReadSync
-  SYNCHELP_WRITE_BEGIN();
-
-  if ( this->getHostID()!=0 && this->getHostID()!=this->getOwner() )
-  {
-    return SYNCHELP_WRITE_N;
-  }
-
-  byte flags = 0;
-  if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS*0.05*this->velocity.len() ||
-       fabs( coory - relCoordinate.y ) > __OFFSET_POS*0.05*this->velocity.len() ||
-       fabs( coorz - relCoordinate.z ) > __OFFSET_POS*0.05*this->velocity.len() )
-    flags |= __FLAG_COOR;
-
-  if ( fabs( rotw - absDirection.w ) > __OFFSET_ROT ||
-       fabs( rotx - absDirection.v.x ) > __OFFSET_ROT ||
-       fabs( roty - absDirection.v.y ) > __OFFSET_ROT ||
-       fabs( rotz - absDirection.v.z ) > __OFFSET_ROT )
-    flags |= __FLAG_ROT;
-
-
-  SYNCHELP_WRITE_BYTE( flags, NWT_PN_FLAGS );
-  PRINTF(0)("FLAGS = %d\n", flags);
-
-  if ( flags & __FLAG_COOR )
-  {
-
-    PRINTF(0)("SEND COOR: %f %f %f\n", this->relCoordinate.x, this->relCoordinate.y, this->relCoordinate.z);
-
-    SYNCHELP_WRITE_FLOAT( this->relCoordinate.x, NWT_PN_SCOORX );
-    SYNCHELP_WRITE_FLOAT( this->relCoordinate.y, NWT_PN_SCOORY );
-    SYNCHELP_WRITE_FLOAT( this->relCoordinate.z, NWT_PN_SCOORZ );
-
-    coorx = relCoordinate.x;
-    coory = relCoordinate.y;
-    coorz = relCoordinate.z;
-  }
-
-  if ( flags & __FLAG_ROT )
-  {
-
-    PRINTF(0)("SEND QUAT: %f %f %f %f\n", this->absDirection.w, this->absDirection.v.x, this->absDirection.v.y, this->absDirection.v.z);
-
-    SYNCHELP_WRITE_FLOAT( this->absDirection.w, NWT_PN_SROTV );
-    SYNCHELP_WRITE_FLOAT( this->absDirection.v.x, NWT_PN_SROTX );
-    SYNCHELP_WRITE_FLOAT( this->absDirection.v.y, NWT_PN_SROTY );
-    SYNCHELP_WRITE_FLOAT( this->absDirection.v.z, NWT_PN_SROTZ );
-
-    rotw = absDirection.w;
-    rotx = absDirection.v.x;
-    roty = absDirection.v.y;
-    rotz = absDirection.v.z;
-  }
-
-  return SYNCHELP_WRITE_N;
-}
-
-bool PNode::needsReadSync( )
-{
-  if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS*0.05*this->velocity.len() ||
-       fabs( coory - relCoordinate.y ) > __OFFSET_POS*0.05*this->velocity.len() ||
-       fabs( coorz - relCoordinate.z ) > __OFFSET_POS*0.05*this->velocity.len() )
-    return true;
-
-  if ( fabs( rotw - absDirection.w ) > __OFFSET_ROT ||
-       fabs( rotx - absDirection.v.x ) > __OFFSET_ROT ||
-       fabs( roty - absDirection.v.y ) > __OFFSET_ROT ||
-       fabs( rotz - absDirection.v.z ) > __OFFSET_ROT )
-    return true;
-
-  return false;
-}
+ * handles changes in synchronizable variables
+ * @param id id's which changed
+ */
+void PNode::varChangeHandler( std::list< int > & id )
+{
+#warning implement this
+}
+
+
Index: /branches/network/src/lib/coord/p_node.h
===================================================================
--- /branches/network/src/lib/coord/p_node.h	(revision 7443)
+++ /branches/network/src/lib/coord/p_node.h	(revision 7444)
@@ -187,10 +187,4 @@
   float distance(const PNode* node) const { return (this->getAbsCoor() - node->getAbsCoor()).len(); };
 
-  int       writeState(const byte* data, int length, int sender);
-  int       readState(byte* data, int maxLength );
-  int       writeSync(const byte* data, int length, int sender);
-  int       readSync(byte* data, int maxLength );
-  bool      needsReadSync();
-
  private:
   /** tells the child that the parent's Coordinate has changed */
@@ -244,4 +238,13 @@
     float roty;
     float rotz;
+    
+  private:
+    int relCoordinate_handle;
+    int relDirection_handle;
+    Vector relCoordinate_write;
+    Quaternion relDirection_write;
+    
+  public:
+    virtual void varChangeHandler( std::list<int> & id );
 };
 
Index: /branches/network/src/lib/lang/base_object.cc
===================================================================
--- /branches/network/src/lib/lang/base_object.cc	(revision 7443)
+++ /branches/network/src/lib/lang/base_object.cc	(revision 7444)
@@ -177,33 +177,2 @@
 
 }
-
-/**
- * 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 BaseObject::writeState( const byte * data, int length, int sender )
-{
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_STRING( this->objectName, NWT_BO_NAME );
-
-  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 BaseObject::readState( byte * data, int maxLength )
-{
-  SYNCHELP_WRITE_BEGIN();
-
-  //PRINTF(0)("objectname = %s\n", this->objectName);
-  SYNCHELP_WRITE_STRING( this->objectName, NWT_BO_NAME );
-
-  return SYNCHELP_WRITE_N;
-}
Index: /branches/network/src/lib/lang/base_object.h
===================================================================
--- /branches/network/src/lib/lang/base_object.h	(revision 7443)
+++ /branches/network/src/lib/lang/base_object.h	(revision 7444)
@@ -51,14 +51,11 @@
   bool operator==(ClassID classID) { return this->isA(classID); };
 
-  int       writeState(const byte* data, int length, int sender);
-  int       readState(byte* data, int maxLength );
-
  protected:
    void setClassID(ClassID classID, const std::string& className);
+   std::string        objectName;        //!< The name of this object
 
  private:
     std::string        className;        //!< the name of the class
     long               classID;          //!< this is the id from the class_id.h enumeration
-    std::string        objectName;       //!< The name of this object
 
     ClassList*         classList;        //!< Pointer to the ClassList this Object is inside of
Index: /branches/network/src/lib/network/Makefile.am
===================================================================
--- /branches/network/src/lib/network/Makefile.am	(revision 7443)
+++ /branches/network/src/lib/network/Makefile.am	(revision 7444)
@@ -15,5 +15,14 @@
 		      handshake.cc \
 		      network_game_manager.cc \
-		      converter.cc
+		      converter.cc \
+		      \
+		      synchronizeable_var/synchronizeable_var.cc \
+		      synchronizeable_var/synchronizeable_vector.cc \
+		      synchronizeable_var/synchronizeable_int.cc \
+		      synchronizeable_var/synchronizeable_quaternion.cc \
+		      synchronizeable_var/synchronizeable_string.cc \
+		      synchronizeable_var/synchronizeable_float.cc \
+		      synchronizeable_var/synchronizeable_bool.cc \
+		      synchronizeable_var/synchronizeable_uint.cc 
 
 
@@ -32,5 +41,14 @@
 		 network_game_manager.h \
 		 converter.h \
-		 netdefs.h
+		 netdefs.h \
+		 \
+		 synchronizeable_var/synchronizeable_var.h \
+		 synchronizeable_var/synchronizeable_vector.h \
+		 synchronizeable_var/synchronizeable_int.h \
+		 synchronizeable_var/synchronizeable_quaternion.h \
+		 synchronizeable_var/synchronizeable_string.h \
+		 synchronizeable_var/synchronizeable_float.h \
+		 synchronizeable_var/synchronizeable_bool.h \
+		 synchronizeable_var/synchronizeable_uint.h
 
 
Index: /branches/network/src/lib/network/handshake.cc
===================================================================
--- /branches/network/src/lib/network/handshake.cc	(revision 7443)
+++ /branches/network/src/lib/network/handshake.cc	(revision 7444)
@@ -31,9 +31,15 @@
 
   this->setIsServer(server);
-  this->clientId = clientId;
-  this->networkGameManagerId = networkGameManagerId;
-  this->state = 0;
-  this->isOk = false;
-  this->setOwner(0);
+  this->localState.hostId = clientId;
+  this->localState.networkManagerId = networkGameManagerId;
+ 
+  orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId" ) );
+  version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version" ) );
+  netManId_handler = registerVarId( new SynchronizeableInt( &localState.networkManagerId, &remoteState.networkManagerId, "networkManagerId" ) );
+  hostId_handler = registerVarId( new SynchronizeableInt( &localState.hostId, &remoteState.hostId, "hostId" ) );
+  completed_handler = registerVarId( new SynchronizeableInt( &localState.completed, &remoteState.completed, "completed" ) );
+  error_handler = registerVarId( new SynchronizeableInt( &localState.error, &remoteState.error, "error" ) );
+  errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString" ) );
+
 
   this->setSynchronized(true);
@@ -41,165 +47,10 @@
 }
 
-int Handshake::writeBytes( const byte * data, int length, int sender)
-{
-  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);
-
-  SYNCHELP_READ_BEGIN();
-
-  if ( hasState( HS_COMPLETED ) )
-       return 0;
-
-  if ( !hasState( HS_RECVD_INIT ) )
-  {
-    if ( length != _INITIAL_DATA_LENGTH )
-    {
-      PRINTF(0)("initial packet has wrong size %d instead of %d\n", length, _INITIAL_DATA_LENGTH);
-      setState( HS_COMPLETED );
-      return 0;
-    }
-
-    if ( strncmp((char*)data, _INITIAL_DATA, length) )
-    {
-      PRINTF(0)("initial packed does not match\n");
-      setState( HS_COMPLETED );
-      return length;
-    }
-
-    setState( HS_RECVD_INIT );
-    PRINTF(0)("got valid initial packet from client %d\n", clientId);
-    return length;
-  }
-
-  if ( hasState( HS_RECVD_INIT ) && !hasState( HS_RECVD_VER ) )
-  {
-    if ( length != _ORXONOX_VERSION_LENGTH )
-    {
-      PRINTF(0)("version number packet has wrong size %d instead of %d\n", length, _ORXONOX_VERSION_LENGTH);
-      setState( HS_COMPLETED );
-      return 0;
-    }
-
-    if ( strncmp((char*)data, _ORXONOX_VERSION, length) )
-    {
-      PRINTF(0)("versions do not match\n");
-      setState( HS_COMPLETED );
-      return length;
-    }
-
-    setState( HS_RECVD_VER );
-
-    PRINTF(0)("client %d's version does match\n", clientId);
-    return length;
-  }
-
-  if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) )
-  {
-    /*if ( length != INTSIZE+INTSIZE )
-    {
-      PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, INTSIZE+INTSIZE);
-      setState( HS_COMPLETED );
-      return 0;
-  }*/
-
-    setState( HS_COMPLETED );
-    setState( HS_RECVD_HID );
-    this->isOk = true;
-    SYNCHELP_READ_INT( this->newHostId, NWT_HS_HOST_ID );
-    SYNCHELP_READ_INT( this->newNetworkGameManagerId, NWT_HS_NGM_ID );
-
-    if ( newHostId == 0 )
-    {
-      setState( HS_WAS_REJECT );
-      isOk = false;
-      PRINTF(0)("Server did not accept handshake!\n");
-    }
-    else
-    {
-      PRINTF(0)("got my hostID: %d and networkGameManagerId: %d\n", newHostId, newNetworkGameManagerId);
-    }
-    return SYNCHELP_READ_N;
-  }
-
-}
-
-int Handshake::readBytes( byte * data, int maxLength, int * reciever )
-{
-  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);
-
-  SYNCHELP_WRITE_BEGIN();
-
-  if ( hasState( HS_COMPLETED ) )
-    return 0;
-
-  if ( !hasState( HS_SENT_INIT ) )
-  {
-    if ( maxLength < _INITIAL_DATA_LENGTH )
-    {
-      PRINTF(0)("buffer too small for _INITIAL_DATA");
-      setState( HS_COMPLETED );
-      return 0;
-    }
-
-    setState( HS_SENT_INIT );
-    memcpy(data, _INITIAL_DATA, _INITIAL_DATA_LENGTH);
-    if ( this->isServer() )
-      *reciever = clientId;
-    return _INITIAL_DATA_LENGTH;
-  }
-
-  if ( hasState( HS_RECVD_INIT ) && hasState( HS_SENT_INIT ) && !hasState( HS_SENT_VER ) )
-  {
-    if ( maxLength < _ORXONOX_VERSION_LENGTH )
-    {
-      PRINTF(0)("buffer too small for version number");
-      setState( HS_COMPLETED );
-      return 0;
-    }
-
-    setState( HS_SENT_VER );
-    memcpy(data, _ORXONOX_VERSION, _ORXONOX_VERSION_LENGTH);
-    if ( this->isServer() )
-      *reciever = clientId;
-    return _ORXONOX_VERSION_LENGTH;
-  }
-
-  if ( isServer() && hasState( HS_RECVD_VER) && hasState( HS_SENT_VER ) && !hasState( HS_SENT_HID ) )
-  {
-    if ( maxLength < 2 )
-    {
-      PRINTF(0)("buffer too small for ID");
-      setState( HS_COMPLETED );
-      return 0;
-    }
-
-    setState( HS_SENT_HID );
-    setState( HS_COMPLETED );
-
-    if ( hasState( HS_DO_REJECT ) )
-    {
-      isOk = false;
-      //memcpy(data, (byte*)0, 4);
-      SYNCHELP_WRITE_INT( 0, NWT_HS_HOST_ID);
-      SYNCHELP_WRITE_INT( 0, NWT_HS_NGM_ID);
-    }
-    else
-    {
-      isOk = true;
-      //memcpy(data, &clientId, 4);
-      SYNCHELP_WRITE_INT( clientId, NWT_HS_HOST_ID );
-      SYNCHELP_WRITE_INT( networkGameManagerId, NWT_HS_NGM_ID );
-    }
-    *reciever = clientId;
-    return SYNCHELP_WRITE_N;
-  }
-
-  return 0;
-}
-
-void Handshake::writeDebug( ) const
+/**
+ * handler for changes in synced vars
+ * @param id id's which have changed
+ */
+void Handshake::varChangeHandler( std::list< int > & id )
 {
 }
 
-void Handshake::readDebug( ) const
-{
-}
Index: /branches/network/src/lib/network/handshake.h
===================================================================
--- /branches/network/src/lib/network/handshake.h	(revision 7443)
+++ /branches/network/src/lib/network/handshake.h	(revision 7444)
@@ -10,23 +10,20 @@
 #include "synchronizeable.h"
 
-#define _INITIAL_DATA "orxonox"
-#define _INITIAL_DATA_LENGTH 7
+#define _INITIAL_DATA 0xF91337A0
 
-#define _ORXONOX_VERSION "\x00\x00\x00\x01"
-#define _ORXONOX_VERSION_LENGTH 4
+#define _ORXONOX_VERSION 1
 
-typedef enum HandshakeState {
-  HS_SENT_INIT  = 0x00000001,
-  HS_RECVD_INIT = 0x00000002,
-  HS_SENT_VER   = 0x00000004,
-  HS_RECVD_VER  = 0x00000008,
-  HS_SENT_HID   = 0x00000010,
-  HS_RECVD_HID  = 0x00000020,
-  HS_COMPLETED  = 0x00000040,
-
-  HS_DO_REJECT  = 0x00010000,
-  HS_WAS_REJECT = 0x00020000,
-
-  NUM_STATES
+struct HandshakeState {
+  int orxId;
+  int version;
+  
+  int networkManagerId;
+  int hostId;
+  
+  int completed;
+  
+  int error;
+  
+  std::string errorString;
 };
 
@@ -34,28 +31,24 @@
 {
   public:
-    Handshake(bool server, int clientId = 0, int networkGameManagerId = 0);
-    inline bool       completed(){ return hasState( HS_COMPLETED ); }
-    inline bool       ok(){ return isOk; }
-    inline int        getHostId(){ return newHostId; }
-    inline int        getNetworkGameManagerId(){ return newNetworkGameManagerId; }
-
-    inline void       doReject(){ setState(HS_DO_REJECT); }
-
-    virtual int       writeBytes(const byte* data, int length, int sender);
-    virtual int       readBytes(byte* data, int maxLength, int * reciever);
-    virtual void      writeDebug() const;
-    virtual void      readDebug() const;
+    Handshake( bool server, int clientId = 0, int networkGameManagerId = 0 );
+    inline bool       completed(){ return localState.completed != 0 && remoteState.completed != 0; }
+    inline bool       ok(){ return localState.error == 0 && remoteState.error == 0; }
+    inline int        getHostId(){ return localState.hostId; }
+    inline int        getNetworkGameManagerId(){ return localState.networkManagerId; }
+    inline void       doReject( std::string reason ){ remoteState.error = 1; remoteState.errorString = "the server rejected your connection ["+ reason +"]"; }
+    
+    virtual void varChangeHandler( std::list<int> & id );
 
   private:
-    int               state;
-    int               clientId;
-    int               networkGameManagerId;
-    int               newHostId;
-    int               newNetworkGameManagerId;
-    bool              isOk;
-
-    inline bool       hasState( int a ){ return (state & a) == a; }
-    inline void       setState( int a ){ state = state | a; }
-    inline void       unsetState( int a ){ state = state & (~a); }
+    HandshakeState localState;
+    HandshakeState remoteState;
+    
+    int netManId_handler;
+    int hostId_handler;
+    int completed_handler;
+    int error_handler;
+    int errorString_handler;
+    int orxId_handler;
+    int version_handler;
 
 };
Index: /branches/network/src/lib/network/network_game_manager.cc
===================================================================
--- /branches/network/src/lib/network/network_game_manager.cc	(revision 7443)
+++ /branches/network/src/lib/network/network_game_manager.cc	(revision 7444)
@@ -141,10 +141,4 @@
     {
       sendEntityList( sender );
-      continue;
-    }
-    else if ( b == NET_REQUEST_SYNC )
-    {
-      if ( !handleRequestSync( i, data, length, sender ) )
-        return i;
       continue;
     }
@@ -532,6 +526,5 @@
     s->setSynchronized(true);
     //this->networkStream->connectSynchronizeable( *s );
-    if ( !isServer() )
-      s->setIsOutOfSync( true );
+
     PRINTF(0)("Fabricated %s with id %d\n", s->getClassName(), s->getUniqueID());
 
@@ -601,25 +594,4 @@
 }
 
-/**
- * Tell the synchronizeable that a user's synchronizeable is out of sync
- * @param uniqueID: unique ID assigned with the entity which is out of sync
- * @param userID: user ID who's synchronizeable is out of sync
- */
-void NetworkGameManager::doRequestSync( int uniqueID, int userID )
-{
-  SynchronizeableList::const_iterator it,e;
-  it = this->networkStream->getSyncBegin();
-  e = this->networkStream->getSyncEnd();
-
-  while ( it != e )
-  {
-    if ( (*it)->getUniqueID() == uniqueID )
-    {
-      (*it)->requestSync( userID );
-      break;
-    }
-    it++;
-  }
-}
 
 /**
@@ -697,6 +669,4 @@
   assert(player != NULL);
 
-  s->setIsOutOfSync( true );
-
   PRINTF(0)("uniqueID = %d\n", s->getUniqueID());
 
@@ -902,21 +872,4 @@
   return true;
 }
-
-bool NetworkGameManager::handleRequestSync( int & i, const byte * data, int length, int sender )
-{
-  if ( INTSIZE > length-i )
-  {
-    PRINTF(1)("Cannot read uniqueID from buffer! Not enough data left!\n");
-    return false;
-  }
-  int uniqueID;
-  i += Converter::byteArrayToInt( &data[i], &uniqueID );
-
-  PRINTF(0)("handleRequestSync %d %d\n", uniqueID, sender);
-  doRequestSync( uniqueID, sender );
-
-  return true;
-}
-
 
 /**
@@ -986,25 +939,3 @@
 }
 
-void NetworkGameManager::sync( int uniqueID, int owner )
-{
-  /*if ( owner==this->getHostID() )
-  return;*/
-
-  if ( !isServer() )
-    executeRequestSync( uniqueID, 0 );
-  else
-    executeRequestSync( uniqueID, owner );
-}
-
-void NetworkGameManager::executeRequestSync( int uniqueID, int user )
-{
-  PRINTF(0)("executeRequestSync %d %d\n", uniqueID, user);
-  if ( user >= outBuffer.size() )
-    resizeBufferVector( user );
-
-  if ( !writeToClientBuffer( outBuffer[user], (byte)NET_REQUEST_SYNC ) )
-    return;
-  if ( !writeToClientBuffer( outBuffer[user], uniqueID ) )
-    return;
-}
-
+
Index: /branches/network/src/lib/network/network_game_manager.h
===================================================================
--- /branches/network/src/lib/network/network_game_manager.h	(revision 7443)
+++ /branches/network/src/lib/network/network_game_manager.h	(revision 7444)
@@ -35,8 +35,4 @@
  *
  *  REQUEST_ENTITY_LIST: //request the whole world :D
- *  REQUEST_SYNC:        >> UNIQUE_ID
- *                       << [Sync Info]
- *  //REQUEST_SYNC_LIST:   NUMBER, [UNIQUE_ID][0..NUMBER]
- *
  *  YOU_ARE_ENTITY:      >> UNIQUE_ID
  *
@@ -54,5 +50,4 @@
   NET_REQUEST_CREATE,
   NET_REQUEST_REMOVE,
-  NET_REQUEST_SYNC,
   NET_YOU_ARE_ENTITY,
   NET_REQUEST_ENTITY_LIST,
@@ -91,6 +86,4 @@
     void sendYouAre( int uniqueID, int userID );
 
-    void sync(int uniqueID, int owner);
-
     void sendEntityList(int userID);
 
@@ -111,5 +104,4 @@
     bool handleRemoveEntityList( int& i, const byte* data, int length, int sender );
     bool handleYouAreEntity( int& i, const byte* data, int length, int sender );
-    bool handleRequestSync( int& i, const byte* data, int length, int sender );
     bool handleRequestPNodePath(int& i, const byte* data, int length, int sender);
     bool handleSendPNodePath(int& i, const byte* data, int length, int sender);
@@ -124,7 +116,4 @@
     void executeRemoveEntity(int uniqueID);
     void doRemoveEntity(int uniqueID);
-
-    void executeRequestSync( int uniqueID, int user );
-    void doRequestSync(int uniqueID, int userID);
 
     void doYouAre( int uniqueID );
Index: /branches/network/src/lib/network/network_stream.cc
===================================================================
--- /branches/network/src/lib/network/network_stream.cc	(revision 7443)
+++ /branches/network/src/lib/network/network_stream.cc	(revision 7444)
@@ -250,5 +250,8 @@
 
         reciever = 0;
-        dataLength = (*it)->readBytes(downBuffer, DATA_STREAM_BUFFER_SIZE, &reciever);
+#warning fix this
+dataLength = 0;
+//TODO fix
+        //dataLength = (*it)->readBytes(downBuffer, DATA_STREAM_BUFFER_SIZE, &reciever);
 
         if ( dataLength<=0 ){
@@ -345,4 +348,6 @@
         for (SynchronizeableList::iterator it = synchronizeables.begin(); it!=synchronizeables.end(); it++)
         {
+#warning fix this
+#if 0
           if ( *it && (*it)->getUniqueID()==header.synchronizeableID )
           {
@@ -354,4 +359,5 @@
             continue;
           }
+#endif
         }
 
@@ -388,5 +394,5 @@
     if ( clientId > this->maxConnections )
     {
-      handshakes[clientId]->doReject();
+      handshakes[clientId]->doReject( "too many connections" );
       PRINTF(0)("Will reject client %d because there are to many connections!\n", clientId);
     }
Index: /branches/network/src/lib/network/synchronizeable.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable.cc	(revision 7443)
+++ /branches/network/src/lib/network/synchronizeable.cc	(revision 7444)
@@ -36,11 +36,8 @@
   this->setClassID(CL_SYNCHRONIZEABLE, "Synchronizeable");
   this->owner = -1;
-  this->state = 0;
   this->hostID = SharedNetworkData::getInstance()->getHostID();
   this->setIsServer(this->hostID == 0);
   this->uniqueID = NET_UID_UNASSIGNED;
   this->networkStream = NULL;
-  this->setRequestedSync( false );
-  this->setIsOutOfSync( !(this->isServer()) );
   this->bSynchronize = false;
 
@@ -52,4 +49,6 @@
     this->setUniqueID(SharedNetworkData::getInstance()->getNewUniqueID());
   }
+  
+  this->registerVar( new SynchronizeableString( &this->objectName, &this->objectName, "objectName" ) );
 }
 
@@ -64,31 +63,4 @@
     this->networkStream->disconnectSynchronizeable(*this);
 }
-
-
-/**
- *  write data to NetworkStream
- */
-int Synchronizeable::writeBytes(const byte* data, int length, int sender)
-{
-  PRINTF(5)("Synchronizeable::writeBytes was called\n");
-}
-
-
-/**
- *  read data from NetworkStream
- */
-int Synchronizeable::readBytes(byte* data, int maxLength, int * reciever)
-{
-  PRINTF(5)("Synchronizeable::readBytes was called\n");
-}
-
-
-void Synchronizeable::writeDebug() const
-{}
-
-
-void Synchronizeable::readDebug() const
-{}
-
 
 /**
@@ -106,18 +78,4 @@
 
 /**
- * Sets the outofsync flag to a given value
- * @param outOfSync: the boolean value which the outofsync flag is to set to
- */
-void Synchronizeable::setIsOutOfSync(bool outOfSync)
-{
-  if( outOfSync )
-    this->state = this->state | STATE_OUTOFSYNC;
-  else
-    this->state = this->state & (~STATE_OUTOFSYNC);
-  //PRINTF(0)("isoutofsync %s %d\n", this->getClassName(), state);
-}
-
-
-/**
  * Determines if the server flag is set
  * @return true, if the server flag is true, false else
@@ -130,35 +88,59 @@
 
 /**
- * Determines if the outofsync flag is set
- * @return true, if the outofsync flag is true, false else
+ * get the diff to last acked state of userId
+ * @param userId user to create diff for
+ * @param data buffer to copy diff in
+ * @param maxLength max bytes to copy into data
+ * @param stateId id of current state
+ * @param priorityTH tells getStateDiff to not send element with priority \< priorityTH
+ * @return n bytes copied into data
  */
-bool Synchronizeable::isOutOfSync()
+int Synchronizeable::getStateDiff( int userId, byte* data, int maxLength, int stateId, int priorityTH )
 {
-  return (this->state & STATE_OUTOFSYNC) >0;
+#warning implement this
+}
+
+/**
+ * sets a new state out of a diff created on another host
+ * @param userId hostId of user who send me that diff
+ * @param data pointer to diff
+ * @param length length of diff
+ * @param stateId id of current state
+ * @return true on success
+ */
+bool Synchronizeable::setStateDiff( int userId, byte* data, int length, int stateId )
+{
+#warning implement this
+}
+
+ /**
+ * override this function to be notified on change
+ * of your registred variables.
+ * @param id id's which have changed
+ */
+void varChangeHandler( std::list<int> & id )
+{
+#warning implement this
+}
+
+/**
+ * registers a varable to be synchronized over network
+ * @param var see src/lib/network/synchronizeable_var/ for available classes
+ */
+void Synchronizeable::registerVar( SynchronizeableVar * var )
+{
+#warning implement this
+}
+
+/**
+ * registers a varable to be synchronized over network
+ * return value is passed to varChangeHandler on change
+ * @param var see src/lib/network/synchronizeable_var/ for available classes
+ * @return handle passed to varChangeHandler on changes
+ */
+int Synchronizeable::registerVarId( SynchronizeableVar * var )
+{
+#warning implement this
 }
 
 
-/**
- * Determines if the requestedSync flag is set
- * @return true, if the requestedSync flag is true, false else
- */
-bool Synchronizeable::requestedSync()
-{
-  return (this->state & STATE_REQUESTEDSYNC) >0;
-}
-
-
-/**
- * Sets the requestedsync flag to a given value
- * @param requestedSync: the boolean value which the requestedsync flag is to set to
- */
-void Synchronizeable::setRequestedSync( bool requestedSync )
-{
-  if( requestedSync )
-    this->state = this->state | STATE_REQUESTEDSYNC;
-  else
-    this->state = this->state & (~STATE_REQUESTEDSYNC);
-}
-
-
-
Index: /branches/network/src/lib/network/synchronizeable.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable.h	(revision 7443)
+++ /branches/network/src/lib/network/synchronizeable.h	(revision 7444)
@@ -1,4 +1,4 @@
 /*!
- * @file connection_monitor.h
+ * @file synchronizeable.h
     \brief interface for all classes that have to be synchronized
  */
@@ -10,5 +10,14 @@
 #include "netdefs.h"
 #include "converter.h"
-
+#include "vector.h"
+#include "quaternion.h"
+#include "synchronizeable_var/synchronizeable_var.h"
+#include "synchronizeable_var/synchronizeable_vector.h"
+#include "synchronizeable_var/synchronizeable_quaternion.h"
+#include "synchronizeable_var/synchronizeable_string.h"
+#include "synchronizeable_var/synchronizeable_int.h"
+#include "synchronizeable_var/synchronizeable_float.h"
+#include "synchronizeable_var/synchronizeable_bool.h"
+#include "synchronizeable_var/synchronizeable_uint.h"
 
 
@@ -18,285 +27,13 @@
 //State constants: They have to be of the form 2^n
 #define STATE_SERVER 1
-#define STATE_OUTOFSYNC 2
-#define STATE_REQUESTEDSYNC 4
 
 enum {
-  NWT_SS_WE_STATE = 1000000,
-  NWT_SS_B,
-  NWT_SS_FLAGS,
-  NWT_SS_MOUSEDIRX,
-  NWT_SS_MOUSEDIRY,
-  NWT_SS_MOUSEDIRZ,
-  NWT_SS_MOUSEDIRW,
-  NWT_SS_PN_SYNC,
-  NWT_SS_VELX,
-  NWT_SS_VELY,
-  NWT_SS_VELZ,
-  NWT_SS_PL_SYNC,
-  NWT_SS_CO_N,
-  NWT_SS_CO_CLID,
-
-  NWT_HS_HOST_ID,
-  NWT_HS_NGM_ID,
-
-  NWT_PL_B,
-  NWT_PL_FLAGS,
-  NWT_PL_SCORE,
-
-  NWT_PN_BO_WRITESTATE,
-  NWT_PN_PARENTMODE,
-  NWT_PN_COORX,
-  NWT_PN_COORY,
-  NWT_PN_COORZ,
-  NWT_PN_ROTX,
-  NWT_PN_ROTY,
-  NWT_PN_ROTZ,
-  NWT_PN_ROTV,
-
-  NWT_PN_FLAGS,
-  NWT_PN_SCOORX,
-  NWT_PN_SCOORY,
-  NWT_PN_SCOORZ,
-  NWT_PN_SROTX,
-  NWT_PN_SROTY,
-  NWT_PN_SROTZ,
-  NWT_PN_SROTV,
-
-  NWT_BO_NAME,
-
-  NWT_WE_PN_WRITESTATE,
-  NWT_WE_PN_MODELFILENAME,
-  NWT_WE_PN_SCALING,
-
-  NWT_GT_WE_STATE,
-
-  NWT_SB_WE_STATE,
-  NWT_SB_SIZE,
-  NWT_SB_TEXTURENAME,
-
-  NWT_TER_WE_STATE,
-
-  NWT_PU_WE_STATE,
-
-  NWT_TPU_WE_STATE,
-
-  NWT_LPU_WE_STATE,
-
-  NWT_WPU_WE_STATE,
-
-  NWT_PPU_WE_STATE,
-  NWT_PPU_TYPE,
-  NWT_PPU_VALUE,
-  NWT_PPU_MINVALUE,
-  NWT_PPU_MAXVALUE,
-
-  NWT_WAT_STATE,
-  NWT_WAT_WE_STATE,
-  NWT_WAT_SIZEX,
-  NWT_WAT_SIZEY,
-  NWT_WAT_RESX,
-  NWT_WAT_RESY,
-  NWT_WAT_HEIGHT
+  PERMISSION_OWNER = 1,
+  PERMISSION_ALL   = 2
 };
 
-
-//macros to help writing data in byte buffer
-/*
- * Important: these macros must be used in
- *     SYNCHELP_READ_*:  virtual void      writeBytes(const byte* data, int length, int sender);
- *     SYNCHELP_WRITE_*: virtual int       readBytes(byte* data, int maxLength, int * reciever);
- * with the same argument names!
- *
- * id is one int out of that enum on top of this comment it is used to identify
- * read/write. when you read a value you have to use exactly the same as you used
- * to write or you will see an assertion failing.
- *
- * SYNCHELP_WRITE_BEGIN()
- * SYNCHELP_WRITE_INT(i,id)
- * SYNCHELP_WRITE_FLOAT(f,id)
- * SYNCHELP_WRITE_BYTE(b,id)
- * SYNCHELP_WRITE_STRING(s,id)
- * SYNCHELP_WRITE_N
- *
- * SYNCHELP_READ_BEGIN()
- * SYNCHELP_READ_INT(i,id)
- * SYNCHELP_READ_FLOAT(f,id)
- * SYNCHELP_READ_STRING(s,l,id) l = size of buffer s
- * SYNCHELP_READ_STRINGM(s,id)  allocates memory for string! you have to delete this later
- * SYNCHELP_READ_BYTE(b,id)
- * SYNCHELP_READ_REMAINING() returns the remaining buffer size
- * SYNCHELP_READ_NEXTBYTE()  reads the next byte but it is not removed from the buffer
- * SYNCHELP_READ_N
- *
- *
- *
- * Example 1:
- *  SYNCHELP_READ_BEGIN();
- *  SYNCHELP_READ_FLOAT(size);
- *  SYNCHELP_READ_STRING( textureName, 1024 ); //1024 is the length of textureName
- *  delete[] textureName;
- *  textureName = NULL;
- *  SYNCHELP_READ_STRINGM( texturename );      //this will call new char[strlen()+1]
- *
- * Example 2:
- *  SYNCHELP_WRITE_BEGIN();
- *  SYNCHELP_WRITE_FLOAT(this->size);
- *  SYNCHELP_WRITE_STRING(this->textureName);
- *  return SYNCHELP_WRITE_N;
- *
- */
-
-#define SYNCHELP_WRITE_DEBUG(n) {\
-  __synchelp_write_n = Converter::intToByteArray( n, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
-  assert( __synchelp_write_n == INTSIZE ); \
-  __synchelp_write_i += __synchelp_write_n; \
-}
-
-#define SYNCHELP_READ_DEBUG(n) {  \
-  int nn; \
-  __synchelp_read_n = Converter::byteArrayToInt( data+__synchelp_read_i, &nn );  \
-  assert( __synchelp_read_n == INTSIZE ); \
-  if ( n != nn ) { \
-    PRINTF(1)("Check your code! read/writes not in right order! read %d instead of %d\n", nn, n); \
-    assert( false ); \
-  } \
-  __synchelp_read_i += __synchelp_read_n; \
-}
-
-#define SYNCHELP_WRITE_BEGIN()    int __synchelp_write_i = 0; \
-                                  int __synchelp_write_n
-#define SYNCHELP_WRITE_INT(i,n) { SYNCHELP_WRITE_DEBUG(n); \
-                                __synchelp_write_n = \
-                                Converter::intToByteArray( i, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
-                                assert( __synchelp_write_n == INTSIZE ); \
-                                if ( __synchelp_write_n <= 0) \
-{ \
-                                  PRINTF(1)("Buffer is too small to store a int\n"); \
-                                  return 0; \
-} \
-                                __synchelp_write_i += __synchelp_write_n; \
-}
-#define SYNCHELP_WRITE_FLOAT(f,n) { SYNCHELP_WRITE_DEBUG(n); \
-                                __synchelp_write_n = \
-                                Converter::floatToByteArray( f, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
-                                assert( __synchelp_write_n == FLOATSIZE ); \
-                                if ( __synchelp_write_n <= 0) \
-{ \
-                                  PRINTF(1)("Buffer is too small to store a float\n"); \
-                                  return 0; \
-} \
-                                __synchelp_write_i += __synchelp_write_n; \
-}
-#define SYNCHELP_WRITE_BYTE(b,n) { SYNCHELP_WRITE_DEBUG(n); \
-                                \
-                                if (maxLength - __synchelp_write_i < 1) \
-{ \
-                                  PRINTF(1)("Buffer is too small to store string\n"); \
-                                  return 0; \
-} \
-                                data[__synchelp_write_i] = b; \
-                                __synchelp_write_i++; \
-}
-#define SYNCHELP_WRITE_STRING(s,n) { SYNCHELP_WRITE_DEBUG(n); \
-                                __synchelp_write_n = \
-                                Converter::stringToByteArray( s, data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
-                                assert( __synchelp_write_n == ((std::string)s).length()+INTSIZE ); \
-                                if ( __synchelp_write_n <= 0) \
-{ \
-                                  PRINTF(1)("Buffer is too small to store string\n"); \
-                                  return 0; \
-} \
-                                __synchelp_write_i += __synchelp_write_n; \
-}
-#define SYNCHELP_WRITE_N        __synchelp_write_i
-#define SYNCHELP_WRITE_FKT(f,n)   { SYNCHELP_WRITE_DEBUG(n); \
-                                  PRINTF(0)("calling %s with %d left\n", #f, maxLength - __synchelp_write_i);  \
-                                  byte * spos = data+__synchelp_write_i;  \
-                                  if (maxLength - __synchelp_write_i < INTSIZE) \
-{ \
-                                    PRINTF(1)("Buffer is too small to store more data\n"); \
-                                    return 0; \
-} \
-                                  __synchelp_write_i += INTSIZE; \
-                                  __synchelp_write_n = \
-                                  f( data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
-                                  __synchelp_write_i += __synchelp_write_n;  \
-                                  Converter::intToByteArray( __synchelp_write_n, spos, INTSIZE ); \
-                                }
-
-
-#define SYNCHELP_READ_BEGIN()     int __synchelp_read_i = 0; \
-                                  int __synchelp_read_n
-
-#define SYNCHELP_READ_INT(i,n)       { SYNCHELP_READ_DEBUG(n); \
-                                    if ( length-__synchelp_read_i < INTSIZE ) \
-{ \
-                                      PRINTF(1)("There is not enough data to read an int\n");  \
-                                      return 0; \
-} \
-                                    __synchelp_read_n = Converter::byteArrayToInt( data+__synchelp_read_i, &i );  \
-                                    assert( __synchelp_read_n == INTSIZE ); \
-                                    __synchelp_read_i += __synchelp_read_n; \
-}
-#define SYNCHELP_READ_FLOAT(f,n)    { SYNCHELP_READ_DEBUG(n); \
-                                    if ( length-__synchelp_read_i < FLOATSIZE ) \
-{ \
-                                      PRINTF(1)("There is not enough data to read a flaot\n");  \
-                                      return 0; \
-} \
-                                    __synchelp_read_n = Converter::byteArrayToFloat( data+__synchelp_read_i, &f );  \
-                                    assert( __synchelp_read_n == FLOATSIZE ) ;\
-                                    __synchelp_read_i += __synchelp_read_n; \
-}
-#define SYNCHELP_READ_STRING(s,n)    {SYNCHELP_READ_DEBUG(n); \
-                                    __synchelp_read_n = Converter::byteArrayToString( data+__synchelp_read_i, s, length-__synchelp_read_i );  \
-                                    assert( __synchelp_read_n == s.length()+INTSIZE ) ;\
-                                    if ( __synchelp_read_n <0 )  \
-{ \
-                                      PRINTF(1)("There is not enough data to read string\n");  \
-                                      return 0; \
-} \
-                                    __synchelp_read_i += __synchelp_read_n; \
-}
-#if 0 //not needed any more
-#define SYNCHELP_READ_STRINGM(s,n)    { SYNCHELP_READ_DEBUG(n); \
-                                    __synchelp_read_n = Converter::byteArrayToStringM( data+__synchelp_read_i, s );  \
-                                    assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\
-                                    if ( __synchelp_read_n <0 )  \
-{ \
-                                      PRINTF(1)("There is not enough data to read string\n");  \
-                                      return 0; \
-} \
-                                    __synchelp_read_i += __synchelp_read_n; \
-}
-#endif
-#define SYNCHELP_READ_BYTE(b,n)      { SYNCHELP_READ_DEBUG(n); \
-                                    if ( length-__synchelp_read_i < 1 ) \
-{ \
-                                      PRINTF(1)("There is not enough data to read a byte\n");  \
-                                      return 0; \
-} \
-                                    b = data[__synchelp_read_i]; \
-                                    __synchelp_read_i ++;  \
-}
-#define SYNCHELP_READ_FKT(f,n)   { SYNCHELP_READ_DEBUG(n); \
-                                  int s; \
-                                  if ( length-__synchelp_read_i < INTSIZE ) \
-{ \
-                                      PRINTF(1)("There is not enough data to read an int\n");  \
-                                      return 0; \
-} \
-                                    __synchelp_read_n = Converter::byteArrayToInt( data+__synchelp_read_i, &s );  \
-                                    assert( __synchelp_read_n == INTSIZE ); \
-                                    __synchelp_read_i += __synchelp_read_n; \
-                                  __synchelp_read_i += \
-                                  f( data+__synchelp_read_i, s, sender); \
-                                  }
-#define SYNCHELP_READ_REMAINING() ( length-__synchelp_read_i )
-#define SYNCHELP_READ_NEXTBYTE() ( data[__synchelp_read_i] )
-#define SYNCHELP_READ_N           __synchelp_read_i
+typedef std::vector<SynchronizeableVar> SyncVarList;
 
 class NetworkStream;
-
 
 class Synchronizeable : virtual public BaseObject
@@ -307,16 +44,15 @@
     virtual ~Synchronizeable();
 
-    virtual int       writeBytes(const byte* data, int length, int sender);
-    virtual int       readBytes(byte* data, int maxLength, int * reciever);
-    virtual void      writeDebug() const;
-    virtual void      readDebug() const;
-
     void setIsServer( bool isServer );
-    void setIsOutOfSync( bool outOfSync );
-    void setRequestedSync( bool requestedSync );
     bool isServer();
-    bool isOutOfSync();
-    bool requestedSync();
-
+    
+    virtual void varChangeHandler( std::list<int> & id );
+    
+    int getStateDiff( int userId, byte* data, int maxLength, int stateId, int priorityTH );
+    bool setStateDiff( int userId, byte* data, int length, int stateId );
+    
+    void registerVar( SynchronizeableVar * var );
+    int registerVarId( SynchronizeableVar * var );
+    
     inline void setUniqueID( int id ){ uniqueID = id; }
     inline int  getUniqueID() const { return uniqueID; }
@@ -331,7 +67,4 @@
     inline void setSynchronized(bool bSynchronize) { this->bSynchronize = bSynchronize; }
 
-    inline void requestSync( int hostID ){ this->synchronizeRequests.push_back( hostID ); }
-    inline int getRequestSync( void ){ if ( this->synchronizeRequests.size()>0 ){ int n = *(synchronizeRequests.begin()); synchronizeRequests.pop_front(); return n; } else { return -1; } };
-
     inline void setNetworkStream(NetworkStream* stream) { this->networkStream = stream; }
     inline NetworkStream* getNetworkStream() { return this->networkStream; }
@@ -339,15 +72,12 @@
 
   protected:
-    NetworkStream*    networkStream;
+    NetworkStream*    networkStream;  //!< reference network stream we are connected to
     int               state;
 
-
   private:
-    int               uniqueID;
-    int               owner;
-    int               hostID;
-    bool              bSynchronize;
-
-    std::list<int>    synchronizeRequests;
+    int               uniqueID;       //!< unique id assigned to synchronizeable
+    int               owner;          //!< hostId of owner ( 0 if none / server )
+    int               hostID;         //!< my own host id
+    bool              bSynchronize;   //!< do we need beeing synchronized?
 
 };
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_bool.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_bool.cc	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_bool.cc	(revision 7444)
@@ -0,0 +1,58 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+
+#include "synchronizeable_bool.h"
+
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+SynchronizeableBool::SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )
+{
+  this->vPtrIn = ptrIn;
+  this->vPtrOut = ptrOut;
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableBool::~SynchronizeableBool ()
+{
+}
+
+/**
+ * write var data to byte buffer
+ * @param buf pointer to write to
+ * @param maxLength writeToBuf will not write more than maxLength bytes
+ * @return number bytes written
+ */
+int SynchronizeableBool::writeToBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
+
+/**
+ * read var data from byte buffer
+ * @param buf pointer to read from
+ * @param maxLength readFromBuf will not read more than maxLength bytes
+ * @return number bytes read
+ */
+int SynchronizeableBool::readFromBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_bool.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_bool.h	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_bool.h	(revision 7444)
@@ -0,0 +1,26 @@
+/*!
+ * @file synchronizeable_int.h
+ * @brief Definition of SynchronizeableInt
+*/
+
+#include "synchronizeable_var/synchronizeable_var.h"
+
+#ifndef _SYNCHRONIZEABLE_BOOL_H
+#define _SYNCHRONIZEABLE_BOOL_H
+
+class SynchronizeableBool : public SynchronizeableVar {
+
+  public:
+    SynchronizeableBool( bool * ptrIn, bool * ptrOut, std::string name, int permission = 0, int priority = 0 );
+    virtual ~SynchronizeableBool();
+    
+    virtual int writeToBuf( byte * buf, int maxLength );
+    virtual int readFromBuf( byte * buf, int maxLength );
+    
+  private:
+    bool * vPtrIn;       //!< pointer to data (read)
+    bool * vPtrOut;      //!< pointer to data (write)
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_float.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_float.cc	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_float.cc	(revision 7444)
@@ -0,0 +1,58 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+
+#include "synchronizeable_float.h"
+
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+SynchronizeableFloat::SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )
+{
+  this->vPtrIn = ptrIn;
+  this->vPtrOut = ptrOut;
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableFloat::~SynchronizeableFloat ()
+{
+}
+
+/**
+ * write var data to byte buffer
+ * @param buf pointer to write to
+ * @param maxLength writeToBuf will not write more than maxLength bytes
+ * @return number bytes written
+ */
+int SynchronizeableFloat::writeToBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
+
+/**
+ * read var data from byte buffer
+ * @param buf pointer to read from
+ * @param maxLength readFromBuf will not read more than maxLength bytes
+ * @return number bytes read
+ */
+int SynchronizeableFloat::readFromBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_float.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_float.h	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_float.h	(revision 7444)
@@ -0,0 +1,26 @@
+/*!
+ * @file synchronizeable_float.h
+ * @brief Definition of SynchronizeableFloat
+*/
+
+#include "synchronizeable_var/synchronizeable_var.h"
+
+#ifndef _SYNCHRONIZEABLE_FLOAT_H
+#define _SYNCHRONIZEABLE_FLOAT_H
+
+class SynchronizeableFloat : public SynchronizeableVar {
+
+  public:
+    SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission = 0, int priority = 0 );
+    virtual ~SynchronizeableFloat();
+    
+    virtual int writeToBuf( byte * buf, int maxLength );
+    virtual int readFromBuf( byte * buf, int maxLength );
+    
+  private:
+    float * vPtrIn;       //!< pointer to data (read)
+    float * vPtrOut;      //!< pointer to data (write)
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_int.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_int.cc	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_int.cc	(revision 7444)
@@ -0,0 +1,58 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+
+#include "synchronizeable_int.h"
+
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+SynchronizeableInt::SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )
+{
+  this->vPtrIn = ptrIn;
+  this->vPtrOut = ptrOut;
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableInt::~SynchronizeableInt ()
+{
+}
+
+/**
+ * write var data to byte buffer
+ * @param buf pointer to write to
+ * @param maxLength writeToBuf will not write more than maxLength bytes
+ * @return number bytes written
+ */
+int SynchronizeableInt::writeToBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
+
+/**
+ * read var data from byte buffer
+ * @param buf pointer to read from
+ * @param maxLength readFromBuf will not read more than maxLength bytes
+ * @return number bytes read
+ */
+int SynchronizeableInt::readFromBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_int.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_int.h	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_int.h	(revision 7444)
@@ -0,0 +1,27 @@
+/*!
+ * @file synchronizeable_int.h
+ * @brief Definition of SynchronizeableInt
+*/
+
+#include "synchronizeable_var/synchronizeable_var.h"
+
+#ifndef _SYNCHRONIZEABLE_INT_H
+#define _SYNCHRONIZEABLE_INT_H
+
+class SynchronizeableInt : public SynchronizeableVar {
+
+  public:
+    SynchronizeableInt( int * ptrIn, int * ptrOut, std::string name, int permission = 0, int priority = 0 );
+    virtual ~SynchronizeableInt();
+    
+    virtual int writeToBuf( byte * buf, int maxLength );
+    virtual int readFromBuf( byte * buf, int maxLength );
+    
+  private:
+    int * vPtrIn;       //!< pointer to data (read)
+    int * vPtrOut;      //!< pointer to data (write)
+
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc	(revision 7444)
@@ -0,0 +1,58 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+
+#include "synchronizeable_quaternion.h"
+
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+SynchronizeableQuaternion::SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )
+{
+  this->vPtrIn = ptrIn;
+  this->vPtrOut = ptrOut;
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableQuaternion::~SynchronizeableQuaternion ()
+{
+}
+
+/**
+ * write var data to byte buffer
+ * @param buf pointer to write to
+ * @param maxLength writeToBuf will not write more than maxLength bytes
+ * @return number bytes written
+ */
+int SynchronizeableQuaternion::writeToBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
+
+/**
+ * read var data from byte buffer
+ * @param buf pointer to read from
+ * @param maxLength readFromBuf will not read more than maxLength bytes
+ * @return number bytes read
+ */
+int SynchronizeableQuaternion::readFromBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h	(revision 7444)
@@ -0,0 +1,28 @@
+/*!
+ * @file synchronizeable_quaternion.h
+ * @brief Definition of SynchronizeableQuaternion
+*/
+
+#include "synchronizeable_var/synchronizeable_var.h"
+
+#ifndef _SYNCHRONIZEABLE_QUATERNION_H
+#define _SYNCHRONIZEABLE_QUATERNION_H
+
+#include "quaternion.h"
+
+class SynchronizeableQuaternion : public SynchronizeableVar {
+
+  public:
+    SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission = 0, int priority = 0 );
+    virtual ~SynchronizeableQuaternion();
+    
+    virtual int writeToBuf( byte * buf, int maxLength );
+    virtual int readFromBuf( byte * buf, int maxLength );
+    
+  private:
+    Quaternion * vPtrIn;       //!< pointer to data (read)
+    Quaternion * vPtrOut;      //!< pointer to data (write)
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_string.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_string.cc	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_string.cc	(revision 7444)
@@ -0,0 +1,58 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+
+#include "synchronizeable_string.h"
+
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+SynchronizeableString::SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )
+{
+  this->vPtrIn = ptrIn;
+  this->vPtrOut = ptrOut;
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableString::~SynchronizeableString ()
+{
+}
+
+/**
+ * write var data to byte buffer
+ * @param buf pointer to write to
+ * @param maxLength writeToBuf will not write more than maxLength bytes
+ * @return number bytes written
+ */
+int SynchronizeableString::writeToBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
+
+/**
+ * read var data from byte buffer
+ * @param buf pointer to read from
+ * @param maxLength readFromBuf will not read more than maxLength bytes
+ * @return number bytes read
+ */
+int SynchronizeableString::readFromBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_string.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_string.h	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_string.h	(revision 7444)
@@ -0,0 +1,28 @@
+/*!
+ * @file synchronizeable_string.h
+ * @brief Definition of SynchronizeableString
+*/
+
+#include "synchronizeable_var/synchronizeable_var.h"
+
+#ifndef _SYNCHRONIZEABLE_STRING_H
+#define _SYNCHRONIZEABLE_STRING_H
+
+#include <string>
+
+class SynchronizeableString : public SynchronizeableVar {
+
+  public:
+    SynchronizeableString( std::string * ptrIn, std::string * ptrOut, std::string name, int permission = 0, int priority = 0 );
+    virtual ~SynchronizeableString();
+    
+    virtual int writeToBuf( byte * buf, int maxLength );
+    virtual int readFromBuf( byte * buf, int maxLength );
+    
+  private:
+    std::string * vPtrIn;       //!< pointer to data (read)
+    std::string * vPtrOut;      //!< pointer to data (write)
+
+};
+
+#endif /* _SYNCHRONIZEABLE_STRING_H */
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_uint.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_uint.cc	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_uint.cc	(revision 7444)
@@ -0,0 +1,35 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+
+#include "synchronizeable_uint.h"
+
+
+/**
+ * standard constructor
+*/
+SynchronizeableUInt::SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission, int priority) : SynchronizeableInt( (int*)ptrIn, (int*)ptrOut, name, permission, priority )
+{
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableUInt::~SynchronizeableUInt ()
+{
+}
+
+
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_uint.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_uint.h	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_uint.h	(revision 7444)
@@ -0,0 +1,19 @@
+/*!
+ * @file synchronizeable_uint.h
+ * @brief Definition of SynchronizeableInt
+*/
+
+#include "synchronizeable_var/synchronizeable_int.h"
+
+#ifndef _SYNCHRONIZEABLE_UINT_H
+#define _SYNCHRONIZEABLE_UINT_H
+
+class SynchronizeableUInt : public SynchronizeableInt {
+
+  public:
+    SynchronizeableUInt( unsigned int * ptrIn, unsigned int * ptrOut, std::string name, int permission = 0, int priority = 0 );
+    virtual ~SynchronizeableUInt();
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.cc	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.cc	(revision 7444)
@@ -0,0 +1,63 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+
+#include "synchronizeable_var.h"
+
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+SynchronizeableVar::SynchronizeableVar ( void * ptrIn, void * ptrOut, std::string name, int length, int permission, int priority)
+{
+  this->ptrIn = ptrIn;
+  this->ptrOut = ptrOut;
+  this->length = length;
+  this->permission = permission;
+  this->priority = priority;
+  this->real_priority = priority;
+  this->name = name;
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableVar::~SynchronizeableVar ()
+{
+}
+
+/**
+ * write var data to byte buffer
+ * @param buf pointer to write to
+ * @param maxLength writeToBuf will not write more than maxLength bytes
+ * @return number bytes written
+ */
+int SynchronizeableVar::writeToBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
+
+/**
+ * read var data from byte buffer
+ * @param buf pointer to read from
+ * @param maxLength readFromBuf will not read more than maxLength bytes
+ * @return number bytes read
+ */
+int SynchronizeableVar::readFromBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.h	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.h	(revision 7444)
@@ -0,0 +1,62 @@
+/*!
+ * @file synchronizeable_var.h
+ * @brief Definition of SynchronizeableVar
+*/
+
+#ifndef _SYNCHRONIZEABLE_VAR_H
+#define _SYNCHRONIZEABLE_VAR_H
+
+#include <string>
+#include "netdefs.h"
+
+class SynchronizeableVar {
+
+  public:
+    SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = 0, int priority = 0 );
+    virtual ~SynchronizeableVar();
+    
+    /**
+     * check if synchronizeable wants to be informed on changes
+     * @return true if synchronizeable wants to be informed on changes
+     */
+    inline bool beWatched(){ return this->bWatched; }
+    
+    virtual int writeToBuf( byte * buf, int maxLength );
+    virtual int readFromBuf( byte * buf, int maxLength );
+    
+    /**
+     * check for permission to write
+     * @return true if you can write
+     */
+    inline bool checkPremission( int permission ){ return (permission & this->permission) != 0; }
+    
+    /**
+     * get variable name
+     * @return name
+     */
+    inline std::string getName(){ return name; }
+    
+    /**
+     * set variable name
+     * @param name new name
+     */
+    inline void setName( std::string name ) { this->name = name; }
+
+
+  private:
+    bool bWatched;      //!< true if synchronizeable wants to be informed on changes
+
+  protected:
+    void * ptrIn;       //!< pointer to data (read)
+    void * ptrOut;      //!< pointer to data (write)
+    int length;         //!< data length
+    int permission;     //!< who is allowed to change this var
+    int priority;       //!< priority assigned to var
+    int real_priority;  //!< priority assigned to var, increased every time not sent
+    
+    
+    std::string name;    //!< variable name (for debugging)
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.cc	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.cc	(revision 7444)
@@ -0,0 +1,58 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Christoph Renner
+   co-programmer: ...
+*/
+
+
+#include "synchronizeable_vector.h"
+
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+SynchronizeableVector::SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )
+{
+  this->vPtrIn = ptrIn;
+  this->vPtrOut = ptrOut;
+}
+
+
+/**
+ * standard deconstructor
+*/
+SynchronizeableVector::~SynchronizeableVector ()
+{
+}
+
+/**
+ * write var data to byte buffer
+ * @param buf pointer to write to
+ * @param maxLength writeToBuf will not write more than maxLength bytes
+ * @return number bytes written
+ */
+int SynchronizeableVector::writeToBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
+
+/**
+ * read var data from byte buffer
+ * @param buf pointer to read from
+ * @param maxLength readFromBuf will not read more than maxLength bytes
+ * @return number bytes read
+ */
+int SynchronizeableVector::readFromBuf( byte * buf, int maxLength )
+{
+#warning implement this
+}
Index: /branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.h
===================================================================
--- /branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.h	(revision 7444)
+++ /branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.h	(revision 7444)
@@ -0,0 +1,28 @@
+/*!
+ * @file synchronizeable_vector.h
+ * @brief Definition of SynchronizeableVector
+*/
+
+#include "synchronizeable_var/synchronizeable_var.h"
+
+#ifndef _SYNCHRONIZEABLE_VECTOR_H
+#define _SYNCHRONIZEABLE_VECTOR_H
+
+#include "vector.h"
+
+class SynchronizeableVector : public SynchronizeableVar {
+
+  public:
+    SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission = 0, int priority = 0 );
+    virtual ~SynchronizeableVector();
+    
+    virtual int writeToBuf( byte * buf, int maxLength );
+    virtual int readFromBuf( byte * buf, int maxLength );
+    
+  private:
+    Vector * vPtrIn;       //!< pointer to data (read)
+    Vector * vPtrOut;      //!< pointer to data (write)
+
+};
+
+#endif /* _PROTO_CLASS_H */
Index: /branches/network/src/util/multiplayer_team_deathmatch.cc
===================================================================
--- /branches/network/src/util/multiplayer_team_deathmatch.cc	(revision 7443)
+++ /branches/network/src/util/multiplayer_team_deathmatch.cc	(revision 7444)
@@ -203,10 +203,7 @@
       if ( terrz < terrain->getHeight( terrx, terry ) && ss->getAbsCoor().x > -1000 )
       {
-        //PRINTF(0)("COLLLLLLIIIIIDDDDEEEE\n");
-        ss->networkCollisionList.push_back( 1234567890 );
-        ss->doCollideNetwork( 1234567890 );
+        //TODO handle this
       }
-      //PRINTF(0)("x = %f, y = %f, z = %f, height = %f\n", terrx, terry, terrz, terrain->getHeight( terrx, terry ));
-      //ss->setRelCoorSoft( ss->getAbsCoor().x, terrain->getHeight( terrx, terry )-offsety, ss->getAbsCoor().z );
+
 
       float dist = (dynamic_cast<Playable*>(*it)->getAbsCoor() - big_left).len();
@@ -222,6 +219,5 @@
         if((*it)->isA(CL_SPACE_SHIP))
         {
-          dynamic_cast<SpaceShip*>(*it)->networkCollisionList.push_back(1163692);
-          dynamic_cast<SpaceShip*>(*it)->doCollideNetwork(11636922);
+          //TODO handle this
         }
       }
Index: /branches/network/src/world_entities/environments/water.cc
===================================================================
--- /branches/network/src/world_entities/environments/water.cc	(revision 7443)
+++ /branches/network/src/world_entities/environments/water.cc	(revision 7444)
@@ -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,19 @@
 
 
-/**
- * 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();
+  }
+}
Index: /branches/network/src/world_entities/environments/water.h
===================================================================
--- /branches/network/src/world_entities/environments/water.h	(revision 7443)
+++ /branches/network/src/world_entities/environments/water.h	(revision 7444)
@@ -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;
Index: /branches/network/src/world_entities/npcs/ground_turret.cc
===================================================================
--- /branches/network/src/world_entities/npcs/ground_turret.cc	(revision 7443)
+++ /branches/network/src/world_entities/npcs/ground_turret.cc	(revision 7444)
@@ -180,49 +180,2 @@
   Explosion::explode(this, Vector(10,10,10));
 }
-
-/**
- * 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 GroundTurret::writeBytes( const byte * data, int length, int sender )
-{
-  setRequestedSync( false );
-  setIsOutOfSync( false );
-
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_GT_WE_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 GroundTurret::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( WorldEntity::readState, NWT_GT_WE_STATE );
-
-  }
-
-  *reciever = 0;
-  return SYNCHELP_WRITE_N;
-}
Index: /branches/network/src/world_entities/npcs/ground_turret.h
===================================================================
--- /branches/network/src/world_entities/npcs/ground_turret.h	(revision 7443)
+++ /branches/network/src/world_entities/npcs/ground_turret.h	(revision 7444)
@@ -30,7 +30,4 @@
   virtual void tick(float time);
 
-  virtual int writeBytes(const byte* data, int length, int sender);
-  virtual int readBytes(byte* data, int maxLength, int * reciever);
-
  private:
    PNode  weaponHolder[2];
Index: /branches/network/src/world_entities/playable.cc
===================================================================
--- /branches/network/src/world_entities/playable.cc	(revision 7443)
+++ /branches/network/src/world_entities/playable.cc	(revision 7444)
@@ -60,7 +60,8 @@
 
   this->score = 0;
-  this->oldScore = 0;
 
   this->bDead = false;
+  
+  registerVar( new SynchronizeableInt( &score, &score, "score" ) );
 }
 
@@ -480,79 +481,4 @@
 
 
-#define DATA_FLAGS    1
-#define DATA_SCORE    2
-
-#define FLAGS_bFire   1
-
-int Playable::writeSync( const byte * data, int length, int sender )
-{
-  SYNCHELP_READ_BEGIN();
-
-  byte b;
-  SYNCHELP_READ_BYTE( b, NWT_PL_B );
-
-  byte flags;
-
-  if ( b == DATA_FLAGS )
-  {
-    SYNCHELP_READ_BYTE( flags, NWT_PL_FLAGS );
-
-    bFire = (flags & FLAGS_bFire) != 0;
-
-    return SYNCHELP_READ_N;
-  }
-
-  if ( b == DATA_SCORE )
-  {
-    int newScore;
-    SYNCHELP_READ_BYTE( newScore, NWT_PL_SCORE );
-    setScore( newScore );
-
-    return SYNCHELP_READ_N;
-  }
-
-  return SYNCHELP_READ_N;
-}
-
-int Playable::readSync( byte * data, int maxLength )
-{
-  SYNCHELP_WRITE_BEGIN();
-
-  if ( score != oldScore && isServer() )
-  {
-    SYNCHELP_WRITE_BYTE( DATA_SCORE, NWT_PL_B);
-    SYNCHELP_WRITE_INT( score, NWT_PL_SCORE );
-    oldScore = score;
-
-    return SYNCHELP_WRITE_N;
-  }
-
-  byte flags = 0;
-
-  if ( bFire )
-    flags |= FLAGS_bFire;
-
-
-  SYNCHELP_WRITE_BYTE( DATA_FLAGS, NWT_PL_B);
-  SYNCHELP_WRITE_BYTE( flags, NWT_PL_FLAGS );
-  oldFlags = flags;
-
-
-  return SYNCHELP_WRITE_N;
-}
-
-bool Playable::needsReadSync( )
-{
-  if ( score != oldScore && isServer() )
-    return true;
-
-  byte flags = 0;
-
-  if ( bFire )
-    flags |= FLAGS_bFire;
-
-  return flags!=oldFlags;
-}
-
 
 /**
Index: /branches/network/src/world_entities/playable.h
===================================================================
--- /branches/network/src/world_entities/playable.h	(revision 7443)
+++ /branches/network/src/world_entities/playable.h	(revision 7444)
@@ -79,10 +79,4 @@
   virtual void tick(float dt);
 
-  // NETWORK
-  int       writeSync(const byte* data, int length, int sender);
-  int       readSync(byte* data, int maxLength );
-  bool      needsReadSync();
-
-
   // Transformations:
   static Playable::Playmode stringToPlaymode(const std::string& playmode);
@@ -111,6 +105,5 @@
   int                   oldFlags;           //!< Used for synchronisation
 
-  int                   score;
-  int                   oldScore;
+  int                   score;              //!< players score
 
   bool                  bDead;
Index: /branches/network/src/world_entities/power_ups/laser_power_up.cc
===================================================================
--- /branches/network/src/world_entities/power_ups/laser_power_up.cc	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/laser_power_up.cc	(revision 7444)
@@ -120,40 +120,3 @@
 }
 
-int LaserPowerUp::writeBytes( const byte * data, int length, int sender )
-{
-  setRequestedSync( false );
-  setIsOutOfSync( false );
 
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( PowerUp::writeState, NWT_LPU_WE_STATE );
-
-  return SYNCHELP_READ_N;
-}
-
-
-
-int LaserPowerUp::readBytes( byte * data, int maxLength, int * reciever )
-{
-  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_BEGIN();
-
-    SYNCHELP_WRITE_FKT( PowerUp::readState, NWT_LPU_WE_STATE );
-
-    return SYNCHELP_WRITE_N;
-  }
-
-  *reciever = 0;
-  return 0;
-}
-
Index: /branches/network/src/world_entities/power_ups/laser_power_up.h
===================================================================
--- /branches/network/src/world_entities/power_ups/laser_power_up.h	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/laser_power_up.h	(revision 7444)
@@ -26,7 +26,4 @@
   virtual void draw() const;
 
-  virtual int writeBytes(const byte* data, int length, int sender);
-  virtual int readBytes(byte* data, int maxLength, int * reciever );
-
   private:
    void init();
Index: /branches/network/src/world_entities/power_ups/param_power_up.cc
===================================================================
--- /branches/network/src/world_entities/power_ups/param_power_up.cc	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/param_power_up.cc	(revision 7444)
@@ -43,4 +43,9 @@
   if( root != NULL)
     this->loadParams(root);
+  
+  registerVar( new SynchronizeableInt( (int*)&type, (int*)&type, "type" ) );
+  registerVar( new SynchronizeableFloat( &value, &value, "value" ) );
+  registerVar( new SynchronizeableFloat( &max_value, &max_value, "max_value" ) );
+  registerVar( new SynchronizeableFloat( &min_value, &min_value, "min_value" ) );
 }
 
@@ -119,62 +124,2 @@
 }
 
-int ParamPowerUp::writeBytes( const byte * data, int length, int sender )
-{
-  setRequestedSync( false );
-  setIsOutOfSync( false );
-
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( PowerUp::writeState, NWT_PPU_WE_STATE );
-
-  int i;
-  SYNCHELP_READ_INT( i, NWT_PPU_TYPE );
-  this->type = (EnumParamPowerUpType)i;
-  SYNCHELP_READ_FLOAT( this->value, NWT_PPU_VALUE );
-
-  if ( this->value != 0 )
-  {
-    SYNCHELP_READ_FLOAT( this->min_value, NWT_PPU_MINVALUE );
-    SYNCHELP_READ_FLOAT( this->max_value, NWT_PPU_MAXVALUE );
-    respawn();
-  }
-
-  return SYNCHELP_READ_N;
-}
-
-
-
-int ParamPowerUp::readBytes( byte * data, int maxLength, int * reciever )
-{
-  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_BEGIN();
-
-    SYNCHELP_WRITE_FKT( PowerUp::readState, NWT_PPU_WE_STATE );
-
-    int i = (int)this->type;
-    SYNCHELP_WRITE_INT( i, NWT_PPU_TYPE );
-    SYNCHELP_WRITE_FLOAT( this->value, NWT_PPU_VALUE );
-
-    if ( this->value != 0 )
-    {
-      SYNCHELP_WRITE_FLOAT( this->min_value, NWT_PPU_MINVALUE );
-      SYNCHELP_WRITE_FLOAT( this->max_value, NWT_PPU_MAXVALUE );
-    }
-
-    return SYNCHELP_WRITE_N;
-  }
-
-  *reciever = 0;
-  return 0;
-}
-
Index: /branches/network/src/world_entities/power_ups/param_power_up.h
===================================================================
--- /branches/network/src/world_entities/power_ups/param_power_up.h	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/param_power_up.h	(revision 7444)
@@ -32,7 +32,4 @@
   float getValue();
 
-  virtual int writeBytes(const byte* data, int length, int sender);
-  virtual int readBytes(byte* data, int maxLength, int * reciever );
-
 protected:
   virtual void respawn();
Index: /branches/network/src/world_entities/power_ups/power_up.cc
===================================================================
--- /branches/network/src/world_entities/power_ups/power_up.cc	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/power_up.cc	(revision 7444)
@@ -201,34 +201,2 @@
 
 
-/********************************************************************************************
- NETWORK STUFF
- ********************************************************************************************/
-
-
-/**
- * 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 PowerUp::readState( byte * data, int maxLength )
-{
-  SYNCHELP_WRITE_BEGIN();
-  SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_PU_WE_STATE );
-  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 PowerUp::writeState( const byte * data, int length, int sender )
-{
-  SYNCHELP_READ_BEGIN();
-  SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_PU_WE_STATE );
-  return SYNCHELP_READ_N;
-}
-
Index: /branches/network/src/world_entities/power_ups/power_up.h
===================================================================
--- /branches/network/src/world_entities/power_ups/power_up.h	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/power_up.h	(revision 7444)
@@ -34,7 +34,4 @@
   void setRespawnTime(const float respawn);
 
-  int       writeState(const byte* data, int length, int sender);
-  int       readState(byte* data, int maxLength );
-
 protected:
   PowerUp(float r, float g, float b);
Index: /branches/network/src/world_entities/power_ups/turret_power_up.cc
===================================================================
--- /branches/network/src/world_entities/power_ups/turret_power_up.cc	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/turret_power_up.cc	(revision 7444)
@@ -115,47 +115,2 @@
   glPopMatrix();
 }
-
-
-
-
-/********************************************************************************************
- NETWORK STUFF
- ********************************************************************************************/
-
-
-int TurretPowerUp::writeBytes( const byte * data, int length, int sender )
-{
-  setRequestedSync( false );
-  setIsOutOfSync( false );
-
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( PowerUp::writeState, NWT_TPU_WE_STATE );
-
-  return SYNCHELP_READ_N;
-}
-
-
-int TurretPowerUp::readBytes( byte * data, int maxLength, int * reciever )
-{
-  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_BEGIN();
-
-    SYNCHELP_WRITE_FKT( PowerUp::readState, NWT_TPU_WE_STATE );
-
-    return SYNCHELP_WRITE_N;
-  }
-
-  *reciever = 0;
-  return 0;
-}
Index: /branches/network/src/world_entities/power_ups/turret_power_up.h
===================================================================
--- /branches/network/src/world_entities/power_ups/turret_power_up.h	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/turret_power_up.h	(revision 7444)
@@ -24,7 +24,4 @@
   virtual void draw() const;
 
-  virtual int writeBytes(const byte* data, int length, int sender);
-  virtual int readBytes(byte* data, int maxLength, int * reciever );
-
   private:
    void init();
Index: /branches/network/src/world_entities/power_ups/weapon_power_up.cc
===================================================================
--- /branches/network/src/world_entities/power_ups/weapon_power_up.cc	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/weapon_power_up.cc	(revision 7444)
@@ -103,43 +103,2 @@
 }
 
-int WeaponPowerUp::writeBytes( const byte * data, int length, int sender )
-{
-  setRequestedSync( false );
-  setIsOutOfSync( false );
-
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( PowerUp::writeState, NWT_WPU_WE_STATE );
-
-  //TODO: sync weapon class ( see loadParams )
-
-  return SYNCHELP_READ_N;
-}
-
-
-
-int WeaponPowerUp::readBytes( byte * data, int maxLength, int * reciever )
-{
-  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_BEGIN();
-
-    SYNCHELP_WRITE_FKT( PowerUp::readState, NWT_WPU_WE_STATE );
-
-    //TODO: sync weapon class ( see loadParams )
-
-    return SYNCHELP_WRITE_N;
-  }
-
-  *reciever = 0;
-  return 0;
-}
Index: /branches/network/src/world_entities/power_ups/weapon_power_up.h
===================================================================
--- /branches/network/src/world_entities/power_ups/weapon_power_up.h	(revision 7443)
+++ /branches/network/src/world_entities/power_ups/weapon_power_up.h	(revision 7444)
@@ -24,7 +24,4 @@
   void setWeaponClass(const std::string& name);
 
-  virtual int writeBytes(const byte* data, int length, int sender);
-  virtual int readBytes(byte* data, int maxLength, int * reciever );
-
   bool process(WeaponManager* manager);
 
Index: /branches/network/src/world_entities/skybox.cc
===================================================================
--- /branches/network/src/world_entities/skybox.cc	(revision 7443)
+++ /branches/network/src/world_entities/skybox.cc	(revision 7444)
@@ -95,4 +95,7 @@
 {
   this->rebuild();
+  
+  textureName_handle = registerVarId( new SynchronizeableString( &textureName, &textureName, "textureName") );
+  size_handle = registerVarId( new SynchronizeableFloat( &size, &size, "size" ) );
 }
 
@@ -292,62 +295,6 @@
 }
 
-int SkyBox::writeBytes( const byte * data, int length, int sender )
-{
-  setRequestedSync( false );
-  setIsOutOfSync( false );
-
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SB_WE_STATE );
-
-  SYNCHELP_READ_FLOAT( size, NWT_SB_SIZE );
-  if ( !this->textureName.empty() )
-  {
-    textureName = "";
-  }
-  std::string texName;
-  SYNCHELP_READ_STRING( texName, NWT_SB_TEXTURENAME );
-
-  this->setSize( size );
-  this->setTextureAndType( texName, "jpg" );
-  this->rebuild();
-
-  return SYNCHELP_READ_N;
-}
-
-
-
-int SkyBox::readBytes( byte * data, int maxLength, int * reciever )
-{
-  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_BEGIN();
-
-    SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_SB_WE_STATE );
-
-    SYNCHELP_WRITE_FLOAT(this->size, NWT_SB_SIZE);
-    SYNCHELP_WRITE_STRING(this->textureName, NWT_SB_TEXTURENAME);
-
-    return SYNCHELP_WRITE_N;
-  }
-
-  *reciever = 0;
-  return 0;
-}
-
-void SkyBox::writeDebug( ) const
-{
-}
-
-void SkyBox::readDebug( ) const
-{
-}
+void SkyBox::varChangeHandler( std::list< int > & id )
+{
+#warning implement this
+}
Index: /branches/network/src/world_entities/skybox.h
===================================================================
--- /branches/network/src/world_entities/skybox.h	(revision 7443)
+++ /branches/network/src/world_entities/skybox.h	(revision 7444)
@@ -58,8 +58,5 @@
   static void disableCubeMap();
 
-  virtual int       writeBytes(const byte* data, int length, int sender);
-  virtual int       readBytes(byte* data, int maxLength, int * reciever);
-  virtual void      writeDebug() const;
-  virtual void      readDebug() const;
+  virtual void varChangeHandler( std::list<int> & id );
 
  private:
@@ -72,4 +69,7 @@
   float           textureSize;     //!< this is the length of a texture (assumes a square texture)
   std::string     textureName;     //!< Name of the Texture
+  
+  int textureName_handle;          //!< used to notify about changes of textureName
+  int size_handle;                 //!< used to notify about changes of size
 
 };
Index: /branches/network/src/world_entities/space_ships/space_ship.cc
===================================================================
--- /branches/network/src/world_entities/space_ships/space_ship.cc	(revision 7443)
+++ /branches/network/src/world_entities/space_ships/space_ship.cc	(revision 7444)
@@ -94,19 +94,4 @@
   if (root != NULL)
     this->loadParams(root);
-  else
-  {
-    //this->loadModel("models/ships/reap_#.obj");
-    //TODO HACK this is only for network multiplayer games.
-    if( this->getOwner()%2 == 0)
-    {
-      this->loadModel("models/ships/reap_#.obj");
-      this->toList(OM_GROUP_00);
-    }
-    else
-    {
-      this->loadModel( "models/ships/fighter.obj" );
-      this->toList(OM_GROUP_01);
-    }
-  }
 
 }
@@ -235,5 +220,16 @@
   this->burstSystem->setColor(0.5, .5,.5,.8,.8);
   this->burstSystem->setColor(1.0, .8,.8,.8,.0);
-
+  
+  registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity" ) );
+  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir" ) );
+
+  registerVar( new SynchronizeableBool( &bUp, &bUp, "bUp" ) );
+  registerVar( new SynchronizeableBool( &bDown, &bDown, "bDown" ) );
+  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft" ) );
+  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight" ) );
+  registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend" ) );
+  registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend" ) );
+  registerVar( new SynchronizeableBool( &bRollL, &bRollL, "bRollL" ) );
+  registerVar( new SynchronizeableBool( &bRollR, &bRollR, "bRollR" ) );
 }
 
@@ -307,6 +303,5 @@
     if ( isServer() )
     {
-      networkCollisionList.push_back( entity->getHealth() );
-      doCollideNetwork( entity->getHealth() );
+      //TODO handle this
     }
   }
@@ -510,273 +505,4 @@
 
 
-#define MASK_bUp         1
-#define MASK_bDown       2
-#define MASK_bLeft       4
-#define MASK_bRight      8
-#define MASK_bAscend    16
-#define MASK_bDescend   32
-#define MASK_bRollL     64
-#define MASK_bRollR    128
-
-#define DATA_state       1
-#define DATA_flags       2
-#define DATA_mouse       3
-#define DATA_sync        4
-#define DATA_velocity    5
-#define DATA_playables   6
-#define DATA_collision   7
-
-int SpaceShip::writeBytes( const byte * data, int length, int sender )
-{
-  SYNCHELP_READ_BEGIN();
-
-  byte b;
-
-  while ( SYNCHELP_READ_REMAINING()>0 )
-  {
-    SYNCHELP_READ_BYTE( b, NWT_SS_B );
-
-    if ( b == DATA_state )
-    {
-      setRequestedSync( false );
-      setIsOutOfSync( false );
-      SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_SS_WE_STATE );
-
-      continue;
-    }
-
-    if ( b == DATA_flags )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        byte flags = 0;
-        SYNCHELP_READ_BYTE( flags, NWT_SS_FLAGS );
-
-        bUp = (flags & MASK_bUp) != 0;
-        bDown = (flags & MASK_bDown) != 0;
-        bLeft = (flags & MASK_bLeft) != 0;
-        bRight = (flags & MASK_bRight) != 0;
-        bAscend = (flags & MASK_bAscend) != 0;
-        bDescend = (flags & MASK_bDescend) != 0;
-        bRollL = (flags & MASK_bRollL) != 0;
-        bRollR = (flags & MASK_bRollR) != 0;
-
-      }
-      else
-        assert(false);
-
-      continue;
-    }
-
-    if ( b == DATA_mouse )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        SYNCHELP_READ_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
-        SYNCHELP_READ_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
-        SYNCHELP_READ_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
-        SYNCHELP_READ_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
-      }
-      else
-        assert(false);
-
-      continue;
-    }
-
-    if ( b == DATA_sync )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        SYNCHELP_READ_FKT( PNode::writeSync, NWT_SS_PN_SYNC );
-      }
-      else
-        assert(false);
-
-      continue;
-    }
-
-    if ( b == DATA_velocity )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        SYNCHELP_READ_FLOAT( velocity.x, NWT_SS_VELX );
-        SYNCHELP_READ_FLOAT( velocity.y, NWT_SS_VELY );
-        SYNCHELP_READ_FLOAT( velocity.z, NWT_SS_VELZ );
-      }
-      else
-        assert(false);
-
-      continue;
-    }
-
-    if ( b == DATA_playables )
-    {
-      if ( this->getOwner() != this->getHostID() )
-      {
-        SYNCHELP_READ_FKT( Playable::writeSync, NWT_SS_PL_SYNC );
-      }
-      else
-        assert(false);
-    }
-
-    if ( b == DATA_collision )
-    {
-      int n;
-      float energy;
-      SYNCHELP_READ_INT( n, NWT_SS_CO_N );
-
-      for ( int i = 0; i<n; i++ )
-      {
-        SYNCHELP_READ_FLOAT( energy, NWT_SS_CO_CLID );
-        doCollideNetwork( energy );
-      }
-    }
-  }
-
-  return SYNCHELP_READ_N;
-}
-
-
-
-int SpaceShip::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 );
-    PRINTF(0)("REQUESTED STATE %d\n", this->getUniqueID());
-  }
-
-  int rec = this->getRequestSync();
-  if ( rec > 0 )
-  {
-    *reciever = rec;
-
-    PRINTF(0)("SEND STATE %d %d\n", this->getUniqueID(), rec);
-
-    SYNCHELP_WRITE_BYTE( (byte)DATA_state, NWT_SS_B );
-
-    SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_SS_WE_STATE );
-
-    return SYNCHELP_WRITE_N;
-  }
-
-  *reciever = 0 - this->getOwner();
-  //TODO: implement with SYNCHELP_WRITE_SENT()
-  bool sentSomething = false;
-
-  if ( PNode::needsReadSync() && ( this->getHostID()==0 || this->getOwner() == this->getHostID() ) )
-  {
-    PRINTF(0)("sending PNode::readSync\n");
-    SYNCHELP_WRITE_BYTE( DATA_sync, NWT_SS_B );
-    SYNCHELP_WRITE_FKT( PNode::readSync, NWT_SS_PN_SYNC );
-    sentSomething = true;
-  }
-
-  if ( this->getHostID()==0 || this->getHostID()==this->getOwner() )
-  {
-    byte mask = 0;
-
-    if ( bUp )
-      mask |= MASK_bUp;
-    if ( bDown )
-      mask |= MASK_bDown;
-    if ( bLeft )
-      mask |= MASK_bLeft;
-    if ( bRight )
-      mask |= MASK_bRight;
-    if ( bAscend )
-      mask |= MASK_bAscend;
-    if ( bRollL )
-      mask |= MASK_bRollL;
-    if ( bRollR )
-      mask |= MASK_bRollR;
-
-
-    if ( mask != oldMask )
-    {
-      oldMask = mask;
-      PRINTF(0)("sending mask\n");
-      sentSomething = true;
-      SYNCHELP_WRITE_BYTE( DATA_flags, NWT_SS_B );
-      SYNCHELP_WRITE_BYTE( mask, NWT_SS_FLAGS );
-    }
-#define __OFFSET_MDIR_W 0.01
-#define __OFFSET_MDIR_V 0.01
-    if ( fabs( oldMouseDir.w - mouseDir.w ) > __OFFSET_MDIR_W ||
-         fabs( oldMouseDir.v.x - mouseDir.v.x ) > __OFFSET_MDIR_V ||
-         fabs( oldMouseDir.v.y - mouseDir.v.y ) > __OFFSET_MDIR_V ||
-         fabs( oldMouseDir.v.z - mouseDir.v.z ) > __OFFSET_MDIR_V )
-    {
-      oldMouseDir = mouseDir;
-
-      SYNCHELP_WRITE_BYTE( DATA_mouse, NWT_SS_B );
-      PRINTF(0)("SENDING mousedir\n");
-      sentSomething = true;
-      SYNCHELP_WRITE_FLOAT( mouseDir.w, NWT_SS_MOUSEDIRW );
-      SYNCHELP_WRITE_FLOAT( mouseDir.v.x, NWT_SS_MOUSEDIRX );
-      SYNCHELP_WRITE_FLOAT( mouseDir.v.y, NWT_SS_MOUSEDIRY );
-      SYNCHELP_WRITE_FLOAT( mouseDir.v.z, NWT_SS_MOUSEDIRZ );
-    }
-#define __OFFSET_VEL 0.05
-    if ( fabs( oldVelocity.x - velocity.x ) > __OFFSET_VEL*fabs(oldVelocity.x)+0.1 ||
-         fabs( oldVelocity.y - velocity.y ) > __OFFSET_VEL*fabs(oldVelocity.y)+0.1 ||
-         fabs( oldVelocity.z - velocity.z ) > __OFFSET_VEL*fabs(oldVelocity.z)+0.1 )
-    {
-      oldVelocity.x = velocity.x;
-      oldVelocity.y = velocity.y;
-      oldVelocity.z = velocity.z;
-      PRINTF(0)("SENDING velocity\n");
-      sentSomething = true;
-      SYNCHELP_WRITE_BYTE( DATA_velocity, NWT_SS_B );
-      SYNCHELP_WRITE_FLOAT( velocity.x, NWT_SS_VELX );
-      SYNCHELP_WRITE_FLOAT( velocity.y, NWT_SS_VELY );
-      SYNCHELP_WRITE_FLOAT( velocity.z, NWT_SS_VELZ );
-    }
-
-    while ( Playable::needsReadSync() )
-    {
-      sentSomething = true;
-      PRINTF(0)("SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC )\n");
-      SYNCHELP_WRITE_BYTE( DATA_playables, NWT_SS_B );
-      SYNCHELP_WRITE_FKT( Playable::readSync, NWT_SS_PL_SYNC );
-    }
-
-  }
-
-  if ( !sentSomething )
-  {
-    *reciever = 0;
-
-    if ( networkCollisionList.size()>0 )
-    {
-      SYNCHELP_WRITE_BYTE( DATA_collision, NWT_SS_B );
-
-      SYNCHELP_WRITE_INT( networkCollisionList.size(), NWT_SS_CO_N );
-
-      for ( std::list<float>::iterator it = networkCollisionList.begin(); it!=networkCollisionList.end(); it++ )
-      {
-        SYNCHELP_WRITE_FLOAT( *it, NWT_SS_CO_CLID );
-      }
-
-      networkCollisionList.clear();
-    }
-  }
-
-  return SYNCHELP_WRITE_N;
-}
-
-
-void SpaceShip::doCollideNetwork( float energy )
-{
-  this->decreaseHealth( energy );
-  if( this->getHealth() <= 0)
-  {
-    this->die();
-  }
-}
-
-
-
+
+
Index: /branches/network/src/world_entities/space_ships/space_ship.h
===================================================================
--- /branches/network/src/world_entities/space_ships/space_ship.h	(revision 7443)
+++ /branches/network/src/world_entities/space_ships/space_ship.h	(revision 7444)
@@ -46,8 +46,4 @@
     virtual int       readBytes(byte* data, int maxLength, int * reciever);
 
-    //HACK HACK HACK HACK make this private or remove it
-    void doCollideNetwork( float energy );
-    std::list<float>        networkCollisionList;
-
   private:
     void init();
Index: /branches/network/src/world_entities/terrain.cc
===================================================================
--- /branches/network/src/world_entities/terrain.cc	(revision 7443)
+++ /branches/network/src/world_entities/terrain.cc	(revision 7444)
@@ -423,44 +423,4 @@
 }
 
-int Terrain::writeBytes( const byte * data, int length, int sender )
-{
-  setRequestedSync( false );
-  setIsOutOfSync( false );
-
-  SYNCHELP_READ_BEGIN();
-  SYNCHELP_READ_FKT( WorldEntity::writeState, NWT_TER_WE_STATE );
-
-  return SYNCHELP_READ_N;
-}
-
-int Terrain::readBytes( byte * data, int maxLength, int * reciever )
-{
-  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_BEGIN();
-    SYNCHELP_WRITE_FKT( WorldEntity::readState, NWT_TER_WE_STATE );
-    return SYNCHELP_WRITE_N;
-
-  }
-
-  *reciever = 0;
-  return 0;
-}
-
-void Terrain::writeDebug( ) const
-  {}
-
-void Terrain::readDebug( ) const
-  {}
-
 float Terrain::getHeight(float x, float y)
 {
Index: /branches/network/src/world_entities/terrain.h
===================================================================
--- /branches/network/src/world_entities/terrain.h	(revision 7443)
+++ /branches/network/src/world_entities/terrain.h	(revision 7444)
@@ -33,9 +33,4 @@
   virtual ~Terrain();
 
-  virtual int       writeBytes(const byte* data, int length, int sender);
-  virtual int       readBytes(byte* data, int maxLength, int * reciever);
-  virtual void      writeDebug() const;
-  virtual void      readDebug() const;
-
   void init();
   virtual void loadParams(const TiXmlElement* root);
Index: /branches/network/src/world_entities/world_entity.cc
===================================================================
--- /branches/network/src/world_entities/world_entity.cc	(revision 7443)
+++ /branches/network/src/world_entities/world_entity.cc	(revision 7444)
@@ -65,4 +65,7 @@
 
   this->toList(OM_NULL);
+  
+  modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
+  scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
 }
 
@@ -123,4 +126,14 @@
   this->modelLODName = fileName;
   this->scaling = scaling;
+  
+  std::string name = fileName;
+
+  if (  name.find( ResourceManager::getInstance()->getDataDir() ) == 0 ) 
+  {
+    name.erase(ResourceManager::getInstance()->getDataDir().size());
+  }
+
+  this->modelFileName = name;
+  
   if (!fileName.empty())
   {
@@ -504,93 +517,10 @@
 
 
-
-
-/********************************************************************************************
- NETWORK STUFF
- ********************************************************************************************/
-
-
-/**
- * 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 WorldEntity::writeState( const byte * data, int length, int sender )
-{
-  std::string modelFileName;
-  SYNCHELP_READ_BEGIN();
-
-  SYNCHELP_READ_FKT( PNode::writeState, NWT_WE_PN_WRITESTATE );
-
-  SYNCHELP_READ_STRING( modelFileName, NWT_WE_PN_MODELFILENAME );
-  SYNCHELP_READ_FLOAT( scaling, NWT_WE_PN_SCALING );
-  //check if modelFileName is relative to datadir or absolute
-
-
-  PRINTF(0)("================ LOADING MODEL %s, %f\n", modelFileName.c_str(), scaling);
-
-  if ( modelFileName != "" )
-  {
-    loadModel( modelFileName, scaling);
-    PRINTF(0)("modelfilename: %s\n", getModel( 0 )->getName());
-  }
-
-  /*SYNCHELP_READ_STRINGM( modelFileName );
-
-  if ( strcmp(modelFileName, "") )
-    if ( strstr(modelFileName, ResourceManager::getInstance()->getDataDir()) )
-    {
-      this->md2TextureFileName = new char[strlen(modelFileName)-strlen(ResourceManager::getInstance()->getDataDir())+1];
-      strcpy((char*)this->md2TextureFileName, modelFileName+strlen(ResourceManager::getInstance()->getDataDir()));
-    }
-    else
-    {
-      this->md2TextureFileName = modelFileName;
-    }
-  */
-
-  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 WorldEntity::readState( byte * data, int maxLength )
-{
-  SYNCHELP_WRITE_BEGIN();
-
-  SYNCHELP_WRITE_FKT( PNode::readState, NWT_WE_PN_WRITESTATE );
-
-  if ( getModel(0) && getModel(0)->getName() != "" )
-  {
-    std::string name = getModel( 0 )->getName();
-
-    if (  name.find( ResourceManager::getInstance()->getDataDir() ) == 0 ) 
-    {
-      name.erase(ResourceManager::getInstance()->getDataDir().size());
-    }
-
-    SYNCHELP_WRITE_STRING( name, NWT_WE_PN_MODELFILENAME );
-  }
-  else
-  {
-    SYNCHELP_WRITE_STRING("", NWT_WE_PN_MODELFILENAME);
-  }
-
-  SYNCHELP_WRITE_FLOAT( scaling, NWT_WE_PN_SCALING );
-  /*if ( this->md2TextureFileName!=NULL && strcmp(this->md2TextureFileName, "") )
-  {
-    SYNCHELP_WRITE_STRING(this->md2TextureFileName);
-  }
-  else
-  {
-    SYNCHELP_WRITE_STRING("");
-  }*/
-
-  return SYNCHELP_WRITE_N;
-}
+/**
+ * handler for changes on registred vars
+ * @param id id's which changed
+ */
+void WorldEntity::varChangeHandler( std::list< int > & id )
+{
+#warning implement this
+}
Index: /branches/network/src/world_entities/world_entity.h
===================================================================
--- /branches/network/src/world_entities/world_entity.h	(revision 7443)
+++ /branches/network/src/world_entities/world_entity.h	(revision 7444)
@@ -96,4 +96,6 @@
   GLGuiWidget* getHealthWidget();
   bool hasHealthWidget() const { return this->healthWidget; };
+  
+  virtual void varChangeHandler( std::list<int> & id );
 
 protected:
@@ -123,5 +125,12 @@
   ObjectManager::EntityList::iterator objectListIterator; //!< The iterator position of this Entity in the given list of the ObjectManager.
 
-  float                   scaling;
+  
+  //network stuff
+  
+  float       scaling;                         //!< model's scaling factor
+  int         scaling_handle;                  //!< handle for syncing var
+  
+  std::string modelFileName;                  //!< model's file name
+  int         modelFileName_handle;           //!< handle for syncing var
 
 
