Index: branches/network/src/lib/coord/p_node.cc
===================================================================
--- branches/network/src/lib/coord/p_node.cc	(revision 6328)
+++ branches/network/src/lib/coord/p_node.cc	(revision 6331)
@@ -27,4 +27,6 @@
 #include "glincl.h"
 #include "color.h"
+
+#include "synchronizeable.h"
 
 using namespace std;
@@ -1003,2 +1005,143 @@
     return (PNODE_ROTATE_AND_MOVE);
 }
+
+/**
+ * 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();
+
+  char * name;
+  SYNCHELP_READ_STRINGM( name );
+
+  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 );
+  this->setParentMode((PARENT_MODE)parentMode);
+
+  if ( strcmp(name, "")==0 )
+  {
+    this->setName( NULL );
+  }
+  else
+  {
+    this->setName( name );
+  }
+  delete name;
+  name = NULL;
+
+  float f1, f2, f3, f4;
+
+  SYNCHELP_READ_FLOAT( f1 );
+  SYNCHELP_READ_FLOAT( f2 );
+  SYNCHELP_READ_FLOAT( f3 );
+  this->setRelCoor( f1, f2, f3 );
+
+  PRINTF(0)("%f %f %f\n", f1, f2, f3);
+
+  SYNCHELP_READ_FLOAT( f1 );
+  SYNCHELP_READ_FLOAT( f2 );
+  SYNCHELP_READ_FLOAT( f3 );
+  this->setAbsCoor( f1, f2, f3 );
+
+  PRINTF(0)("%f %f %f\n", f1, f2, f3);
+
+  SYNCHELP_READ_FLOAT( f1 );
+  SYNCHELP_READ_FLOAT( f2 );
+  SYNCHELP_READ_FLOAT( f3 );
+  SYNCHELP_READ_FLOAT( f4 );
+  this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
+
+  SYNCHELP_READ_FLOAT( f1 );
+  SYNCHELP_READ_FLOAT( f2 );
+  SYNCHELP_READ_FLOAT( f3 );
+  SYNCHELP_READ_FLOAT( f4 );
+  this->setAbsDir( Quaternion( Vector(f2, f3, f4), f1 ) );
+
+  int n;
+  char * childName;
+
+  SYNCHELP_READ_INT( n );
+
+  for (int i = 0; i<n; i++)
+  {
+    SYNCHELP_READ_STRINGM( 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_STRING( this->getName() );
+
+  if ( this->parent )
+  {
+    SYNCHELP_WRITE_STRING( parent->getName() );
+  }
+  else
+  {
+    SYNCHELP_WRITE_STRING( "" );
+  }
+
+  SYNCHELP_WRITE_INT( this->parentMode );
+
+  SYNCHELP_WRITE_FLOAT( this->relCoordinate.x );
+  SYNCHELP_WRITE_FLOAT( this->relCoordinate.y );
+  SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
+
+  PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);
+
+  SYNCHELP_WRITE_FLOAT( this->absCoordinate.x );
+  SYNCHELP_WRITE_FLOAT( this->absCoordinate.y );
+  SYNCHELP_WRITE_FLOAT( this->absCoordinate.z );
+
+  PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);
+
+  SYNCHELP_WRITE_FLOAT( this->relDirection.w );
+  SYNCHELP_WRITE_FLOAT( this->relDirection.v.x );
+  SYNCHELP_WRITE_FLOAT( this->relDirection.v.y );
+  SYNCHELP_WRITE_FLOAT( this->relDirection.v.z );
+
+  SYNCHELP_WRITE_FLOAT( this->absDirection.w );
+  SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );
+  SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );
+  SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );
+
+  int n = children.size();
+  SYNCHELP_WRITE_INT( n );
+
+  for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
+  {
+    SYNCHELP_WRITE_STRING( (*it)->getName() );
+  }
+  return SYNCHELP_WRITE_N;
+}
Index: branches/network/src/lib/coord/p_node.h
===================================================================
--- branches/network/src/lib/coord/p_node.h	(revision 6328)
+++ branches/network/src/lib/coord/p_node.h	(revision 6331)
@@ -178,4 +178,6 @@
   static PARENT_MODE charToParentingMode(const char* parentingMode);
 
+  int       writeState(const byte* data, int length, int sender);
+  int       readState(byte* data, int maxLength );
 
  private:
Index: branches/network/src/lib/network/converter.cc
===================================================================
--- branches/network/src/lib/network/converter.cc	(revision 6328)
+++ branches/network/src/lib/network/converter.cc	(revision 6331)
@@ -317,4 +317,13 @@
     return -1;
   }
+
+  //handle 0 else function will loop for ever
+  if ( x == 0 )
+  {
+    for ( int i = 0; i<FLOATSIZE; i++)
+      a[i] = 0;
+    return FLOATSIZE;
+  }
+
   int mantisse = 0;
   int exponent = 128;
@@ -376,4 +385,17 @@
 int Converter::byteArrayToFloat(const byte* a, float* x)
 {
+  //handle 0
+  for (int i = 0; i<FLOATSIZE; i++)
+  {
+    if (a[i]!=0)
+      break;
+    if ( i==FLOATSIZE-1 )
+    {
+      *x = 0.0f;
+      return FLOATSIZE;
+    }
+  }
+
+
   int hmant = a[0] + a[1] * 256 + a[2] * 65536;
   int mantisse = hmant % expmult;
@@ -441,4 +463,5 @@
   int n = Converter::byteArrayToInt( a, &length );
 
+
   if ( length+1 > maxLength )
   {
Index: branches/network/src/lib/network/handshake.cc
===================================================================
--- branches/network/src/lib/network/handshake.cc	(revision 6328)
+++ branches/network/src/lib/network/handshake.cc	(revision 6331)
@@ -37,10 +37,12 @@
 }
 
-void Handshake::writeBytes( const byte * data, int length, int sender)
+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;
+       return 0;
 
   if ( !hasState( HS_RECVD_INIT ) )
@@ -50,5 +52,5 @@
       PRINTF(0)("initial packet has wrong size %d instead of %d\n", length, _INITIAL_DATA_LENGTH);
       setState( HS_COMPLETED );
-      return;
+      return 0;
     }
 
@@ -57,10 +59,10 @@
       PRINTF(0)("initial packed does not match\n");
       setState( HS_COMPLETED );
-      return;
+      return length;
     }
 
     setState( HS_RECVD_INIT );
     PRINTF(0)("got valid initial packet from client %d\n", clientId);
-    return;
+    return length;
   }
 
@@ -71,5 +73,5 @@
       PRINTF(0)("version number packet has wrong size %d instead of %d\n", length, _ORXONOX_VERSION_LENGTH);
       setState( HS_COMPLETED );
-      return;
+      return 0;
     }
 
@@ -78,5 +80,5 @@
       PRINTF(0)("versions do not match\n");
       setState( HS_COMPLETED );
-      return;
+      return length;
     }
 
@@ -84,14 +86,14 @@
 
     PRINTF(0)("client %d's version does match\n", clientId);
-    return;
+    return length;
   }
 
   if ( !isServer() && hasState( HS_RECVD_VER ) && !hasState( HS_RECVD_HID ) )
   {
-    if ( length != 2 )
+    if ( length != INTSIZE+INTSIZE )
     {
       PRINTF(0)("hostID packet has wrong size %d instead of %d\n", length, 1);
       setState( HS_COMPLETED );
-      return;
+      return 0;
     }
 
@@ -99,6 +101,6 @@
     setState( HS_RECVD_HID );
     this->isOk = true;
-    this->newHostId = data[0];
-    this->newNetworkGameManagerId = data[1];
+    SYNCHELP_READ_INT( this->newHostId );
+    SYNCHELP_READ_INT( this->newNetworkGameManagerId );
 
     if ( newHostId == 0 )
@@ -112,5 +114,5 @@
       PRINTF(0)("got my hostID: %d and networkGameManagerId: %d\n", newHostId, newNetworkGameManagerId);
     }
-    return;
+    return SYNCHELP_READ_N;
   }
 
@@ -120,4 +122,6 @@
 {
   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 ) )
@@ -172,5 +176,6 @@
       isOk = false;
       //memcpy(data, (byte*)0, 4);
-      data[0] = 0;
+      SYNCHELP_WRITE_INT( 0 );
+      SYNCHELP_WRITE_INT( 0 );
     }
     else
@@ -178,9 +183,9 @@
       isOk = true;
       //memcpy(data, &clientId, 4);
-      data[0] = (byte)clientId;
-      data[1] = (byte)networkGameManagerId;
+      SYNCHELP_WRITE_INT( clientId );
+      SYNCHELP_WRITE_INT( networkGameManagerId );
     }
     *reciever = clientId;
-    return 2;
+    return SYNCHELP_WRITE_N;
   }
 
Index: branches/network/src/lib/network/handshake.h
===================================================================
--- branches/network/src/lib/network/handshake.h	(revision 6328)
+++ branches/network/src/lib/network/handshake.h	(revision 6331)
@@ -42,5 +42,5 @@
     inline void       doReject(){ setState(HS_DO_REJECT); }
 
-    virtual void      writeBytes(const byte* data, int length, int sender);
+    virtual int       writeBytes(const byte* data, int length, int sender);
     virtual int       readBytes(byte* data, int maxLength, int * reciever);
     virtual void      writeDebug() const;
Index: branches/network/src/lib/network/network_game_manager.cc
===================================================================
--- branches/network/src/lib/network/network_game_manager.cc	(revision 6328)
+++ branches/network/src/lib/network/network_game_manager.cc	(revision 6331)
@@ -41,5 +41,5 @@
 
   /* set the class id for the base object */
