Index: trunk/src/lib/network/handshake.cc
===================================================================
--- trunk/src/lib/network/handshake.cc	(revision 6753)
+++ trunk/src/lib/network/handshake.cc	(revision 6815)
@@ -95,16 +95,16 @@
   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, 1);
-      setState( HS_COMPLETED );
-      return 0;
-    }
+    /*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 );
-    SYNCHELP_READ_INT( this->newNetworkGameManagerId );
+    SYNCHELP_READ_INT( this->newHostId, NWT_HS_HOST_ID );
+    SYNCHELP_READ_INT( this->newNetworkGameManagerId, NWT_HS_NGM_ID );
 
     if ( newHostId == 0 )
@@ -180,6 +180,6 @@
       isOk = false;
       //memcpy(data, (byte*)0, 4);
-      SYNCHELP_WRITE_INT( 0 );
-      SYNCHELP_WRITE_INT( 0 );
+      SYNCHELP_WRITE_INT( 0, NWT_HS_HOST_ID);
+      SYNCHELP_WRITE_INT( 0, NWT_HS_NGM_ID);
     }
     else
@@ -187,6 +187,6 @@
       isOk = true;
       //memcpy(data, &clientId, 4);
-      SYNCHELP_WRITE_INT( clientId );
-      SYNCHELP_WRITE_INT( networkGameManagerId );
+      SYNCHELP_WRITE_INT( clientId, NWT_HS_HOST_ID );
+      SYNCHELP_WRITE_INT( networkGameManagerId, NWT_HS_NGM_ID );
     }
     *reciever = clientId;
Index: trunk/src/lib/network/network_game_manager.cc
===================================================================
--- trunk/src/lib/network/network_game_manager.cc	(revision 6753)
+++ trunk/src/lib/network/network_game_manager.cc	(revision 6815)
@@ -167,9 +167,8 @@
   if ( !isServer() && !hasRequestedWorld )
   {
-    SYNCHELP_WRITE_BEGIN();
-    byte b = NET_REQUEST_ENTITY_LIST;
-    SYNCHELP_WRITE_BYTE( b );
+    assert( maxLength >= 1 );
+    data[0] = NET_REQUEST_ENTITY_LIST;
     hasRequestedWorld = true;
-    return SYNCHELP_WRITE_N;
+    return 1;
   }
 
Index: trunk/src/lib/network/synchronizeable.h
===================================================================
--- trunk/src/lib/network/synchronizeable.h	(revision 6753)
+++ trunk/src/lib/network/synchronizeable.h	(revision 6815)
@@ -20,4 +20,76 @@
 #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_HS_HOST_ID,
+  NWT_HS_NGM_ID,
+  
+  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
+};
 
 
@@ -58,7 +130,25 @@
  *
  */
+#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) { __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 ); \
@@ -70,5 +160,6 @@
                                 __synchelp_write_i += __synchelp_write_n; \
 }
-#define SYNCHELP_WRITE_FLOAT(f) { __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 ); \
@@ -80,5 +171,6 @@
                                 __synchelp_write_i += __synchelp_write_n; \
 }
-#define SYNCHELP_WRITE_BYTE(b) { \
+#define SYNCHELP_WRITE_BYTE(b,n) { SYNCHELP_WRITE_DEBUG(n); \
+                                \
                                 if (maxLength - __synchelp_write_i < 1) \
 { \
@@ -89,5 +181,6 @@
                                 __synchelp_write_i++; \
 }
-#define SYNCHELP_WRITE_STRING(s) { if (s!=NULL) {\
+#define SYNCHELP_WRITE_STRING(s,n) { SYNCHELP_WRITE_DEBUG(n); \
+                                if (s!=NULL) {\
                                 __synchelp_write_n = \
                                 Converter::stringToByteArray( s, data+__synchelp_write_i, strlen(s), maxLength-__synchelp_write_i ); \
@@ -105,5 +198,5 @@
 }
 #define SYNCHELP_WRITE_N        __synchelp_write_i
-#define SYNCHELP_WRITE_FKT(f)   { \
+#define SYNCHELP_WRITE_FKT(f,n)   { SYNCHELP_WRITE_DEBUG(n); \
                                   __synchelp_write_i += \
                                   f( data+__synchelp_write_i, maxLength-__synchelp_write_i ); \
@@ -114,5 +207,5 @@
                                   int __synchelp_read_n
 
-#define SYNCHELP_READ_INT(i)       { \
+#define SYNCHELP_READ_INT(i,n)       { SYNCHELP_READ_DEBUG(n); \
                                     if ( length-__synchelp_read_i < INTSIZE ) \
 { \
@@ -124,5 +217,5 @@
                                     __synchelp_read_i += __synchelp_read_n; \
 }
-#define SYNCHELP_READ_FLOAT(f)    { \
+#define SYNCHELP_READ_FLOAT(f,n)    { SYNCHELP_READ_DEBUG(n); \
                                     if ( length-__synchelp_read_i < FLOATSIZE ) \
 { \
@@ -134,5 +227,5 @@
                                     __synchelp_read_i += __synchelp_read_n; \
 }
-#define SYNCHELP_READ_STRING(s,l)    { \
+#define SYNCHELP_READ_STRING(s,l,n)    {SYNCHELP_READ_DEBUG(n); \
                                     __synchelp_read_n = Converter::byteArrayToString( data+__synchelp_read_i, s, l );  \
                                     assert( __synchelp_read_n == strlen(s)+INTSIZE ) ;\
@@ -144,5 +237,5 @@
                                     __synchelp_read_i += __synchelp_read_n; \
 }
-#define SYNCHELP_READ_STRINGM(s)    { \
+#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 ) ;\
@@ -154,5 +247,5 @@
                                     __synchelp_read_i += __synchelp_read_n; \
 }
-#define SYNCHELP_READ_BYTE(b)      { \
+#define SYNCHELP_READ_BYTE(b,n)      { SYNCHELP_READ_DEBUG(n); \
                                     if ( length-__synchelp_read_i < 1 ) \
 { \
@@ -163,8 +256,10 @@
                                     __synchelp_read_i ++;  \
 }
-#define SYNCHELP_READ_FKT(f)   { \
+#define SYNCHELP_READ_FKT(f,n)   { SYNCHELP_READ_DEBUG(n); \
                                   __synchelp_read_i += \
                                   f( data+__synchelp_read_i, length-__synchelp_read_i, sender); \
                                   }
+#define SYNCHELP_READ_REMAINING() ( length-__synchelp_read_i )
+#define SYNCHELP_READ_NEXTBYTE() ( data[__synchelp_read_i] )
 #define SYNCHELP_READ_N           __synchelp_read_i
 
