Index: code/branches/presentation/src/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/presentation/src/network/synchronisable/Synchronisable.cc	(revision 2575)
+++ 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 2575)
+++ 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
   */
