Index: /code/branches/presentation3/src/libraries/network/packet/Gamestate.cc
===================================================================
--- /code/branches/presentation3/src/libraries/network/packet/Gamestate.cc	(revision 7158)
+++ /code/branches/presentation3/src/libraries/network/packet/Gamestate.cc	(revision 7159)
@@ -405,4 +405,5 @@
     {
       SynchronisableHeader htemp(temp);
+      assert( htemp.getDataSize()!=0 );
       if ( htemp.getObjectID() == objectID )
       {
@@ -410,8 +411,28 @@
         goto DODIFF;
       }
+//       {
+//         SynchronisableHeader htemp2(temp+htemp.getDataSize()+SynchronisableHeader::getSize());
+//         if( temp+htemp.getDataSize()+SynchronisableHeader::getSize() < baseData+baseLength )
+//         {
+//           assert(htemp2.getClassID()<500);
+//           assert(htemp2.getDataSize()!=0 && htemp2.getDataSize()<1000);
+//           assert(htemp2.isDiffed()==false);
+//         }
+//       }
       temp += htemp.getDataSize()+SynchronisableHeader::getSize();
+        
     }
     // If not found start looking at the beginning
+    assert( temp==baseData+baseLength );
     temp = baseData;
+//     {
+//       SynchronisableHeader htemp2(temp);
+//       if( temp < baseData+baseLength )
+//       {
+//         assert(htemp2.getClassID()<500);
+//         assert(htemp2.getDataSize()!=0 && htemp2.getDataSize()<1000);
+//         assert(htemp2.isDiffed()==false);
+//       }
+//     }
     while ( temp < baseData+baseOffset )
     {
@@ -422,4 +443,13 @@
         goto DODIFF;
       }
+//       {
+//         SynchronisableHeader htemp2(temp+htemp.getDataSize()+SynchronisableHeader::getSize());
+//         if( temp+htemp.getDataSize()+SynchronisableHeader::getSize() < baseData+baseLength )
+//         {
+//           assert(htemp2.getClassID()<500);
+//           assert(htemp2.getDataSize()!=0 && htemp2.getDataSize()<1000);
+//           assert(htemp2.isDiffed()==false);
+//         }
+//       }
       temp += htemp.getDataSize()+SynchronisableHeader::getSize();
     }
@@ -430,4 +460,5 @@
 DODIFF:
     {
+//       COUT(4) << "dodiff" << endl;
 //       if(baseOffset==0)
 //       {
@@ -438,4 +469,5 @@
       if( memcmp( origData+origOffset+objectOffset, temp+objectOffset, h.getDataSize()) == 0 )
       {
+//         COUT(4) << "skip object" << Synchronisable::getSynchronisable(h.getObjectID())->getIdentifier()->getName() << endl;
         origOffset += objectOffset+ h.getDataSize(); // skip the whole object
         baseOffset = temp + h.getDataSize()+SynchronisableHeader::getSize() - baseData;
@@ -444,4 +476,7 @@
       else
       {
+//         if( Synchronisable::getSynchronisable(h.getObjectID())->getIdentifier()->getName() == "Bot" )
+//           COUT(0) << "blub" << endl;
+//         COUT(4) << "object diff: " << Synchronisable::getSynchronisable(h.getObjectID())->getIdentifier()->getName() << endl;
 //         COUT(4) << "diff " << h.getObjectID() << ":";
         // Now start to diff the Object
@@ -462,5 +497,5 @@
             if ( memcmp(origData+origOffset+objectOffset, temp+objectOffset, varSize) != 0 )
             {
-//               COUT(4) << " c" << varSize;
+//               COUT(4) << "copy variable" << endl;
               *(VariableID*)(dest+newObjectOffset) = variableID; // copy over the variableID
               newObjectOffset += sizeof(VariableID);
@@ -471,12 +506,15 @@
             else
             {
-//               COUT(4) << " s" << varSize;
+//               COUT(4) << "skip variable" << endl;
               objectOffset += varSize;
             }
           }
+//           else
+//             COUT(4) << "varsize 0" << endl;
 
           ++variableID;
           ++sizes;
         }
+        
         if( Synchronisable::getSynchronisable(h.getObjectID())->getNrOfVariables() != variableID )
           sizes += Synchronisable::getSynchronisable(h.getObjectID())->getNrOfVariables() - variableID;
@@ -486,5 +524,18 @@
         assert(objectOffset == h.getDataSize()+SynchronisableHeader::getSize());
         origOffset += objectOffset;
-        baseOffset += temp + h.getDataSize()+SynchronisableHeader::getSize() - baseData;
+//         baseOffset += temp + h.getDataSize()+SynchronisableHeader::getSize() - baseData;
+        //baseOffset += objectOffset;
+//         SynchronisableHeader htemp(temp);
+//         baseOffset += SynchronisableHeader::getSize() + htemp.getDataSize();
+//         {
+//           SynchronisableHeader htemp2( baseData+(temp-baseData+objectOffset) );
+//           if( baseData+(temp-baseData+objectOffset) < baseData+baseLength )
+//           {
+//             assert(htemp2.getClassID()<500);
+//             assert(htemp2.getDataSize()!=0 && htemp2.getDataSize()<1000);
+//             assert(htemp2.isDiffed()==false);
+//           }
+//         }
+        baseOffset = temp-baseData + objectOffset;
         dest += newObjectOffset;
       }
@@ -495,4 +546,5 @@
 DOCOPY:
     {
+//       COUT(4) << "docopy" << endl;
       // Just copy over the whole Object
       memcpy( dest, origData+origOffset, h.getDataSize()+SynchronisableHeader::getSize() );
Index: /code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- /code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.h	(revision 7158)
+++ /code/branches/presentation3/src/libraries/network/synchronisable/Synchronisable.h	(revision 7159)
@@ -89,7 +89,7 @@
         { return 14; }
       inline uint16_t getDataSize() const
-        { return (*(uint16_t*)data_) & 0x7FFF; } //only use the first 31 bits
+        { return (*(uint16_t*)data_) & 0x7FFF; } //only use the first 15 bits
       inline void setDataSize(uint16_t size)
-        { *(uint16_t*)(data_) = (size & 0x7FFFFFFF) | (*(uint16_t*)(data_) & 0x8000 ); }
+        { *(uint16_t*)(data_) = (size & 0x7FFF) | (*(uint16_t*)(data_) & 0x8000 ); }
       inline bool isDiffed() const
         { return ( (*(uint16_t*)data_) & 0x8000 ) == 0x8000; }
