Index: code/branches/network/src/network/packet/Gamestate.cc
===================================================================
--- code/branches/network/src/network/packet/Gamestate.cc	(revision 1774)
+++ code/branches/network/src/network/packet/Gamestate.cc	(revision 1775)
@@ -46,4 +46,5 @@
 #define HEADER GAMESTATE_HEADER(data_)
 
+  
 Gamestate::Gamestate()
 {
@@ -80,5 +81,5 @@
   orxonox::ObjectList<Synchronisable>::iterator it;
   for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){
-    tempsize=it->getSize2(id, mode);
+    tempsize=it->getSize(id, mode);
 
     if(currentsize+tempsize > size){
@@ -88,5 +89,5 @@
       int addsize=tempsize;
       while(++temp)
-        addsize+=temp->getSize2(id, mode);
+        addsize+=temp->getSize(id, mode);
       data_ = (unsigned char *)realloc(data_, sizeof(GamestateHeader) + currentsize + addsize);
       if(!data_)
@@ -105,5 +106,5 @@
   HEADER->packetType = ENUM::Gamestate;
   assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);
-  HEADER->normsize = currentsize;
+  HEADER->datasize = currentsize;
   HEADER->id = id;
   HEADER->diffed = false;
@@ -125,44 +126,31 @@
   unsigned char *mem=data_+sizeof(GamestateHeader);
     // get the start of the Synchronisable list
-  orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
-
-  while(mem < data_+sizeof(GamestateHeader)+HEADER->normsize){
-      // extract synchronisable header
+  //orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
+  Synchronisable *s;
+
+  // update the data of the objects we received
+  while(mem < data_+sizeof(GamestateHeader)+HEADER->datasize){
     size = *(unsigned int *)mem;
     objectID = *(unsigned int*)(mem+sizeof(unsigned int));
     classID = *(unsigned int*)(mem+2*sizeof(unsigned int));
 
-    if(!it || it->objectID!=objectID || it->classID!=classID){
-        // bad luck ;)
-        // delete the synchronisable (obviously seems to be deleted on the server)
-      while(it && it->objectID!=objectID)
-        removeObject(it);
-
-      if(!it){
-        //fabricate the new synchronisable
-        if(!Synchronisable::fabricate(mem, mode))
-          return false;
-        it=orxonox::ObjectList<Synchronisable>::end();
-      }else{
-	if(! it->updateData(mem, mode))
-        {
-          COUT(1) << "We couldn't update objectID: " \
-            << objectID << "; classID: " << classID << std::endl;
-        }
-      }
-    } else
+    s = Synchronisable::getSynchronisable( objectID );
+    if(!s)
     {
-        // we have our object
-      if(! it->updateData(mem, mode))
-      {
-        COUT(1) << "We couldn't update objectID: " \
-            << objectID << "; classID: " << classID << std::endl;
-      }
+      s = Synchronisable::fabricate(mem, mode);
+      if(!s)
+        return false;
     }
-    ++it;
-  }
-
-  return true;
-}
+    else
+    {
+      if(!s->updateData(mem, mode))
+        return false;
+    }
+  }
+
+  return true;
+}
+
+
 
 int Gamestate::getID(){
@@ -177,5 +165,5 @@
   else
   {
-    return HEADER->normsize+sizeof(GamestateHeader);
+    return HEADER->datasize+sizeof(GamestateHeader);
   }
 }
@@ -186,5 +174,5 @@
   assert(!isCompressed());
   assert(!gs.isCompressed());
