Index: branches/network/src/lib/coord/p_node.cc
===================================================================
--- branches/network/src/lib/coord/p_node.cc	(revision 7380)
+++ 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
+}
+
+