-  this->setClassID(CL_NETWORK_GAME_MANAGER, "EntityManager");
+  this->setClassID(CL_NETWORK_GAME_MANAGER, "NetworkGameManager");
 
   allOutBuffer.length = 0;
@@ -70,5 +70,5 @@
 
 
-void NetworkGameManager::writeBytes(const byte* data, int length, int sender)
+int NetworkGameManager::writeBytes(const byte* data, int length, int sender)
 {
   int i = 0;
@@ -86,5 +86,5 @@
       {
         if ( !handleRequestCreate( i, data, length, sender ) )
-          return;
+          return i;
         continue;
       }
@@ -92,5 +92,5 @@
       {
         if ( !handleRequestRemove( i, data, length, sender ) )
-          return;
+          return i;
         continue;
       }
@@ -101,5 +101,5 @@
       {
         if ( !handleCreateEntity( i, data, length, sender ) )
-          return;
+          return i;
         continue;
       }
@@ -107,5 +107,5 @@
       {
         if ( !handleRemoveEntity( i, data, length, sender ) )
-          return;
+          return i;
         continue;
       }
@@ -113,5 +113,5 @@
       {
         if ( !handleCreateEntityList( i, data, length, sender ) )
-          return;
+          return i;
         continue;
       }
@@ -119,5 +119,5 @@
       {
         if ( !handleRemoveEntityList( i, data, length, sender ) )
-          return;
+          return i;
         continue;
       }
@@ -125,5 +125,5 @@
       {
         if ( !handleYouAreEntity( i, data, length, sender ) )
-          return;
+          return i;
         continue;
       }
@@ -133,5 +133,5 @@
     {
       if ( !handleRequestSync( i, data, length, sender ) )
-        return;
+        return i;
       continue;
     }
@@ -146,6 +146,8 @@
     //if we get her something with data is wrong
     PRINTF(1)("Data is not in the right format! i=%d\n", i);
-    return;
-  }
+    return i;
+  }
+
+  return i;
 }
 
