Index: code/branches/presentation/src/network/GamestateClient.cc
===================================================================
--- code/branches/presentation/src/network/GamestateClient.cc	(revision 2653)
+++ code/branches/presentation/src/network/GamestateClient.cc	(revision 2655)
@@ -77,5 +77,5 @@
     int id = GAMESTATEID_INITIAL;
     packet::Gamestate *processed = processGamestate(tempGamestate_);
-//    assert(processed);
+    assert(processed);
     
     //now call the queued callbacks
@@ -83,5 +83,5 @@
     
     if (!processed){
-      sendAck(0);
+//      sendAck(0);
       return false;
     }
@@ -91,5 +91,5 @@
     last_diff_ = processed->getID();
     id = processed->getID();
-    sendAck(id);
+//     sendAck(id);
     return true;
   }
@@ -160,4 +160,5 @@
       packet::Gamestate *base = gamestateMap_[gs->getBaseID()];
       if(!base){
+COUT(0) << "could not find base gamestate id: " << gs->getBaseID() << endl;
         delete gs;
         return 0;
@@ -172,4 +173,5 @@
       return gs;
     else
+COUT(0) << "could not spread gamestate" << endl;
       return NULL;
   }
Index: code/branches/presentation/src/network/GamestateManager.cc
===================================================================
--- code/branches/presentation/src/network/GamestateManager.cc	(revision 2653)
+++ code/branches/presentation/src/network/GamestateManager.cc	(revision 2655)
@@ -134,4 +134,5 @@
 //       COUT(3) << "diffing" << std::endl;
       gs = gs->diff(client);
