Index: code/trunk/src/network/packet/Gamestate.cc
===================================================================
--- code/trunk/src/network/packet/Gamestate.cc	(revision 2087)
+++ code/trunk/src/network/packet/Gamestate.cc	(revision 2171)
@@ -38,5 +38,5 @@
 
 
-namespace network {
+namespace orxonox {
 
 namespace packet {
@@ -71,9 +71,9 @@
 }
 
-bool Gamestate::collectData(int id, int mode)
-{
-  int tempsize=0, currentsize=0;
+bool Gamestate::collectData(int id, uint8_t mode)
+{
+  unsigned int tempsize=0, currentsize=0;
   assert(data_==0);
-  int size = calcGamestateSize(id, mode);
+  unsigned int size = calcGamestateSize(id, mode);
 
   COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
@@ -86,19 +86,16 @@
   }
 
-#ifndef NDEBUG
-  std::list<Synchronisable*> slist;
-  std::list<Synchronisable*>::iterator iit;
-#endif
   //start collect data synchronisable by synchronisable
   uint8_t *mem=data_;
   mem+=sizeof(GamestateHeader);
-  orxonox::ObjectList<Synchronisable>::iterator it;
-  for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){
+  ObjectList<Synchronisable>::iterator it;
+  for(it = ObjectList<Synchronisable>::begin(); it; ++it){
     tempsize=it->getSize(id, mode);
 
     if(currentsize+tempsize > size){
+      assert(0); // if we don't use multithreading this part shouldn't be neccessary
       // start allocate additional memory
       COUT(3) << "G.St.Man: need additional memory" << std::endl;
-      orxonox::ObjectList<Synchronisable>::iterator temp = it;
+      ObjectList<Synchronisable>::iterator temp = it;
       int addsize=tempsize;
       while(++temp)
@@ -110,9 +107,4 @@
     }// stop allocate additional memory
 
-#ifndef NDEBUG
-    for(iit=slist.begin(); iit!=slist.end(); iit++)
-      assert((*iit)!=*it);
-    slist.push_back(*it);
-#endif
 
     //if(it->doSelection(id))
@@ -127,5 +119,4 @@
   //start write gamestate header
   HEADER->packetType = ENUM::Gamestate;
-  assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);
   HEADER->datasize = currentsize;
   HEADER->id = id;
@@ -140,5 +131,5 @@
 }
 
-bool Gamestate::spreadData(int mode)
+bool Gamestate::spreadData(uint8_t mode)
 {
   assert(data_);
@@ -147,5 +138,5 @@
   uint8_t *mem=data_+sizeof(GamestateHeader);
     // get the start of the Synchronisable list
-  //orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
+  //ObjectList<Synchronisable>::iterator it=ObjectList<Synchronisable>::begin();
   Synchronisable *s;
 
@@ -163,6 +154,4 @@
       bool b = s->updateData(mem, mode);
       assert(b);
-      //if(!s->updateData(mem, mode))
-        //return false;
     }
   }
@@ -367,17 +356,11 @@
     assert(it->second->objectID==oldobjectheader->objectID);
     *newobjectheader = *oldobjectheader;
-    objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader
+    objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader
     if(it->second->doSelection(HEADER->id)){
-      newobjectheader->dataAvailable=true; //TODO: probably not neccessary
-      while(objectOffset<objectsize){
-        *(newdata + objectOffset)=*(origdata + objectOffset);    // copy the data
-        objectOffset++;
-      }
+      assert(newobjectheader->dataAvailable==true);
+      memcpy(newdata+objectOffset, origdata+objectOffset, objectsize-objectOffset);
     }else{
       newobjectheader->dataAvailable=false;
-      while(objectOffset<objectsize){
-        *(newdata+objectOffset)=0;    // set to 0
-        objectOffset++;
-      }
+      memset(newdata+objectOffset, 0, objectsize-objectOffset);
       assert(objectOffset==objectsize);
     }
@@ -565,11 +548,11 @@
 
 
-unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)
-{
-  int size=0;
+unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)
+{
+  unsigned int size=0;
     // get the start of the Synchronisable list
-  orxonox::ObjectList<Synchronisable>::iterator it;
+  ObjectList<Synchronisable>::iterator it;
     // get total size of gamestate
-  for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it)
+  for(it = ObjectList<Synchronisable>::begin(); it; ++it)
     size+=it->getSize(id, mode); // size of the actual data of the synchronisable
 //  size+=sizeof(GamestateHeader);
@@ -582,6 +565,6 @@
  * @return iterator pointing to the next object in the list
  */
-  void Gamestate::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
-    orxonox::ObjectList<Synchronisable>::iterator temp=it;
+  void Gamestate::removeObject(ObjectList<Synchronisable>::iterator &it) {
+    ObjectList<Synchronisable>::iterator temp=it;
     ++it;
     delete  *temp;
