Index: /branches/network/src/lib/network/handshake.cc
===================================================================
--- /branches/network/src/lib/network/handshake.cc	(revision 7601)
+++ /branches/network/src/lib/network/handshake.cc	(revision 7602)
@@ -34,11 +34,11 @@
   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" ) );
+  orxId_handler = registerVarId( new SynchronizeableInt( &localState.orxId, &remoteState.orxId, "orxonoxId", PERMISSION_ALL ) );
+  version_handler = registerVarId( new SynchronizeableInt( &localState.version, &remoteState.version, "version", PERMISSION_ALL ) );
+  netManId_handler = registerVarId( new SynchronizeableInt( &localState.networkManagerId, &remoteState.networkManagerId, "networkManagerId", PERMISSION_ALL ) );
+  hostId_handler = registerVarId( new SynchronizeableInt( &localState.hostId, &remoteState.hostId, "hostId", PERMISSION_ALL ) );
+  completed_handler = registerVarId( new SynchronizeableInt( &localState.completed, &remoteState.completed, "completed", PERMISSION_ALL ) );
+  error_handler = registerVarId( new SynchronizeableInt( &localState.error, &remoteState.error, "error", PERMISSION_ALL ) );
+  errorString_handler = registerVarId( new SynchronizeableString( &localState.errorString, &remoteState.errorString, "errorString", PERMISSION_ALL ) );
   
   localState.completed = false;
Index: /branches/network/src/lib/network/network_stream.cc
===================================================================
--- /branches/network/src/lib/network/network_stream.cc	(revision 7601)
+++ /branches/network/src/lib/network/network_stream.cc	(revision 7602)
@@ -163,6 +163,7 @@
   if (disconnectSynchro != this->synchronizeables.end())
     this->synchronizeables.erase(disconnectSynchro);
-
-  this->bActive = false;
+  
+  //TODO set timestamp
+  oldSynchronizeables[sync.getUniqueID()] = 0;
 }
 
@@ -462,5 +463,5 @@
 
           PRINT(0)("handshake finished id=%d\n", it->second.handshake->getNetworkGameManagerId());
-
+          assert(false);
 
           delete it->second.handshake;
@@ -471,4 +472,5 @@
           PRINT(1)("handshake failed!\n");
           it->second.socket->disconnectServer();
+          assert(false);
         }
       }
@@ -529,5 +531,11 @@
       offset += n;
       
-      offset += sync.getStateDiff( peer->second.userId, buf + offset, UDP_PACKET_SIZE-offset, currentState, peer->second.lastAckedState, 0 );
+      //make space for size
+      offset += INTSIZE;
+      
+      n = sync.getStateDiff( peer->second.userId, buf + offset, UDP_PACKET_SIZE-offset, currentState, peer->second.lastAckedState, 0 );
+      offset += n;
+      
+      assert( Converter::intToByteArray( n, buf + offset - n, INTSIZE ) == INTSIZE );
     }
     
@@ -535,5 +543,6 @@
     
     assert( peer->second.socket->writePacket( buf, offset ) );
-    PRINTF(0)("send packet: %d\n", offset);
+    PRINTF(0)("send packet: %d userId = %d %x %d\n", offset, peer->second.userId, peer->second.handshake->getLeafClassID(), peer->second.handshake->getUniqueID());
+    assert( peer->second.handshake->getLeafClassID() == CL_HANDSHAKE );
   }
 }
@@ -553,4 +562,5 @@
   int ackedState = 0;
   int fromState = 0;
+  int syncDataLength = 0;
   
   for ( PeerList::iterator peer = peers.begin(); peer != peers.end(); peer++ )
@@ -592,4 +602,7 @@
       offset += INTSIZE;
       
+      assert( Converter::byteArrayToInt( buf + offset, &syncDataLength ) == INTSIZE );
+      offset += INTSIZE;
+      
       Synchronizeable * sync = NULL;
       
@@ -606,4 +619,10 @@
       if ( sync == NULL )
       {
+        if ( oldSynchronizeables.find( uniqueId ) != oldSynchronizeables.end() )
+        {
+          offset += syncDataLength;
+          continue;
+        }
+        
         //TODO dont accept new object from all peers (probably only servers)
         int leafClassId;
Index: /branches/network/src/lib/network/network_stream.h
===================================================================
--- /branches/network/src/lib/network/network_stream.h	(revision 7601)
+++ /branches/network/src/lib/network/network_stream.h	(revision 7602)
@@ -98,4 +98,6 @@
 
     NetworkGameManager*        networkGameManager;
+
+    std::map<int,int>          oldSynchronizeables;
 };
 #endif /* _NETWORK_STREAM */
Index: /branches/network/src/lib/network/synchronizeable.cc
===================================================================
--- /branches/network/src/lib/network/synchronizeable.cc	(revision 7601)
+++ /branches/network/src/lib/network/synchronizeable.cc	(revision 7602)
@@ -52,5 +52,5 @@
   /* make sure loadClassId is first synced var because this is read by networkStream */
   assert( syncVarList.size() == 0 );
-  this->registerVar( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) );
+  mLeafClassId = this->registerVarId( new SynchronizeableInt( (int*)&this->getLeafClassID(), (int*)&this->getLeafClassID(), "leafClassId" ) );
     
   this->registerVar( new SynchronizeableInt( &this->owner, &this->owner, "owner" ) );
@@ -189,4 +189,5 @@
       for ( int j = 0; j < (*it)->getSize(); it++ )
       {
+        assert(false);
         stateTo->data[i] = 0;
         i++;
@@ -321,4 +322,6 @@
 void Synchronizeable::varChangeHandler( std::list<int> & id )
 {
+  for ( std::list<int>::iterator it = id.begin(); it != id.end(); it++ )
+    assert( *it != mLeafClassId );
 }
 
@@ -345,2 +348,3 @@
 
 
+