+//       gs = new packet::Gamestate(*gs);
     }
     else{
Index: code/branches/presentation/src/network/packet/Gamestate.cc
===================================================================
--- code/branches/presentation/src/network/packet/Gamestate.cc	(revision 2653)
+++ code/branches/presentation/src/network/packet/Gamestate.cc	(revision 2655)
@@ -44,10 +44,17 @@
 namespace packet {
 
+#define GAMESTATE_START(data) (data + GamestateHeader::getSize())
 
 #define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
 
+// Gamestate::Gamestate()
+// {
+//   flags_ = flags_ | PACKET_FLAG_GAMESTATE;
+// }
+
 Gamestate::Gamestate()
 {
   flags_ = flags_ | PACKET_FLAG_GAMESTATE;
+  header_ = 0;
 }
 
@@ -56,4 +63,5 @@
 {
   flags_ = flags_ | PACKET_FLAG_GAMESTATE;
+  header_ = new GamestateHeader(data_);
 }
 
@@ -62,4 +70,5 @@
   flags_ = flags_ | PACKET_FLAG_GAMESTATE;
   data_=data;
+  header_ = new GamestateHeader(data_);
 }
 
@@ -71,4 +80,5 @@
 bool Gamestate::collectData(int id, uint8_t mode)
 {
+  assert(this->header_==0); // make sure the header didn't exist before
   uint32_t tempsize=0, currentsize=0;
   assert(data_==0);
@@ -78,13 +88,16 @@
   if(size==0)
     return false;
-  data_ = new unsigned char[size + sizeof(GamestateHeader)];
+  data_ = new uint8_t[size + GamestateHeader::getSize()];
   if(!data_){
     COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
     return false;
   }
+  
+  // create the header object
+  header_ = new GamestateHeader(data_);
 
   //start collect data synchronisable by synchronisable
   uint8_t *mem=data_;
-  mem+=sizeof(GamestateHeader);
+  mem += GamestateHeader::getSize();
   ObjectList<Synchronisable>::iterator it;
   for(it = ObjectList<Synchronisable>::begin(); it; ++it){
@@ -100,5 +113,5 @@
       while(++temp)
         addsize+=temp->getSize(id, mode);
-      data_ = (uint8_t *)realloc(data_, sizeof(GamestateHeader) + currentsize + addsize);
+      data_ = (uint8_t *)realloc(data_, GamestateHeader::getSize() + currentsize + addsize);
       if(!data_)
         return false;
@@ -119,10 +132,9 @@
 
   //start write gamestate header
-  HEADER->packetType = ENUM::Gamestate;
-  HEADER->datasize = currentsize;
-  HEADER->id = id;
-  HEADER->diffed = false;
-  HEADER->complete = true;
-  HEADER->compressed = false;
+  header_->setDataSize( currentsize );
+  header_->setID( id );
+  header_->setDiffed( false );
+  header_->setComplete( true );
+  header_->setCompressed( false );
   //stop write gamestate header
 
@@ -135,7 +147,7 @@
 {
   assert(data_);
-  assert(!HEADER->compressed);
-  assert(!HEADER->diffed);
-  uint8_t *mem=data_+sizeof(GamestateHeader);
+  assert(!header_->isCompressed());
+  assert(!header_->isDiffed());
+  uint8_t *mem=data_+GamestateHeader::getSize();
     // get the start of the Synchronisable list
   //ObjectList<Synchronisable>::iterator it=ObjectList<Synchronisable>::begin();
@@ -143,14 +155,18 @@
 
   // update the data of the objects we received
-  while(mem < data_+sizeof(GamestateHeader)+HEADER->datasize){
-    synchronisableHeader *objectheader = (synchronisableHeader*)mem;
-
-    s = Synchronisable::getSynchronisable( objectheader->objectID );
+  while(mem < data_+GamestateHeader::getSize()+header_->getDataSize()){
+    SynchronisableHeader objectheader(mem);
+
+    s = Synchronisable::getSynchronisable( objectheader.getObjectID() );
     if(!s)
     {
       if (!Core::isMaster())
+      {
         Synchronisable::fabricate(mem, mode);
+      }
       else
-        mem += objectheader->size;
+      {
+        mem += objectheader.getDataSize();
+      }
 //         COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;
 //       else
@@ -196,18 +212,18 @@
 {
   assert(data_);
-  if(HEADER->compressed)
-    return HEADER->compsize+sizeof(GamestateHeader);
+  if(header_->isCompressed())
+    return header_->getCompSize()+GamestateHeader::getSize();
   else
   {
-    return HEADER->datasize+sizeof(GamestateHeader);
+    return header_->getDataSize()+GamestateHeader::getSize();
   }
 }
 
 bool Gamestate::operator==(packet::Gamestate gs){
-  uint8_t *d1 = data_+sizeof(GamestateHeader);
-  uint8_t *d2 = gs.data_+sizeof(GamestateHeader);
+  uint8_t *d1 = data_+GamestateHeader::getSize();
+  uint8_t *d2 = gs.data_+GamestateHeader::getSize();
   assert(!isCompressed());
   assert(!gs.isCompressed());
-  while(d1<data_+HEADER->datasize)
+  while(d1<data_+header_->getDataSize())
   {
     if(*d1!=*d2)
@@ -228,16 +244,16 @@
 bool Gamestate::compressData()
 {
-  assert(HEADER);
-  assert(!HEADER->compressed);
-  uLongf buffer = (uLongf)(((HEADER->datasize + 12)*1.01)+1);
+  assert(data_);
+  assert(!header_->isCompressed());
+  uLongf buffer = (uLongf)(((header_->getDataSize() + 12)*1.01)+1);
   if(buffer==0)
     return false;
 
-  uint8_t *ndata = new uint8_t[buffer+sizeof(GamestateHeader)];
-  uint8_t *dest = GAMESTATE_START(ndata);
+  uint8_t *ndata = new uint8_t[buffer+GamestateHeader::getSize()];
+  uint8_t *dest = ndata + GamestateHeader::getSize();
   //unsigned char *dest = new unsigned char[buffer];
-  uint8_t *source = GAMESTATE_START(data_);
+  uint8_t *source = data_ + GamestateHeader::getSize();
   int retval;
-  retval = compress( dest, &buffer, source, (uLong)(HEADER->datasize) );
+  retval = compress( dest, &buffer, source, (uLong)(header_->getDataSize()) );
   switch ( retval ) {
     case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
@@ -248,29 +264,30 @@
 
   //copy and modify header
-  *GAMESTATE_HEADER(ndata) = *HEADER;
+  GamestateHeader *temp = header_;
+  header_ = new GamestateHeader(ndata, temp);
+  delete temp;
   //delete old data
   delete[] data_;
   //save new data
   data_ = ndata;
-  HEADER->compsize = buffer;
-  HEADER->compressed = true;
-  assert(HEADER->compressed);
-  COUT(4) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl;
+  header_->setCompSize( buffer );
+  header_->setCompressed( true );
+  COUT(5) << "gamestate compress datasize: " << header_->getDataSize() << " compsize: " << header_->getCompSize() << std::endl;
   return true;
 }
 bool Gamestate::decompressData()
 {
-  assert(HEADER);
-  assert(HEADER->compressed);
-  COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
-  uint32_t datasize = HEADER->datasize;
-  uint32_t compsize = HEADER->compsize;
+  assert(data_);
+  assert(header_->isCompressed());
+  COUT(4) << "GameStateClient: uncompressing gamestate. id: " << header_->getID() << ", baseid: " << header_->getBaseID() << ", datasize: " << header_->getDataSize() << ", compsize: " << header_->getCompSize() << std::endl;
+  uint32_t datasize = header_->getDataSize();
+  uint32_t compsize = header_->getCompSize();
   uint32_t bufsize;
 //  assert(compsize<=datasize);
   bufsize = datasize;
   assert(bufsize!=0);
-  uint8_t *ndata = new uint8_t[bufsize + sizeof(GamestateHeader)];
-  uint8_t *dest = ndata + sizeof(GamestateHeader);
-  uint8_t *source = data_ + sizeof(GamestateHeader);
+  uint8_t *ndata = new uint8_t[bufsize + GamestateHeader::getSize()];
+  uint8_t *dest = ndata + GamestateHeader::getSize();
+  uint8_t *source = data_ + GamestateHeader::getSize();
   int retval;
   uLongf length=bufsize;
@@ -284,5 +301,7 @@
 
   //copy over the header
-  *GAMESTATE_HEADER(ndata) = *HEADER;
+  GamestateHeader *temp = header_;
+  header_ = new GamestateHeader( data_, header_ );
+  delete temp;
 
   if (this->bDataENetAllocated_){
@@ -299,7 +318,7 @@
   //set new pointers
   data_ = ndata;
-  HEADER->compressed = false;
-  assert(HEADER->datasize==datasize);
-  assert(HEADER->compsize==compsize);
+  header_->setCompressed( false );
+  assert(header_->getDataSize()==datasize);
+  assert(header_->getCompSize()==compsize);
   return true;
 }
@@ -307,23 +326,24 @@
 Gamestate *Gamestate::diff(Gamestate *base)
 {
-  assert(HEADER);
-  assert(!HEADER->compressed);
-  assert(!HEADER->diffed);
+  assert(data_);
+  assert(!header_->isCompressed());
+  assert(!header_->isDiffed());
+  GamestateHeader diffHeader(base->data_);
   //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
   uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
   uint32_t of=0; // pointers offset
   uint32_t dest_length=0;
-  dest_length=HEADER->datasize;
+  dest_length=header_->getDataSize();
   if(dest_length==0)
     return NULL;
-  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+sizeof(GamestateHeader)];
-  uint8_t *dest = ndata + sizeof(GamestateHeader);
-  while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){
+  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
+  uint8_t *dest = ndata + GamestateHeader::getSize();
+  while(of < diffHeader.getDataSize() && of < header_->getDataSize()){
     *(dest+of)=*(basep+of)^*(gs+of); // do the xor
     ++of;
   }
-  if(GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){
+  if(diffHeader.getDataSize()!=header_->getDataSize()){
     uint8_t n=0;
-    if(GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){
+    if(diffHeader.getDataSize() < header_->getDataSize()){
       while(of<dest_length){
         *(dest+of)=n^*(gs+of);
@@ -333,8 +353,8 @@
   }
 
-  *GAMESTATE_HEADER(ndata) = *HEADER;
-  GAMESTATE_HEADER(ndata)->diffed = true;
-  GAMESTATE_HEADER(ndata)->base_id = base->getID();
   Gamestate *g = new Gamestate(ndata, getClientID());
+  *(g->header_) = *header_;
+  g->header_->setDiffed( true );
+  g->header_->setBaseID( base->getID() );
   g->flags_=flags_;
   g->packetDirection_ = packetDirection_;
@@ -347,14 +367,14 @@
 
   // allocate memory for new data
-  uint8_t *gdata = new uint8_t[HEADER->datasize+sizeof(GamestateHeader)];
+  uint8_t *gdata = new uint8_t[header_->getDataSize()+GamestateHeader::getSize()];
   // create a gamestate out of it
   Gamestate *gs = new Gamestate(gdata);
-  uint8_t *newdata = gdata + sizeof(GamestateHeader);
+  uint8_t *newdata = gdata + GamestateHeader::getSize();
   uint8_t *origdata = GAMESTATE_START(data_);
 
   //copy the GamestateHeader
-  *(GamestateHeader*)gdata = *HEADER;
-
-  synchronisableHeader *oldobjectheader, *newobjectheader;
+  assert(gs->header_);
+  *(gs->header_) = *header_;
+
   uint32_t objectOffset;
   unsigned int objectsize, destsize=0;
@@ -363,5 +383,5 @@
 
   //call TrafficControl
-  TrafficControl::getInstance()->processObjectList( clientID, HEADER->id, &dataMap_ );
+  TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), &dataMap_ );
 
   //copy in the zeros
@@ -371,6 +391,6 @@
 //    if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this
 //      continue;                            // merged from objecthierarchy2, doesn't work anymore; TODO: change this
-    oldobjectheader = (synchronisableHeader*)origdata;
-    newobjectheader = (synchronisableHeader*)newdata;
+    SynchronisableHeader oldobjectheader(origdata);
+    SynchronisableHeader newobjectheader(newdata);
     if ( (*it).objSize == 0 )
     {
@@ -380,13 +400,13 @@
 //     object = Synchronisable::getSynchronisable( (*it).objID );
 //     assert(object->objectID == oldobjectheader->objectID);
-    objectsize = oldobjectheader->size;
-    objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader
-    if ( (*it).objID == oldobjectheader->objectID ){
+    objectsize = oldobjectheader.getDataSize();
+    objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
+    if ( (*it).objID == oldobjectheader.getObjectID() ){
       memcpy(newdata, origdata, objectsize);
-      assert(newobjectheader->dataAvailable==true);
+      assert(newobjectheader.isDataAvailable()==true);
       ++it;
     }else{
-      *newobjectheader = *oldobjectheader;
-      newobjectheader->dataAvailable=false;
+      newobjectheader = oldobjectheader;
+      newobjectheader.setDataAvailable(false);
       memset(newdata+objectOffset, 0, objectsize-objectOffset);
     }
@@ -397,15 +417,15 @@
 #ifndef NDEBUG
   uint32_t origsize = destsize;
-  while ( origsize < HEADER->datasize )
+  while ( origsize < header_->getDataSize() )
   {
-    oldobjectheader = (synchronisableHeader*)origdata;
-    objectsize = oldobjectheader->size;
+    SynchronisableHeader oldobjectheader(origdata);
+    objectsize = oldobjectheader.getDataSize();
     origdata += objectsize;
     origsize += objectsize;
   }
-  assert(origsize==HEADER->datasize);
+  assert(origsize==header_->getDataSize());
   assert(destsize!=0);
 #endif
-  ((GamestateHeader*)gdata)->datasize = destsize;
+  gs->header_->setDataSize( destsize );
   return gs;
 }
@@ -414,7 +434,7 @@
 Gamestate *Gamestate::undiff(Gamestate *base)
 {
-  assert(this && base);assert(HEADER);
-  assert(HEADER->diffed);
-  assert(!HEADER->compressed && !GAMESTATE_HEADER(base->data_)->compressed);
+  assert(this && base);assert(data_);
+  assert(header_->isDiffed());
+  assert(!header_->isCompressed() && !base->header_->isCompressed());
   //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
   uint8_t *basep = GAMESTATE_START(base->data_);
@@ -422,16 +442,16 @@
   uint32_t of=0; // pointers offset
   uint32_t dest_length=0;
-  dest_length=HEADER->datasize;
+  dest_length=header_->getDataSize();
   if(dest_length==0)
     return NULL;
-  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+sizeof(GamestateHeader)];
-  uint8_t *dest = ndata + sizeof(GamestateHeader);
-  while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){
+  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
+  uint8_t *dest = ndata + GamestateHeader::getSize();
+  while(of < base->header_->getDataSize() && of < header_->getDataSize()){
     *(dest+of)=*(basep+of)^*(gs+of); // do the xor
     ++of;
   }
-  if(GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){
+  if(base->header_->getDataSize()!=header_->getDataSize()){
     uint8_t n=0;
-    if(GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){
+    if(base->header_->getDataSize() < header_->getDataSize()){
       while(of < dest_length){
         *(dest+of)=n^*(gs+of);
@@ -440,7 +460,8 @@
     }
   }
-  *GAMESTATE_HEADER(ndata) = *HEADER;
-  GAMESTATE_HEADER(ndata)->diffed = false;
   Gamestate *g = new Gamestate(ndata, getClientID());
+  assert(g->header_);
+  *(g->header_) = *header_;
+  g->header_->setDiffed( false );
   g->flags_=flags_;
   g->packetDirection_ = packetDirection_;
@@ -463,4 +484,3 @@
 
 } //namespace packet
-
 } //namespace orxonox
Index: code/branches/presentation/src/network/packet/Gamestate.h
===================================================================
--- code/branches/presentation/src/network/packet/Gamestate.h	(revision 2653)
+++ code/branches/presentation/src/network/packet/Gamestate.h	(revision 2655)
@@ -46,17 +46,55 @@
 namespace packet {
 
-#define GAMESTATE_START(data) (data + sizeof(GamestateHeader))
-#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
-#define HEADER GAMESTATE_HEADER(data_)
+class _NetworkExport GamestateHeader{
+  public:
+    GamestateHeader(uint8_t *data){ data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; }
+    GamestateHeader(uint8_t *data, GamestateHeader* h)
+      { data_=data; memcpy(data_, h->data_, getSize()); }
+    static inline uint32_t getSize()
+      { return 21; }
 
-struct _NetworkExport GamestateHeader{
-  ENUM::Type packetType;
-  int32_t id; // id of the gamestate
-  uint32_t compsize;
-  uint32_t datasize;
-  int32_t base_id; // id of the base-gamestate diffed from
-  bool diffed:1; // wheter diffed or not
-  bool complete:1; // wheter it is a complete gamestate or only partial
-  bool compressed:1;
+    inline int32_t getID() const
+      { return *(int32_t*)(data_+4); }
+    inline void setID(int32_t id)
+      { *(int32_t*)(data_+4) = id; }
+
+    inline int32_t getBaseID() const
+      { return *(int32_t*)(data_+8); }
+    inline void setBaseID(int32_t id)
+      { *(int32_t*)(data_+8) = id; }
+
+    inline uint32_t getDataSize() const
+      { return *(uint32_t*)(data_+12); }
+    inline void setDataSize(uint32_t size)
+      { *(uint32_t*)(data_+12) = size; }
+
+    inline uint32_t getCompSize() const
+      { return *(uint32_t*)(data_+16); }
+    inline void setCompSize(uint32_t size)
+      { *(uint32_t*)(data_+16) = size; }
+
+    inline bool isDiffed() const
+      { return *(int8_t*)(data_+20) & 0x1; }
+    inline void setDiffed(bool b)
+      { *(int8_t*)(data_+20) = (b<<0) | (*(int8_t*)(data_+20) & 0x6 ); }
+
+    inline bool isComplete() const
+      { return *(int8_t*)(data_+20) & 0x2; }
+    inline void setComplete(bool b)
+      { *(int8_t*)(data_+20) = (b<<1) | (*(int8_t*)(data_+20) & 0x5 ); }
+
+    inline bool isCompressed() const
+      { return *(int8_t*)(data_+20) & 0x4; }
+    inline void setCompressed(bool b)
+      { *(int8_t*)(data_+20) = (b<<2) | (*(int8_t*)(data_+20) & 0x3 ); }
+
+    inline void operator=(GamestateHeader& h)
+      { memcpy( data_, h.data_, getSize()); }
+  private:
+    uint8_t *data_;
+//#define GAMESTATE_START(data) (data + sizeof(GamestateHeader))
+//#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
+//#define HEADER GAMESTATE_HEADER(data_)
+
 };
 
@@ -74,8 +112,8 @@
     bool collectData(int id, uint8_t mode=0x0);
     bool spreadData( uint8_t mode=0x0);
-    inline int32_t getID() const { return HEADER->id; }
-    inline bool isDiffed() const { return HEADER->diffed; }
-    inline bool isCompressed() const { return HEADER->compressed; }
-    inline int32_t getBaseID() const { return HEADER->base_id; }
+    inline int32_t getID() const { return header_->getID(); }
+    inline bool isDiffed() const { return header_->isDiffed(); }
+    inline bool isCompressed() const { return header_->isCompressed(); }
+    inline int32_t getBaseID() const { return header_->getBaseID(); }
     Gamestate *diff(Gamestate *base);
     Gamestate *undiff(Gamestate *base);
@@ -93,4 +131,5 @@
     uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
     std::list<obj> dataMap_;
+    GamestateHeader* header_;
 };
 
Index: code/branches/presentation/src/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/presentation/src/network/synchronisable/Synchronisable.cc	(revision 2653)
+++ code/branches/presentation/src/network/synchronisable/Synchronisable.cc	(revision 2655)
@@ -28,14 +28,4 @@
  */
 
-//
-// C++ Implementation: synchronisable
-//
-// Description:
-//
-//
-// Author:  Dumeni, Oliver Scheuss, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
 
 #include "Synchronisable.h"
@@ -155,15 +145,15 @@
   Synchronisable *Synchronisable::fabricate(uint8_t*& mem, uint8_t mode)
   {
-    synchronisableHeader *header = (synchronisableHeader *)mem;
-
-    if(!header->dataAvailable)
-    {
-      mem += header->size;
+    SynchronisableHeader header(mem);
+
+    if(!header.isDataAvailable())
+    {
+      mem += header.getDataSize();
       return 0;
     }
 
-    COUT(4) << "fabricating object with id: " << header->objectID << std::endl;
-
-    Identifier* id = ClassByID(header->classID);
+    COUT(4) << "fabricating object with id: " << header.getObjectID() << std::endl;
+
+    Identifier* id = ClassByID(header.getClassID());
     if (!id)
     {
@@ -174,11 +164,11 @@
     assert(id);
     BaseObject* creator = 0;
-    if (header->creatorID != OBJECTID_UNKNOWN)
-    {
-      Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header->creatorID);
+    if (header.getCreatorID() != OBJECTID_UNKNOWN)
+    {
+      Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header.getCreatorID());
       if (!synchronisable_creator)
       {
-        mem += header->size; //.TODO: this suckz.... remove size from header
-//         assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^
+        mem += header.getDataSize(); //.TODO: this suckz.... remove size from header
+        assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^
         return 0;
       }
@@ -186,12 +176,12 @@
         creator = dynamic_cast<BaseObject*>(synchronisable_creator);
     }
-    assert(getSynchronisable(header->objectID)==0);   //make sure no object with this id exists
+    assert(getSynchronisable(header.getObjectID())==0);   //make sure no object with this id exists
     BaseObject *bo = id->fabricate(creator);
     assert(bo);
     Synchronisable *no = dynamic_cast<Synchronisable *>(bo);
     assert(no);
-    no->objectID=header->objectID;
-    no->creatorID=header->creatorID; //TODO: remove this
-    no->classID=header->classID;
+    no->objectID=header.getObjectID();
+    no->creatorID=header.getCreatorID(); //TODO: remove this
+    no->classID=header.getClassID();
     COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
           // update data and create object/entity...
@@ -329,12 +319,12 @@
 
     // start copy header
-    synchronisableHeader *header = (synchronisableHeader *)mem;
-    header->size = size;
-    header->objectID = this->objectID;
-    header->creatorID = this->creatorID;
-    header->classID = this->classID;
-    header->dataAvailable = true;
-    tempsize += sizeof(synchronisableHeader);
-    mem += sizeof(synchronisableHeader);
+    SynchronisableHeader header(mem);
+    header.setDataSize( size );
+    header.setObjectID( this->objectID );
+    header.setCreatorID( this->creatorID );
+    header.setClassID( this->classID );
+    header.setDataAvailable( true );
+    tempsize += SynchronisableHeader::getSize();
+    mem += SynchronisableHeader::getSize();
     // end copy header
 
@@ -371,22 +361,23 @@
     uint8_t* data=mem;
     // start extract header
-    synchronisableHeader *syncHeader = (synchronisableHeader *)mem;
-    assert(syncHeader->objectID==this->objectID);
-    assert(syncHeader->creatorID==this->creatorID);
-    assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ?
-    if(syncHeader->dataAvailable==false){
-      mem += syncHeader->size;
+    SynchronisableHeader syncHeader(mem);
+    assert(syncHeader.getObjectID()==this->objectID);
+    assert(syncHeader.getCreatorID()==this->creatorID);
+    assert(syncHeader.getClassID()==this->classID);
+    if(syncHeader.isDataAvailable()==false){
+      mem += syncHeader.getDataSize();
       return true;
     }
 
-    mem += sizeof(synchronisableHeader);
+    mem += SynchronisableHeader::getSize();
     // stop extract header
 
-    COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl;
-    for(i=syncList.begin(); i!=syncList.end() && mem <= data+syncHeader->size; i++)
-    {
+    //COUT(5) << "Synchronisable: objectID " << syncHeader.getObjectID() << ", classID " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;
+    for(i=syncList.begin(); i!=syncList.end(); i++)
+    {
+      assert( mem <= data+syncHeader.getDataSize() ); // always make sure we don't exceed the datasize in our stream
       (*i)->putData( mem, mode, forceCallback );
     }
-    assert(mem == data+syncHeader->size);
+    assert(mem == data+syncHeader.getDataSize());
     return true;
   }
@@ -399,5 +390,5 @@
   */
   uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){
-    int tsize=sizeof(synchronisableHeader);
+    int tsize=SynchronisableHeader::getSize();
     if(mode==0x0)
       mode=state_;
@@ -428,7 +419,7 @@
   bool Synchronisable::isMyData(uint8_t* mem)
   {
-    synchronisableHeader *header = (synchronisableHeader *)mem;
-    assert(header->objectID==this->objectID);
-    return header->dataAvailable;
+    SynchronisableHeader header(mem);
+    assert(header.getObjectID()==this->objectID);
+    return header.isDataAvailable();
   }
 
Index: code/branches/presentation/src/network/synchronisable/Synchronisable.h
===================================================================
--- code/branches/presentation/src/network/synchronisable/Synchronisable.h	(revision 2653)
+++ code/branches/presentation/src/network/synchronisable/Synchronisable.h	(revision 2655)
@@ -72,10 +72,45 @@
   }
 
-  struct _NetworkExport synchronisableHeader{
-    uint32_t size:31;
-    bool dataAvailable:1;
-    uint32_t objectID;
-    uint32_t creatorID;
-    uint32_t classID;
+  /**
+   * @brief: stores information about a Synchronisable 
+   * 
+   * This class stores the information about a Synchronisable (objectID, classID, creatorID, dataSize)
+   * in an emulated bitset.
+   * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
+   * Bit 32 is a bool and defines whether the data is actually stored or is just filled up with 0
+   * Byte 5 to 8: objectID
+   * Byte 9 to 12: classID
+   * Byte 13 to 16: creatorID
+   */
+  class _NetworkExport SynchronisableHeader{
+    private:
+      uint8_t *data_;
+    public:
+      SynchronisableHeader(uint8_t* data)
+        { data_ = data; }
+      inline static uint32_t getSize()
+        { return 16; }
+      inline uint32_t getDataSize() const
+        { return (*(uint32_t*)data_) & 0x7FFFFFFF; } //only use the first 31 bits
+      inline void setDataSize(uint32_t size)
+        { *(uint32_t*)(data_) = (size & 0x7FFFFFFF) | (*(uint32_t*)(data_) & 0x80000000 ); }
+      inline bool isDataAvailable() const
+        { return ( (*(uint32_t*)data_) & 0x80000000 ) == 0x80000000; }
+      inline void setDataAvailable( bool b)
+        { *(uint32_t*)(data_) = (b << 31) | (*(uint32_t*)(data_) & 0x7FFFFFFF ); }
+      inline uint32_t getObjectID() const
+        { return *(uint32_t*)(data_+4); }
+      inline void setObjectID(uint32_t objectID)
+        { *(uint32_t*)(data_+4) = objectID; }
+      inline uint32_t getClassID() const
+        { return *(uint32_t*)(data_+8); }
+      inline void setClassID(uint32_t classID)
+        { *(uint32_t*)(data_+8) = classID; }
+      inline uint32_t getCreatorID() const
+        { return *(uint32_t*)(data_+12); }
+      inline void setCreatorID(uint32_t creatorID)
+        { *(uint32_t*)(data_+12) = creatorID; }
+      inline void operator=(SynchronisableHeader& h)
+        { memcpy(data_, h.data_, getSize()); }
   };
 
@@ -83,5 +118,5 @@
   /**
   * This class is the base class of all the Objects in the universe that need to be synchronised over the network
-   * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list.
+  * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list.
   * @author Oliver Scheuss
   */