Index: branches/network/src/lib/network/network_game_manager.h
===================================================================
--- branches/network/src/lib/network/network_game_manager.h	(revision 6328)
+++ branches/network/src/lib/network/network_game_manager.h	(revision 6331)
@@ -69,5 +69,5 @@
     { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
 
-    virtual void writeBytes(const byte* data, int length, int sender);
+    virtual int writeBytes(const byte* data, int length, int sender);
     virtual int readBytes(byte* data, int maxLength, int * reciever);
     virtual void writeDebug() const;
Index: branches/network/src/lib/network/network_stream.cc
===================================================================
--- branches/network/src/lib/network/network_stream.cc	(revision 6328)
+++ branches/network/src/lib/network/network_stream.cc	(revision 6331)
@@ -303,5 +303,12 @@
         {
           if ( *it && (*it)->getUniqueID()==header.synchronizeableID )
-            (*it)->writeBytes(upBuffer+sizeof(header), dataLength, i);
+          {
+            if ( (*it)->writeBytes(upBuffer+sizeof(header), dataLength, i) != header.length )
+            {
+              PRINTF(1)("%s did not read all the data!\n", (*it)->getClassName());
+              break;
+            }
+            continue;
+          }
         }
 
Index: branches/network/src/lib/network/synchronizeable.cc
===================================================================
--- branches/network/src/lib/network/synchronizeable.cc	(revision 6328)
+++ branches/network/src/lib/network/synchronizeable.cc	(revision 6331)
@@ -52,5 +52,5 @@
  *  write data to NetworkStream
  */
-void Synchronizeable::writeBytes(const byte* data, int length, int sender)
+int Synchronizeable::writeBytes(const byte* data, int length, int sender)
 {
   PRINTF(5)("Synchronizeable::writeBytes was called\n");
Index: branches/network/src/lib/network/synchronizeable.h
===================================================================
--- branches/network/src/lib/network/synchronizeable.h	(revision 6328)
+++ branches/network/src/lib/network/synchronizeable.h	(revision 6331)
@@ -42,4 +42,5 @@
  * SYNCHELP_READ_STRINGM(s)  allocates memory for string! you have to free this after
  * SYNCHELP_READ_BYTE(b)
+ * SYNCHELP_READ_N
  *
  *
@@ -86,6 +87,10 @@
                                 __synchelp_write_i++; \
 }
-#define SYNCHELP_WRITE_STRING(s) { __synchelp_write_n = \
+#define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) \
+                                __synchelp_write_n = \
                                 Converter::stringToByteArray( s, data+__synchelp_write_i, strlen(s), maxLength-__synchelp_write_i ); \
+                                else \
+                                __synchelp_write_n = \
+                                Converter::stringToByteArray( "", data+__synchelp_write_i, strlen(""), maxLength-__synchelp_write_i ); \
                                 if ( __synchelp_write_n <= 0) \
 { \
@@ -95,5 +100,9 @@
                                 __synchelp_write_i += __synchelp_write_n; \
 }
-#define SYNCHELP_WRITE_N __synchelp_write_i
+#define SYNCHELP_WRITE_N        __synchelp_write_i
+#define SYNCHELP_WRITE_FKT(f)   { \
+                                  __synchelp_write_i += \
+                                  f( data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
+                                }
 
 
@@ -105,5 +114,5 @@
 { \
                                       PRINTF(1)("There is not enough data to read an int\n");  \
-                                      return; \
+                                      return 0; \
 } \
                                     __synchelp_read_i += Converter::byteArrayToInt( data+__synchelp_read_i, &i );  \
@@ -113,5 +122,5 @@
 { \
                                       PRINTF(1)("There is not enough data to read a flaot\n");  \
-                                      return; \
+                                      return 0; \
 } \
                                     __synchelp_read_i += Converter::byteArrayToFloat( data+__synchelp_read_i, &f );  \
@@ -122,5 +131,5 @@
 { \
                                       PRINTF(1)("There is not enough data to read string\n");  \
-                                      return; \
+                                      return 0; \
 } \
                                     __synchelp_read_i += __synchelp_read_n; \
@@ -131,5 +140,5 @@
 { \
                                       PRINTF(1)("There is not enough data to read string\n");  \
-                                      return; \
+                                      return 0; \
 } \
                                     __synchelp_read_i += __synchelp_read_n; \
@@ -139,9 +148,14 @@
 { \
                                       PRINTF(1)("There is not enough data to read a byte\n");  \
-                                      return; \
+                                      return 0; \
 } \
                                     b = data[__synchelp_read_i]; \
                                     __synchelp_read_i ++;  \
 }