-  while(d1<data_+HEADER->normsize)
+  while(d1<data_+HEADER->datasize)
   {
     if(*d1!=*d2)
@@ -205,5 +193,5 @@
   assert(HEADER);
   assert(!HEADER->compressed);
-  uLongf buffer = (uLongf)(((HEADER->normsize + 12)*1.01)+1);
+  uLongf buffer = (uLongf)(((HEADER->datasize + 12)*1.01)+1);
   if(buffer==0)
     return false;
@@ -214,5 +202,5 @@
   unsigned char *source = GAMESTATE_START(data_);
   int retval;
-  retval = compress( dest, &buffer, source, (uLong)(HEADER->normsize) );
+  retval = compress( dest, &buffer, source, (uLong)(HEADER->datasize) );
   switch ( retval ) {
     case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
@@ -223,9 +211,9 @@
 #ifndef NDEBUG
   //decompress and compare the start and the decompressed data
-  unsigned char *rdata = new unsigned char[HEADER->normsize+sizeof(GamestateHeader)];
+  unsigned char *rdata = new unsigned char[HEADER->datasize+sizeof(GamestateHeader)];
   unsigned char *d2 = GAMESTATE_START(rdata);
-  uLongf length2 = HEADER->normsize;
+  uLongf length2 = HEADER->datasize;
   uncompress(d2, &length2, dest, buffer);
-  for(unsigned int i=0; i<HEADER->normsize; i++){
+  for(unsigned int i=0; i<HEADER->datasize; i++){
     assert(*(source+i)==*(d2+i));
   }
@@ -235,5 +223,5 @@
   //copy and modify header
 #ifndef NDEBUG
-  HEADER->crc32 = calcCRC(data_+sizeof(GamestateHeader), HEADER->normsize);
+  HEADER->crc32 = calcCRC(data_+sizeof(GamestateHeader), HEADER->datasize);
 #endif
   *GAMESTATE_HEADER(ndata) = *HEADER;
@@ -245,5 +233,5 @@
   HEADER->compressed = true;
   assert(HEADER->compressed);
-  COUT(3) << "gamestate compress normsize: " << HEADER->normsize << " compsize: " << HEADER->compsize << std::endl;
+  COUT(3) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl;
   return true;
 }
@@ -252,10 +240,10 @@
   assert(HEADER);
   assert(HEADER->compressed);
-  COUT(3) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", normsize: " << HEADER->normsize << ", compsize: " << HEADER->compsize << std::endl;
-  unsigned int normsize = HEADER->normsize;
+  COUT(3) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
+  unsigned int datasize = HEADER->datasize;
   unsigned int compsize = HEADER->compsize;
   unsigned int bufsize;
-  assert(compsize<=normsize);
-  bufsize = normsize;
+  assert(compsize<=datasize);
+  bufsize = datasize;
   assert(bufsize!=0);
   unsigned char *ndata = new unsigned char[bufsize + sizeof(GamestateHeader)];
@@ -272,5 +260,5 @@
   }
 #ifndef NDEBUG
-  assert(HEADER->crc32==calcCRC(ndata+sizeof(GamestateHeader), HEADER->normsize));
+  assert(HEADER->crc32==calcCRC(ndata+sizeof(GamestateHeader), HEADER->datasize));
 #endif
 
@@ -282,5 +270,5 @@
   data_ = ndata;
   HEADER->compressed = false;
-  assert(HEADER->normsize==normsize);
+  assert(HEADER->datasize==datasize);
   assert(HEADER->compsize==compsize);
   return true;
@@ -296,16 +284,16 @@
   unsigned int of=0; // pointers offset
   unsigned int dest_length=0;
-  dest_length=HEADER->normsize;
+  dest_length=HEADER->datasize;
   if(dest_length==0)
     return NULL;
   unsigned char *ndata = new unsigned char[dest_length*sizeof(unsigned char)+sizeof(GamestateHeader)];
   unsigned char *dest = ndata + sizeof(GamestateHeader);
-  while(of < GAMESTATE_HEADER(base->data_)->normsize && of < HEADER->normsize){
+  while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){
     *(dest+of)=*(basep+of)^*(gs+of); // do the xor
     ++of;
   }
-  if(GAMESTATE_HEADER(base->data_)->normsize!=HEADER->normsize){
+  if(GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){
     unsigned char n=0;
-    if(GAMESTATE_HEADER(base->data_)->normsize < HEADER->normsize){
+    if(GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){
       while(of<dest_length){
         *(dest+of)=n^*(gs+of);
@@ -334,16 +322,16 @@
   unsigned int of=0; // pointers offset
   unsigned int dest_length=0;
-  dest_length=HEADER->normsize;
+  dest_length=HEADER->datasize;
   if(dest_length==0)
     return NULL;
   unsigned char *ndata = new unsigned char[dest_length*sizeof(unsigned char)+sizeof(GamestateHeader)];
   unsigned char *dest = ndata + sizeof(GamestateHeader);
-  while(of < GAMESTATE_HEADER(base->data_)->normsize && of < HEADER->normsize){
+  while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){
     *(dest+of)=*(basep+of)^*(gs+of); // do the xor
     ++of;
   }
-  if(GAMESTATE_HEADER(base->data_)->normsize!=HEADER->normsize){
+  if(GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){
     unsigned char n=0;
-    if(GAMESTATE_HEADER(base->data_)->normsize < HEADER->normsize){
+    if(GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){
       while(of < dest_length){
         *(dest+of)=n^*(gs+of);
@@ -370,5 +358,5 @@
     // get total size of gamestate
   for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it)
-    size+=it->getSize2(id, mode); // size of the actual data of the synchronisable
+    size+=it->getSize(id, mode); // size of the actual data of the synchronisable
 //  size+=sizeof(GamestateHeader);
   return size;