+#define SYNCHELP_READ_FKT(f)   { \
+                                  __synchelp_read_i += \
+                                  f( data+__synchelp_read_i, length-__synchelp_read_i, sender); \
+                                  }
+#define SYNCHELP_READ_N           __synchelp_read_i
 
 class NetworkStream;
@@ -154,5 +168,5 @@
     ~Synchronizeable();
 
-    virtual void      writeBytes(const byte* data, int length, int sender);
+    virtual int       writeBytes(const byte* data, int length, int sender);
     virtual int       readBytes(byte* data, int maxLength, int * reciever);
     virtual void      writeDebug() const;
Index: branches/network/src/subprojects/network/read_sync.cc
===================================================================
--- branches/network/src/subprojects/network/read_sync.cc	(revision 6328)
+++ branches/network/src/subprojects/network/read_sync.cc	(revision 6331)
@@ -60,5 +60,5 @@
  *  write data to Synchronizeable
  */
-void ReadSync::writeBytes(const byte* data, int length, int sender)
+int ReadSync::writeBytes(const byte* data, int length, int sender)
 {
   PRINTF(0)("ReadSync: got %i bytes of data\n", length);
Index: branches/network/src/subprojects/network/read_sync.h
===================================================================
--- branches/network/src/subprojects/network/read_sync.h	(revision 6328)
+++ branches/network/src/subprojects/network/read_sync.h	(revision 6331)
@@ -16,5 +16,5 @@
     ~ReadSync();
 
-    virtual void writeBytes(const byte* data, int length, int sender);
+    virtual int writeBytes(const byte* data, int length, int sender);
     virtual int readBytes(byte* data, int maxLength, int * reciever);
 
Index: branches/network/src/subprojects/network/simple_sync.cc
===================================================================
--- branches/network/src/subprojects/network/simple_sync.cc	(revision 6328)
+++ branches/network/src/subprojects/network/simple_sync.cc	(revision 6331)
@@ -66,5 +66,5 @@
  *  write data to Synchronizeable
  */
-void SimpleSync::writeBytes(const byte* data, int length, int sender)
+int SimpleSync::writeBytes(const byte* data, int length, int sender)
 {
   PRINTF(0)("SimpleSync: got %i bytes of data\n", length);
Index: branches/network/src/subprojects/network/simple_sync.h
===================================================================
--- branches/network/src/subprojects/network/simple_sync.h	(revision 6328)
+++ branches/network/src/subprojects/network/simple_sync.h	(revision 6331)
@@ -16,5 +16,5 @@
     ~SimpleSync();
 
-    virtual void writeBytes(const byte* data, int length, int sender);
+    virtual int writeBytes(const byte* data, int length, int sender);
     virtual int readBytes(byte* data, int maxLength, int * reciever);
 
Index: branches/network/src/subprojects/network/write_sync.cc
===================================================================
--- branches/network/src/subprojects/network/write_sync.cc	(revision 6328)
+++ branches/network/src/subprojects/network/write_sync.cc	(revision 6331)
@@ -66,5 +66,5 @@
  *  write data to Synchronizeable
  */
-void WriteSync::writeBytes(const byte* data, int length, int sender)
+int WriteSync::writeBytes(const byte* data, int length, int sender)
 {
   PRINTF(0)("WriteSync: got %i bytes of data\n", length);
Index: branches/network/src/subprojects/network/write_sync.h
===================================================================
--- branches/network/src/subprojects/network/write_sync.h	(revision 6328)
+++ branches/network/src/subprojects/network/write_sync.h	(revision 6331)
@@ -16,5 +16,5 @@
     ~WriteSync();
 
-    virtual void writeBytes(const byte* data, int length, int sender);
+    virtual int writeBytes(const byte* data, int length, int sender);
     virtual int readBytes(byte* data, int maxLength, int * reciever);
 
Index: branches/network/src/world_entities/skybox.cc
===================================================================
--- branches/network/src/world_entities/skybox.cc	(revision 6328)
+++ branches/network/src/world_entities/skybox.cc	(revision 6331)
@@ -220,5 +220,5 @@
 }
 
-void SkyBox::writeBytes( const byte * data, int length, int sender )
+int SkyBox::writeBytes( const byte * data, int length, int sender )
 {
   setRequestedSync( false );
@@ -226,4 +226,7 @@
 
   SYNCHELP_READ_BEGIN();
+
+  SYNCHELP_READ_FKT( WorldEntity::writeState );
+
   SYNCHELP_READ_FLOAT( size );
   if ( textureName )
@@ -239,4 +242,6 @@
   this->setTextureAndType( textureName, "jpg" );
   this->rebuild();
+
+  return SYNCHELP_READ_N;
 }
 
@@ -258,4 +263,7 @@
 
     SYNCHELP_WRITE_BEGIN();
+
+    SYNCHELP_WRITE_FKT( WorldEntity::readState );
+
     SYNCHELP_WRITE_FLOAT(this->size);
     SYNCHELP_WRITE_STRING(this->textureName);
Index: branches/network/src/world_entities/skybox.h
===================================================================
--- branches/network/src/world_entities/skybox.h	(revision 6328)
+++ branches/network/src/world_entities/skybox.h	(revision 6331)
@@ -41,5 +41,5 @@
                    const char* right, const char* front, const char* back);
 
-  virtual void      writeBytes(const byte* data, int length, int sender);
+  virtual int       writeBytes(const byte* data, int length, int sender);
   virtual int       readBytes(byte* data, int maxLength, int * reciever);
   virtual void      writeDebug() const;
Index: branches/network/src/world_entities/terrain.cc
===================================================================
--- branches/network/src/world_entities/terrain.cc	(revision 6328)
+++ branches/network/src/world_entities/terrain.cc	(revision 6331)
@@ -319,10 +319,13 @@
 }
 
-void Terrain::writeBytes( const byte * data, int length, int sender )
+int Terrain::writeBytes( const byte * data, int length, int sender )
 {
   setRequestedSync( false );
   setIsOutOfSync( false );
 
-  WorldEntity::writeState(data, length, sender);
+  SYNCHELP_READ_BEGIN();
+  SYNCHELP_READ_FKT( WorldEntity::writeState );
+
+  return SYNCHELP_READ_N;
 }
 
Index: branches/network/src/world_entities/terrain.h
===================================================================
--- branches/network/src/world_entities/terrain.h	(revision 6328)
+++ branches/network/src/world_entities/terrain.h	(revision 6331)
@@ -30,5 +30,5 @@
   virtual ~Terrain();
 
-  virtual void      writeBytes(const byte* data, int length, int sender);
+  virtual int       writeBytes(const byte* data, int length, int sender);
   virtual int       readBytes(byte* data, int maxLength, int * reciever);
   virtual void      writeDebug() const;
Index: branches/network/src/world_entities/weapons/ground_turret.cc
===================================================================
--- branches/network/src/world_entities/weapons/ground_turret.cc	(revision 6328)
+++ branches/network/src/world_entities/weapons/ground_turret.cc	(revision 6331)
@@ -19,4 +19,5 @@
 
 #include "factory.h"
+#include "network_game_manager.h"
 #include "load_param.h"
 
@@ -168,2 +169,49 @@
 
 }
+
+/**
+ * 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 );
+
+  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 );
+
+  }
+
+  *reciever = 0;
+  return SYNCHELP_WRITE_N;
+}
Index: branches/network/src/world_entities/weapons/ground_turret.h
===================================================================
--- branches/network/src/world_entities/weapons/ground_turret.h	(revision 6328)
+++ branches/network/src/world_entities/weapons/ground_turret.h	(revision 6331)
@@ -30,4 +30,7 @@
   virtual void collidesWith (WorldEntity* entity, const Vector& location);
 
+  virtual int writeBytes(const byte* data, int length, int sender);
+  virtual int readBytes(byte* data, int maxLength, int * reciever);
+
  private:
    Weapon *left, *right;
Index: branches/network/src/world_entities/world_entity.cc
===================================================================
--- branches/network/src/world_entities/world_entity.cc	(revision 6328)
+++ branches/network/src/world_entities/world_entity.cc	(revision 6331)
@@ -335,8 +335,11 @@
  * @param sender hostID of sender
  */
-void WorldEntity::writeState( const byte * data, int length, int sender )
+int WorldEntity::writeState( const byte * data, int length, int sender )
 {
   char* modelFileName;
   SYNCHELP_READ_BEGIN();
+
+  SYNCHELP_READ_FKT( PNode::writeState );
+
   SYNCHELP_READ_STRINGM( modelFileName );
   //check if modelFileName is relative to datadir or absolute
@@ -350,4 +353,6 @@
   }
   delete[] modelFileName;
+
+  return SYNCHELP_READ_N;
 }
 
@@ -361,4 +366,7 @@
 {
   SYNCHELP_WRITE_BEGIN();
+
+  SYNCHELP_WRITE_FKT( PNode::readState );
+
   SYNCHELP_WRITE_STRING( getModel( 0 )->getName() );
   PRINTF(0)("%s\n", getModel( 0 )->getName());
Index: branches/network/src/world_entities/world_entity.h
===================================================================
--- branches/network/src/world_entities/world_entity.h	(revision 6328)
+++ branches/network/src/world_entities/world_entity.h	(revision 6331)
@@ -73,6 +73,6 @@
   std::list<WorldEntity*>::iterator& getEntityIterator() { return this->objectListIterator; }
 
-  virtual void      writeState(const byte* data, int length, int sender);
-  virtual int       readState(byte* data, int maxLength );
+  int       writeState(const byte* data, int length, int sender);
+  int       readState(byte* data, int maxLength );
  protected:
   //  CharacterAttributes*    charAttr;         //!< the character attributes of a world_entity
