Index: code/branches/bugger/src/core/Factory.cc
===================================================================
--- code/branches/bugger/src/core/Factory.cc	(revision 2530)
+++ code/branches/bugger/src/core/Factory.cc	(revision 2531)
@@ -58,7 +58,7 @@
         @return The Identifier
     */
-    Identifier* Factory::getIdentifier(const unsigned int id)
+    Identifier* Factory::getIdentifier(const uint32_t id)
     {
-        std::map<unsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);
+        std::map<uint32_t, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);
         if (it != getFactoryPointer()->identifierNetworkIDMap_.end())
             return it->second;
@@ -85,5 +85,5 @@
         @param newID The new networkID
     */
-    void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID)
+    void Factory::changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID)
     {
         getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
Index: code/branches/bugger/src/core/Factory.h
===================================================================
--- code/branches/bugger/src/core/Factory.h	(revision 2530)
+++ code/branches/bugger/src/core/Factory.h	(revision 2531)
@@ -49,4 +49,5 @@
 #include <map>
 #include <string>
+#include "util/Integers.h"
 
 namespace orxonox
@@ -60,7 +61,7 @@
         public:
             static Identifier* getIdentifier(const std::string& name);
-            static Identifier* getIdentifier(const unsigned int id);
+            static Identifier* getIdentifier(const uint32_t id);
             static void add(const std::string& name, Identifier* identifier);
-            static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID);
+            static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);
             static void createClassHierarchy();
 
@@ -83,5 +84,5 @@
 
             std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
-            std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
+            std::map<uint32_t, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
     };
 
Index: code/branches/bugger/src/core/Identifier.cc
===================================================================
--- code/branches/bugger/src/core/Identifier.cc	(revision 2530)
+++ code/branches/bugger/src/core/Identifier.cc	(revision 2531)
@@ -245,5 +245,5 @@
         @param id The new network ID
     */
-    void Identifier::setNetworkID(unsigned int id)
+    void Identifier::setNetworkID(uint32_t id)
     {
         Factory::changeNetworkID(this, this->classID_, id);
Index: code/branches/bugger/src/core/Identifier.h
===================================================================
--- code/branches/bugger/src/core/Identifier.h	(revision 2530)
+++ code/branches/bugger/src/core/Identifier.h	(revision 2531)
@@ -68,4 +68,5 @@
 #include "Super.h"
 #include "Functor.h"
+#include "util/Integers.h"
 #include "util/Debug.h"
 #include "util/String.h"
@@ -230,8 +231,8 @@
 
             /** @brief Returns the network ID to identify a class through the network. @return the network ID */
-            inline const unsigned int getNetworkID() const { return this->classID_; }
+            inline const uint32_t getNetworkID() const { return this->classID_; }
 
             /** @brief Sets the network ID to a new value. @param id The new value */
-            void setNetworkID(unsigned int id);
+            void setNetworkID(uint32_t id);
 
             void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
@@ -317,5 +318,5 @@
             BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
             static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
-            unsigned int classID_;                                         //!< The network ID to identify a class through the network
+            uint32_t classID_;                                             //!< The network ID to identify a class through the network
 
             bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
Index: code/branches/bugger/src/network/CMakeLists.txt
===================================================================
--- code/branches/bugger/src/network/CMakeLists.txt	(revision 2530)
+++ code/branches/bugger/src/network/CMakeLists.txt	(revision 2531)
@@ -11,9 +11,11 @@
   PacketBuffer.cc
   Server.cc
-  Synchronisable.cc
+  TrafficControl.cc
   Host.cc
 )
 
 ADD_SOURCE_DIRECTORY(NETWORK_SRC_FILES packet)
+ADD_SOURCE_DIRECTORY(NETWORK_SRC_FILES synchronisable)
+
 
 IF(WIN32)
Index: code/branches/bugger/src/network/Client.cc
===================================================================
--- code/branches/bugger/src/network/Client.cc	(revision 2530)
+++ code/branches/bugger/src/network/Client.cc	(revision 2531)
@@ -43,5 +43,5 @@
 #include "Client.h"
 #include "Host.h"
-#include "Synchronisable.h"
+#include "synchronisable/Synchronisable.h"
 #include "core/CoreIncludes.h"
 #include "packet/Packet.h"
Index: code/branches/bugger/src/network/ClientInformation.cc
===================================================================
--- code/branches/bugger/src/network/ClientInformation.cc	(revision 2530)
+++ code/branches/bugger/src/network/ClientInformation.cc	(revision 2531)
@@ -45,4 +45,5 @@
 namespace orxonox
 {
+  
 
   ClientInformation *ClientInformation::head_=0;
Index: code/branches/bugger/src/network/ClientInformation.h
===================================================================
--- code/branches/bugger/src/network/ClientInformation.h	(revision 2530)
+++ code/branches/bugger/src/network/ClientInformation.h	(revision 2531)
@@ -46,10 +46,9 @@
 #include <boost/thread/recursive_mutex.hpp>
 
+
 // WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
 
 namespace orxonox
 {
-  static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
-  static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;
 
   /**
Index: code/branches/bugger/src/network/ConnectionManager.cc
===================================================================
--- code/branches/bugger/src/network/ConnectionManager.cc	(revision 2530)
+++ code/branches/bugger/src/network/ConnectionManager.cc	(revision 2531)
@@ -52,5 +52,5 @@
 #include "util/Sleep.h"
 #include "ClientInformation.h"
-#include "Synchronisable.h"
+#include "synchronisable/Synchronisable.h"
 #include "packet/ClassID.h"
 
Index: code/branches/bugger/src/network/GamestateClient.cc
===================================================================
--- code/branches/bugger/src/network/GamestateClient.cc	(revision 2530)
+++ code/branches/bugger/src/network/GamestateClient.cc	(revision 2531)
@@ -35,5 +35,6 @@
 #include "core/BaseObject.h"
 #include "core/Iterator.h"
-#include "Synchronisable.h"
+#include "synchronisable/Synchronisable.h"
+#include "synchronisable/NetworkCallbackManager.h"
 #include "packet/Acknowledgement.h"
 
@@ -77,4 +78,8 @@
     packet::Gamestate *processed = processGamestate(tempGamestate_);
 //    assert(processed);
+    
+    //now call the queued callbacks
+    NetworkCallbackManager::callCallbacks();
+    
     if (!processed){
       sendAck(0);
Index: code/branches/bugger/src/network/GamestateManager.cc
===================================================================
--- code/branches/bugger/src/network/GamestateManager.cc	(revision 2530)
+++ code/branches/bugger/src/network/GamestateManager.cc	(revision 2531)
@@ -49,5 +49,6 @@
 #include "core/BaseObject.h"
 #include "ClientInformation.h"
-#include "Synchronisable.h"
+#include "synchronisable/Synchronisable.h"
+#include "synchronisable/NetworkCallbackManager.h"
 #include "packet/Acknowledgement.h"
 
@@ -87,4 +88,6 @@
     // now clear the queue
     gamestateQueue.clear();
+    //and call all queued callbacks
+    NetworkCallbackManager::callCallbacks();
     return true;
   }
@@ -135,6 +138,5 @@
     if(!reference)
       return 0;
-    gs = reference->doSelection(clientID);
-//     gs = new packet::Gamestate(*reference);
+    gs = reference->doSelection(clientID, 10000);
 //     gs = new packet::Gamestate(*reference);
     // save the (undiffed) gamestate in the clients gamestate map
Index: code/branches/bugger/src/network/NetworkCallback.h
===================================================================
--- code/branches/bugger/src/network/NetworkCallback.h	(revision 2530)
+++ 	(revision )
@@ -1,32 +1,0 @@
-#ifndef _NETWORK_CALLBACK__
-#define _NETWORK_CALLBACK__
-
-#include "NetworkPrereqs.h"
-
-namespace orxonox{
-  class _NetworkExport NetworkCallbackBase
-  {
-    public:
-      virtual void call() = 0;
-	  virtual ~NetworkCallbackBase() {}
-  };
-
-  template <class T>
-  class NetworkCallback: public NetworkCallbackBase
-  {
-    public:
-      NetworkCallback(T* object, void (T::*function) (void)) : object_(object), function_(function) {}
-	  virtual ~NetworkCallback() {}
-      virtual void call()
-        { (this->object_->*function_)(); }
-
-    private:
-      T* object_;
-      void (T::*function_) (void);
-  };
-
-
-}
-
-
-#endif
Index: code/branches/bugger/src/network/NetworkPrereqs.h
===================================================================
--- code/branches/bugger/src/network/NetworkPrereqs.h	(revision 2530)
+++ code/branches/bugger/src/network/NetworkPrereqs.h	(revision 2531)
@@ -57,8 +57,25 @@
 
 //-----------------------------------------------------------------------
+// Includes
+//-----------------------------------------------------------------------
+#include "util/Integers.h"
+
+
+//-----------------------------------------------------------------------
 // Forward declarations
 //-----------------------------------------------------------------------
 namespace orxonox
 {
+
+// Constants definition
+
+  static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
+  static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;
+  static const uint32_t OBJECTID_UNKNOWN = static_cast<uint32_t>(-1);
+  static const unsigned int SCHED_PRIORITY_OFFSET = -5;
+
+  
+
+  
   class Client;
   class ClientConnection;
@@ -70,13 +87,20 @@
   class GamestateManager;
   class GamestateHandler;
+  class NetworkCallbackBase;
+  template <class T> class NetworkCallback;
+  class NetworkCallbackManager;
   class PacketBuffer;
   class Server;
   class ServerFrameListener;
   class Synchronisable;
+  class SynchronisableVariableBase;
+  template <class T> class SynchronisableVariable;
+  template <class T> class SynchronisableVariableBidirectional;
   struct ClientList;
   struct PacketEnvelope;
   struct QueueItem;
   struct syncData;
-  struct synchronisableVariable;
+  class obj;
+  class objInfo;
   namespace packet{
     class Gamestate;
Index: code/branches/bugger/src/network/Synchronisable.cc
===================================================================
--- code/branches/bugger/src/network/Synchronisable.cc	(revision 2530)
+++ 	(revision )
@@ -1,638 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Dumeni Manatschal, (C) 2007
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
-
-//
-// C++ Implementation: synchronisable
-//
-// Description:
-//
-//
-// Author:  Dumeni, Oliver Scheuss, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-
-#include "Synchronisable.h"
-
-#include <cstring>
-#include <string>
-#include <iostream>
-#include <assert.h>
-
-#include "core/CoreIncludes.h"
-#include "core/BaseObject.h"
-// #include "core/Identifier.h"
-
-#include "Host.h"
-namespace orxonox
-{
-
-
-  std::map<unsigned int, Synchronisable *> Synchronisable::objectMap_;
-  std::queue<unsigned int> Synchronisable::deletedObjects_;
-
-  uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
-
-  /**
-  * Constructor:
-  * Initializes all Variables and sets the right objectID
-  */
-  Synchronisable::Synchronisable(BaseObject* creator){
-    RegisterRootObject(Synchronisable);
-    static uint32_t idCounter=0;
-    objectFrequency_=1;
-    objectMode_=0x1; // by default do not send data to server
-    if ( !Host::running() || ( Host::running() && Host::isServer() ) )
-    {
-      this->objectID = idCounter++; //this is only needed when running a server
-    //add synchronisable to the objectMap
-      objectMap_[this->objectID] = this;
-    }
-    else
-      objectID=OBJECTID_UNKNOWN;
-    classID = (unsigned int)-1;
-    syncList = new std::list<synchronisableVariable *>;
-
-
-#ifndef NDEBUG
-    ObjectList<Synchronisable>::iterator it;
-    for(it = ObjectList<Synchronisable>::begin(); it!=ObjectList<Synchronisable>::end(); ++it){
-      if( it->getObjectID()==this->objectID )
-        if(!(*it==this || (it->objectID==OBJECTID_UNKNOWN && it->objectMode_==0x0)))
-        {
-            COUT(1) << "Assertion failed: *it==this || (it->objectID==OBJECTID_UNKNOWN && it->objectMode_==0x0)" << std::endl;
-            COUT(1) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
-            abort();
-        }
-    }
-#endif
-
-    this->creatorID = OBJECTID_UNKNOWN;
-
-    searchcreatorID:
-    if (creator)
-    {
-        Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
-        if (synchronisable_creator && synchronisable_creator->objectMode_)
-        {
-            this->creatorID = synchronisable_creator->getObjectID();
-        }
-        else if (creator != creator->getCreator())
-        {
-            creator = creator->getCreator();
-            goto searchcreatorID;
-        }
-    }
-  }
-
-  /**
-   * Destructor:
-   * Delete all callback objects and remove objectID from the objectMap_
-   */
-  Synchronisable::~Synchronisable(){
-    // delete callback function objects
-    if(!Identifier::isCreatingHierarchy()){
-      for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)
-        delete (*it)->callback;
-      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
-        deletedObjects_.push(objectID);
-//       COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;
-//       COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl;
-//       assert(objectMap_[objectID]->objectID==objectID);
-//       objectMap_.erase(objectID);
-    }
-    std::map<unsigned int, Synchronisable*>::iterator it;
-    it = objectMap_.find(objectID);
-    if (it != objectMap_.end())
-      objectMap_.erase(it);
-  }
-
-  /**
-   * This function gets called after all neccessary data has been passed to the object
-   * Overload this function and recall the create function of the parent class
-   * @return true/false
-   */
-  bool Synchronisable::create(){
-    this->classID = this->getIdentifier()->getNetworkID();
-//     COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
-
-//     COUT(3) << "construct synchronisable +++" << objectID << " | " << classID << std::endl;
-//     objectMap_[objectID]=this;
-//     assert(objectMap_[objectID]==this);
-//     assert(objectMap_[objectID]->objectID==objectID);
-    return true;
-  }
-
-
-  /**
-   * This function sets the internal mode for synchronisation
-   * @param b true if this object is located on a client or on a server
-   */
-  void Synchronisable::setClient(bool b){
-    if(b) // client
-      state_=0x2;
-    else  // server
-      state_=0x1;
-  }
-
-  /**
-   * This function fabricated a new synchrnisable (and children of it), sets calls updateData and create
-   * After calling this function the mem pointer will be increased by the size of the needed data
-   * @param mem pointer to where the appropriate data is located
-   * @param mode defines the mode, how the data should be loaded
-   * @return pointer to the newly created synchronisable
-   */
-  Synchronisable *Synchronisable::fabricate(uint8_t*& mem, uint8_t mode)
-  {
-    synchronisableHeader *header = (synchronisableHeader *)mem;
-
-    if(!header->dataAvailable)
-    {
-      mem += header->size;
-      return 0;
-    }
-
-    COUT(4) << "fabricating object with id: " << header->objectID << std::endl;
-
-    Identifier* id = ClassByID(header->classID);
-    if (!id)
-    {
-        COUT(1) << "Assertion failed: id" << std::endl;
-        COUT(1) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl;
-        abort();
-    }
-    assert(id);
-    BaseObject* creator = 0;
-    if (header->creatorID != OBJECTID_UNKNOWN)
-    {
-      Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header->creatorID);
-      if (!synchronisable_creator)
-      {
-        mem += header->size; //.TODO: this suckz.... remove size from header
-        return 0;
-      }
-      else
-        creator = dynamic_cast<BaseObject*>(synchronisable_creator);
-    }
-    assert(getSynchronisable(header->objectID)==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;
-    COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
-          // update data and create object/entity...
-    bool b = no->updateData(mem, mode, true);
-    assert(b);
-    if (b)
-    {
-        b = no->create();
-        assert(b);
-    }
-    return no;
-  }
-
-
-  /**
-   * Finds and deletes the Synchronisable with the appropriate objectID
-   * @param objectID objectID of the Synchronisable
-   * @return true/false
-   */
-  bool Synchronisable::deleteObject(unsigned int objectID){
-//     assert(getSynchronisable(objectID));
-    if(!getSynchronisable(objectID))
-      return false;
-    assert(getSynchronisable(objectID)->objectID==objectID);
-//     delete objectMap_[objectID];
-    Synchronisable *s = getSynchronisable(objectID);
-    if(s)
-      delete s;
-    else
-      return false;
-    return true;
-  }
-
-  /**
-   * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable
-   * @param objectID objectID of the Synchronisable
-   * @return pointer to the Synchronisable with the objectID
-   */
-  Synchronisable* Synchronisable::getSynchronisable(unsigned int objectID){
-    std::map<unsigned int, Synchronisable*>::iterator it1;
-    it1 = objectMap_.find(objectID);
-    if (it1 != objectMap_.end())
-      return it1->second;
-
-    ObjectList<Synchronisable>::iterator it;
-    for(it = ObjectList<Synchronisable>::begin(); it; ++it){
-      if( it->getObjectID()==objectID ){
-        objectMap_[objectID] = *it;
-        return *it;
-      }
-    }
-    return NULL;
-  }
-
-
-  /**
-  * This function is used to register a variable to be synchronized
-  * also counts the total datasize needed to save the variables
-  * @param var pointer to the variable
-  * @param size size of the datatype the variable consists of
-  * @param t the type of the variable (DATA or STRING
-  * @param mode same as in getData
-  * @param cb callback object that should get called, if the value of the variable changes
-  */
-  void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){
-    assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);
-    // create temporary synch.Var struct
-    synchronisableVariable *temp = new synchronisableVariable;
-    temp->size = size;
-    temp->var = var;
-    temp->mode = mode;
-    temp->type = t;
-    temp->callback = cb;
-    if( ( mode & direction::bidirectional ) )
-    {
-      if(t!=STRING)
-      {
-        temp->varBuffer = new uint8_t[size];
-        memcpy(temp->varBuffer, temp->var, size); //now fill the buffer for the first time
-      }
-      else
-      {
-        temp->varBuffer=new std::string( *static_cast<std::string*>(var) );
-      }
-      temp->varReference = 0;
-    }
-    COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl;
-    //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl;
-    COUT(5) << "Syncronisable::objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl;
-    syncList->push_back(temp);
-#ifndef NDEBUG
-    std::list<synchronisableVariable *>::iterator it = syncList->begin();
-    while(it!=syncList->end()){
-      assert(*it!=var);
-      it++;
-    }
-#endif
-  }
-
-  void Synchronisable::unregisterVariable(void *var){
-    std::list<synchronisableVariable *>::iterator it = syncList->begin();
-    while(it!=syncList->end()){
-      if( (*it)->var == var ){
-        delete *it;
-        syncList->erase(it);
-        return;
-      }
-      else
-        it++;
-    }
-    bool unregistered_nonexistent_variable = false;
-    assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
-    // the variable has not been registered before
-  }
-
-
-  /**
-   * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID and classID to the given memory
-   * takes a pointer to already allocated memory (must have at least getSize bytes length)
-   * structure of the bitstream:
-   * |totalsize,objectID,classID,var1,var2,string1_length,string1,var3,...|
-   * length of varx: size saved int syncvarlist
-   * @param mem pointer to allocated memory with enough size
-   * @param id gamestateid of the gamestate to be saved (important for priorities)
-   * @param mode defines the direction in which the data will be send/received
-   *             0x1: server->client
-   *             0x2: client->server (not recommended)
-   *             0x3: bidirectional
-   * @return true: if !doSync or if everything was successfully saved
-   */
-  bool Synchronisable::getData(uint8_t*& mem, unsigned int id, uint8_t mode){
-    if(mode==0x0)
-      mode=state_;
-    //if this tick is we dont synchronise, then abort now
-    if(!doSync(id, mode))
-      return true;
-    //std::cout << "inside getData" << std::endl;
-    unsigned int tempsize = 0;
-    if(classID==0)
-      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
-
-    if (this->classID == (unsigned int)-1)
-        this->classID = this->getIdentifier()->getNetworkID();
-
-    assert(this->classID==this->getIdentifier()->getNetworkID());
-//     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
-    std::list<synchronisableVariable *>::iterator i;
-    unsigned int size;
-    size=getSize(id, mode);
-
-    // 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);
-    // end copy header
-
-
-    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
-    // copy to location
-    for(i=syncList->begin(); i!=syncList->end(); ++i){
-      if( ((*i)->mode & mode) == 0 ){
-        COUT(5) << "not getting data: " << std::endl;
-        continue;  // this variable should only be received
-      }
-
-      // =========== start bidirectional stuff =============
-      // if the variable gets synchronised bidirectional, then add the reference to the bytestream
-      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
-      {
-        if( ( ((*i)->mode == direction::serverMaster) && (mode == 0x1) ) || \
-            ( ((*i)->mode == direction::clientMaster) && (mode == 0x2) ) )
-        {
-          // MASTER
-          if((*i)->type==DATA){
-            if( memcmp((*i)->var,(*i)->varBuffer,(*i)->size) != 0 ) //check whether the variable changed during the last tick
-            {
-              ((*i)->varReference)++;   //the variable changed so increase the refnr
-              memcpy((*i)->varBuffer, (*i)->var, (*i)->size); //set the buffer to the new value
-            }
-          }
-          else //STRING
-          {
-            if( *static_cast<std::string*>((*i)->var) != *static_cast<std::string*>((*i)->varBuffer) ) //the string changed
-            {
-              ((*i)->varReference)++;   //the variable changed
-              *static_cast<std::string*>((*i)->varBuffer) = *static_cast<std::string*>((*i)->var);  //now set the buffer to the new value
-            }
-          }
-        }
-        // copy the reference number to the stream
-        *(uint8_t*)mem = (*i)->varReference;
-        mem += sizeof( (*i)->varReference );
-        tempsize += sizeof( (*i)->varReference );
-      }
-      // ================== end bidirectional stuff
-
-      switch((*i)->type){
-        case DATA:
-          memcpy( (void *)(mem), (void*)((*i)->var), (*i)->size);
-          mem += (*i)->size;
-          tempsize += (*i)->size;
-          break;
-        case STRING:
-          memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(size_t) );
-          mem += sizeof(size_t);
-          const char *data = ( ( *(std::string *) (*i)->var).c_str());
-          memcpy( mem, (void*)data, (*i)->size);
-          COUT(5) << "synchronisable: char: " << (const char *)(mem) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
-          mem += (*i)->size;
-          tempsize += (*i)->size + sizeof(size_t);
-          break;
-      }
-    }
-    assert(tempsize==size);
-    return true;
-  }
-
-
-  /**
-   * This function takes a bytestream and loads the data into the registered variables
-   * @param mem pointer to the bytestream
-   * @param mode same as in getData
-   * @return true/false
-   */
-  bool Synchronisable::updateData(uint8_t*& mem, uint8_t mode, bool forceCallback){
-    if(mode==0x0)
-      mode=state_;
-    std::list<synchronisableVariable *>::iterator i;
-    //assert(objectMode_!=0x0);
-    //assert( (mode ^ objectMode_) != 0);
-    if(syncList->empty()){
-      COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
-      return false;
-    }
-
-    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;
-      return true;
-    }
-
-    mem += sizeof(synchronisableHeader);
-    // 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++){
-      if( ((*i)->mode ^ mode) == 0 ){
-        COUT(5) << "synchronisable: not updating variable " << std::endl;
-        // if we have a forcecallback then do the callback
-        continue;  // this variable should only be set
-      }
-      COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl;
-      bool callback=false;
-      bool master=false;
-
-      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
-      {
-        uint8_t refNr = *(uint8_t *)mem;
-        if( ( ((*i)->mode == direction::serverMaster) && (mode == 0x1) ) || \
-            ( ((*i)->mode == direction::clientMaster) && (mode == 0x2) ) )
-        { // MASTER
-          master=true;
-          if( refNr != (*i)->varReference || ( memcmp((*i)->var, (*i)->varBuffer, (*i)->size) != 0 ) )
-          { // DISCARD data
-            if( (*i)->type == DATA )
-            {
-              mem += sizeof((*i)->varReference) + (*i)->size;
-            }
-            else //STRING
-            {
-              mem += sizeof(size_t) + *(size_t *)mem;
-            }
-            if( forceCallback && (*i)->callback)
-              (*i)->callback->call();
-            continue;
-          }//otherwise everything is ok and we update the value
-        }
-        else // SLAVE
-        {
-          if( (*i)->varReference == refNr ){
-            //discard data because it's outdated or not different to what we've got
-            if( (*i)->type == DATA )
-            {
-              mem += sizeof((*i)->varReference) + (*i)->size;
-            }
-            else //STRING
-            {
-              mem += sizeof(size_t) + *(size_t *)mem;
-            }
-            if( forceCallback && (*i)->callback)
-              (*i)->callback->call();
-            continue;
-          }
-          else
-            (*i)->varReference = refNr; //copy the reference value for this variable
-        }
-        mem += sizeof((*i)->varReference);
-      }
-
-      switch((*i)->type){
-        case DATA:
-          if((*i)->callback) // check whether this variable changed (but only if callback was set)
-          {
-            if(memcmp((*i)->var, mem, (*i)->size) != 0)
-              callback=true;
-          }
-          if( master )
-          {
-            if( callback || memcmp((*i)->var, mem, (*i)->size) != 0 )
-              //value changed, so set the buffer to the new value
-              memcpy((*i)->varBuffer, mem, (*i)->size);
-          }
-          memcpy((*i)->var, mem, (*i)->size);
-          mem += (*i)->size;
-          break;
-        case STRING:
-          (*i)->size = *(size_t *)mem;
-          mem += sizeof(size_t);
-
-          if( (*i)->callback) // check whether this string changed
-            if( *static_cast<std::string*>((*i)->var) != std::string((char *)mem) )
-              callback=true;
-          if( master )
-          {
-            if( callback || *static_cast<std::string*>((*i)->var) != std::string((char *)mem) )
-              //string changed. set the buffer to the new one
-              *static_cast<std::string*>((*i)->varBuffer)=*static_cast<std::string*>( (void*)(mem+sizeof(size_t)) );
-          }
-
-          *((std::string *)((*i)->var)) = std::string((const char*)mem);
-          COUT(5) << "synchronisable: char: " << (const char*)mem << " string: " << std::string((const char*)mem) << std::endl;
-          mem += (*i)->size;
-          break;
-      }
-      // call the callback function, if defined
-      if((callback || forceCallback) && (*i)->callback)
-        (*i)->callback->call();
-    }
-    assert(mem == data+syncHeader->size);
-    return true;
-  }
-
-  /**
-  * This function returns the total amount of bytes needed by getData to save the whole content of the variables
-  * @param id id of the gamestate
-  * @param mode same as getData
-  * @return amount of bytes
-  */
-  uint32_t Synchronisable::getSize(unsigned int id, uint8_t mode){
-    int tsize=sizeof(synchronisableHeader);
-    if(mode==0x0)
-      mode=state_;
-    if(!doSync(id, mode))
-      return 0;
-    std::list<synchronisableVariable *>::iterator i;
-    for(i=syncList->begin(); i!=syncList->end(); i++){
-      if( ((*i)->mode & mode) == 0 )
-        continue;  // this variable should only be received, so dont add its size to the send-size
-      switch((*i)->type){
-      case DATA:
-        tsize+=(*i)->size;
-        break;
-      case STRING:
-        tsize+=sizeof(int);
-        (*i)->size=((std::string *)(*i)->var)->length()+1;
-        COUT(5) << "String size: " << (*i)->size << std::endl;
-        tsize+=(*i)->size;
-        break;
-      }
-      if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
-      {
-        tsize+=sizeof( (*i)->varReference );
-      }
-    }
-    return tsize;
-  }
-
-  /**
-   * This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction)
-   * @param id gamestate id
-   * @return true/false
-   */
-  bool Synchronisable::doSync(unsigned int id, uint8_t mode){
-    if(mode==0x0)
-      mode=state_;
-    return ( (objectMode_&mode)!=0 && (!syncList->empty() ) );
-  }
-
-  bool Synchronisable::doSelection(unsigned int id){
-    return true; //TODO: change this
-    //return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0);
-  }
-
-  /**
-   * This function looks at the header located in the bytestream and checks wheter objectID and classID match with the Synchronisables ones
-   * @param mem pointer to the bytestream
-   */
-  bool Synchronisable::isMyData(uint8_t* mem)
-  {
-    synchronisableHeader *header = (synchronisableHeader *)mem;
-    assert(header->objectID==this->objectID);
-    return header->dataAvailable;
-  }
-
-  /**
-   * This function sets the synchronisation mode of the object
-   * If set to 0x0 variables will not be synchronised at all
-   * If set to 0x1 variables will only be synchronised to the client
-   * If set to 0x2 variables will only be synchronised to the server
-   * If set to 0x3 variables will be synchronised bidirectionally (only if set so in registerVar)
-   * @param mode same as in registerVar
-   */
-  void Synchronisable::setObjectMode(uint8_t mode){
-    assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3);
-    objectMode_=mode;
-  }
-
-
-}
Index: code/branches/bugger/src/network/Synchronisable.h
===================================================================
--- code/branches/bugger/src/network/Synchronisable.h	(revision 2530)
+++ 	(revision )
@@ -1,145 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss, (C) 2007
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _Synchronisable_H__
-#define _Synchronisable_H__
-
-#include "NetworkPrereqs.h"
-
-#include <list>
-#include <map>
-#include <queue>
-#include "util/Integers.h"
-#include "core/OrxonoxClass.h"
-#include "core/XMLIncludes.h"
-#include "NetworkCallback.h"
-#include "util/Integers.h"
-
-#define REGISTERDATA(varname, ...) \
-    registerVariable((void*)&varname, sizeof(varname), DATA, __VA_ARGS__)
-#define REGISTERSTRING(stringname, ...) \
-    registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)
-
-namespace orxonox
-{
-  static const unsigned int OBJECTID_UNKNOWN = (unsigned int)-1;
-
-  namespace direction{
-    enum syncdirection{
-      toclient=0x1,
-      toserver=0x2,
-      bidirectional=0x3,
-      serverMaster=0x3,
-      clientMaster=0x7
-    };
-  }
-
-  namespace syncmode{
-    enum mode{
-      once=0,
-      always=1
-    };
-  }
-
-  enum variableType{
-    DATA,
-    STRING,
-  };
-
-  struct _NetworkExport synchronisableHeader{
-    uint32_t size:31;
-    bool dataAvailable:1;
-    uint32_t objectID;
-    uint32_t creatorID;
-    uint32_t classID;
-  };
-
-  struct _NetworkExport synchronisableVariable{
-    size_t size;
-    uint8_t mode; // this determines in which direction the variable gets synchronised
-    void *var;
-    variableType type;
-    NetworkCallbackBase *callback;
-    void *varBuffer;
-    uint8_t varReference;
-  };
-
-  /**
-  * 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.
-  * @author Oliver Scheuss
-  */
-  class _NetworkExport Synchronisable : virtual public OrxonoxClass{
-  public:
-    friend class packet::Gamestate;
-//     friend class Server;
-    virtual ~Synchronisable();
-
-
-    virtual bool create();
-    static void setClient(bool b);
-
-    static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0);
-    static bool deleteObject(unsigned int objectID);
-    static Synchronisable *getSynchronisable(unsigned int objectID);
-    static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); }
-    static unsigned int popDeletedObject(){ unsigned int i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
-
-    inline unsigned int getObjectID() const { return objectID; }
-    inline unsigned int getClassID() const { return classID; }
-  protected:
-    Synchronisable(BaseObject* creator);
-    void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
-    void unregisterVariable(void *var);
-    void setObjectMode(uint8_t mode);
-    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
-
-
-  private:
-    bool getData(uint8_t*& men, unsigned int id, uint8_t mode=0x0);
-    uint32_t getSize(unsigned int id, uint8_t mode=0x0);
-    bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
-    bool isMyData(uint8_t* mem);
-    bool doSelection(unsigned int id);
-    bool doSync(unsigned int id, uint8_t mode=0x0);
-
-    unsigned int objectID;
-    unsigned int creatorID;
-    unsigned int classID;
-
-    std::list<synchronisableVariable *> *syncList;
-    static uint8_t state_; // detemines wheter we are server (default) or client
-    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
-    unsigned int objectFrequency_;
-    int objectMode_;
-    static std::map<unsigned int, Synchronisable *> objectMap_;
-    static std::queue<unsigned int> deletedObjects_;
-  };
-}
-
-#endif /* _Synchronisable_H__ */
Index: code/branches/bugger/src/network/TrafficControl.cc
===================================================================
--- code/branches/bugger/src/network/TrafficControl.cc	(revision 2531)
+++ code/branches/bugger/src/network/TrafficControl.cc	(revision 2531)
@@ -0,0 +1,395 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "TrafficControl.h"
+
+#include "synchronisable/Synchronisable.h"
+
+#include <cassert>
+#include <boost/bind.hpp>
+
+namespace orxonox {
+
+  objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched)
+  { 
+    objID = ID; objCreatorID = creatorID; objCurGS = curGsID; objDiffGS = diffGsID; objSize = size; objValuePerm = prioperm; objValueSched = priosched; 
+  }
+  
+  objInfo::objInfo()
+  { 
+    objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objCurGS = GAMESTATEID_INITIAL; objDiffGS = objCurGS; objSize = 0; objValuePerm = 0; objValueSched = 0; 
+  }
+  
+  
+  
+  obj::obj()
+  { 
+    objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objSize = 0; objDataOffset = 0; 
+  }
+  obj::obj( uint32_t ID, uint32_t creatorID, uint32_t size, uint32_t offset )
+  {
+    objID = ID; objCreatorID = creatorID; objSize = size; objDataOffset = offset;
+  }
+  
+/**
+*Initializing protected members
+*/
+	TrafficControl *TrafficControl::instance_=0;
+	
+	/**
+	* @brief Constructor: assures that only one reference will be created and sets the pointer
+	*/
+	TrafficControl::TrafficControl()
+	{
+	  assert(instance_==0);
+	  instance_=this;
+    targetSize = 1000;//5000bytes
+	}
+	
+	/**
+	* @brief Destructor: resets the instance pointer to 0
+	*/
+	TrafficControl::~TrafficControl()
+	{ 
+	  //was macht das genau? da instance ja gleich this ist im moment
+	  instance_=0;
+	  //muss ich alles deallozieren was ich im constructor aufgebaut habe?
+	}
+
+/**
+*Definition of public members
+*/
+
+  /**
+          *eigener sortieralgorithmus
+  */
+//   bool TrafficControl::priodiffer(obj i, obj j)
+//   {
+//     std::map<unsigned int, objInfo>::iterator iti;
+//     std::map<unsigned int, objInfo>::iterator itj;
+//     iti=listToProcess_.find(i.objID);
+//     itj=listToProcess_.find(j.objID);
+//     return iti->second.objValuePerm < itj->second.objValuePerm;
+//   }
+  
+  /**
+  * eigener sortieralgorithmus
+  */
+  bool TrafficControl::priodiffer(uint32_t clientID, obj i, obj j)
+  {
+    assert(clientListPerm_.find(clientID) != clientListPerm_.end());  //make sure the client exists in our list
+    assert(clientListPerm_[clientID].find(i.objID) != clientListPerm_[clientID].end()); // make sure the object i is in the client list
+    assert(clientListPerm_[clientID].find(j.objID) != clientListPerm_[clientID].end()); // make sure the object j is in the client list
+    
+    int prio1 = clientListPerm_[clientID][i.objID].objValuePerm + clientListPerm_[clientID][i.objID].objValueSched;
+    int prio2 = clientListPerm_[clientID][j.objID].objValuePerm + clientListPerm_[clientID][j.objID].objValueSched;
+//     int prio1 = clientListPerm_[clientID][i.objID].objID;
+//     int prio2 = clientListPerm_[clientID][j.objID].objID;
+    // NOTE: smaller priority is better
+    return prio1 < prio2;
+  }
+
+
+	void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list)
+	{
+// 	  copiedVector = *list;
+	  currentClientID=clientID;
+	  currentGamestateID=gamestateID;
+	  evaluateList(clientID, list);
+	  //list hatte vorher ja vielmehr elemente, nach zuweisung nicht mehr... speicherplatz??
+// 	  *list=copiedVector;
+    //später wird copiedVector ja überschrieben, ist das ein problem für list-dh. für gamestatemanager?
+	  return;
+	}
+	
+	void TrafficControl::processAck(unsigned int clientID, unsigned int gamestateID)
+	{
+	  std::list<obj>::iterator itvec;  // iterator to iterate through the acked objects
+    
+    //assertions to make sure the maps already exist
+    assert(clientListTemp_.find(clientID) != clientListTemp_.end() );
+    assert(clientListPerm_.find(clientID) != clientListPerm_.end() );
+	  assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
+    
+    for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++)
+	  {
+      if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists
+      {
+        clientListPerm_[clientID][(*itvec).objID].objID = gamestateID;
+      }
+      else
+      {
+        clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
+        clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;
+        clientListPerm_[clientID][(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
+        clientListPerm_[clientID][(*itvec).objID].objSize = (*itvec).objSize;
+      }
+	  }
+	   // remove temporary list (with acked objects) from the map
+    clientListTemp_[clientID].erase( clientListTemp_[clientID].find(gamestateID) );
+	}
+
+/**
+*Definition of private members
+*/
+	
+	
+	/**
+	*copyList gets list of Gamestate Manager and turns it to *listToProcess
+	*/
+// 	void TrafficControl::copyList(std::list<obj> *list)
+// 	{
+// 	  std::list<obj>::iterator itvec;
+// 	  for(itvec = (*list).begin(); itvec != (*list).end(); itvec++)
+// 	  {
+// 	    objInfo objectA;
+// 	    objectA.objCreatorID=(*itvec).objCreatorID;
+// 	    objectA.objSize = (*itvec).objSize;
+// 	    listToProcess_.insert(std::pair<currentClientID, map<(*itvec).objID,objectA>>);//unsicher: ob map<...> so richtig ist
+// 	  }
+// 	}
+	/**
+	*updateReferenceList compares the sent list by GSmanager with the current *reference list and updates it.
+	*returns void
+	*/
+// 	void TrafficControl::updateReferenceList(std::map<unsigned int, objInfo> *list)
+// 	{
+// 	  std::map<unsigned int, Synchronisable*>::iterator itref;
+// 	  std::map<unsigned int, objInfo>::iterator itproc;
+// 	  for(itproc=listToProcess_.begin(); itproc != listToProcess_.end(); itproc++)
+// 	  {
+// 	    //itproc->first=objectid that is looked for
+// 	    if(referenceList_->find(itproc->first))
+// 	    {
+// 	      continue;
+// 	    }
+// 	    else
+// 	    {
+// 	      (*referenceList_).insert(pair<unsigned int,          Synchronisable*>((*itproc).first,Synchronisable::getSynchronisable((*itproc).first)));//important: how to get adress of an object!
+// 	      insertinClientListPerm(currentClientID,itproc->first,itproc->second);
+// 	    }
+// 	  }
+// 	}
+	/**
+	*updateClientListPerm
+	*returns void
+	*/
+	void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf)
+	{ 
+	  std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs
+// 	  itperm = (clientListPerm_).find(clientID);
+// 	  assert(itperm != clientListPerm_.end() );
+    unsigned int gsid=GAMESTATEID_INITIAL, gsdiff=currentGamestateID, prioperm=Synchronisable::getSynchronisable(objinf.objID)->getPriority(), priomom=0;
+    clientListPerm_[clientID][objinf.objID] = objInfo(objinf.objID, objinf.objCreatorID,gsid,gsdiff, objinf.objSize,prioperm,priomom);
+// 	  itperm->second.insert(std::pair<unsigned int, objInfo>(objid,objinf));
+//     permObjPrio_.insert(objid, objinf.objValuePerm);
+	}
+	
+  /**
+  * updateClientListTemp
+  * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp
+  */	
+  void TrafficControl::updateClientListTemp(std::list<obj> *list)
+  {
+    clientListTemp_[currentClientID][currentGamestateID] = std::list<obj>(*list);
+//     std::list<obj>::iterator itvec;
+//     std::map<unsigned int,std::map<unsigned int, obj> >::iterator ittemp;
+//     std::map<unsigned int, obj>::iterator ittempgs;
+//     ittemp = clientListTemp_.find(currentClientID);
+//     ittempgs = (*ittemp).find(currentGamestateID);
+//     for(itvec = list.begin(); itvec!=list.end(), itvec++)
+//     {
+//       ittempgs.insert(itvec);
+//     }
+  }
+
+  /**
+  *cut
+  *takes the current list that has to be returned to the gsmanager and shortens it in criteria of bandwidth of clientID(XY)
+  */
+  void TrafficControl::cut(std::list<obj> *list, unsigned int targetsize)
+  {
+    unsigned int size=0;
+    std::list<obj>::iterator itvec;
+    assert(!list->empty());
+    itvec = list->begin();
+    for(itvec = list->begin(); itvec != list->end() && size<targetsize; itvec++)
+    {
+      assert( (*itvec).objSize < 1000);
+      if ( size + (*itvec).objSize < targetsize )
+      {
+        size += (*itvec).objSize;//objSize is given in bytes
+      }
+      else
+      {
+        clientListPerm_[currentClientID][(*itvec).objID].objValueSched -= SCHED_PRIORITY_OFFSET;
+        list->erase(itvec++);
+      }
+    }
+    assert(!list->empty());
+  }
+
+
+	/**
+	*evaluateList evaluates whether new obj are there, whether there are things to be updatet and manipulates all this.
+	*/
+	void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list)
+	{
+	  //copyList(list);
+	
+	  //now the sorting
+	
+	  //compare listToProcess vs clientListPerm
+    //if listToProcess contains new Objects, add them to clientListPerm
+// 	  std::map<unsigned int, objInfo>::iterator itproc;
+    std::list<obj>::iterator itvec;
+// 	  std::map<unsigned int, std::map<unsigned int, objInfo> >::iterator itperm;
+// 	  std::map<unsigned int, objInfo>::iterator itpermobj;
+	  for( itvec=list->begin(); itvec != list->end(); itvec++)
+	  {
+// 	    itperm = clientListPerm_.find(clientID);
+	    if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )
+      {
+        // we already have the object in our map
+        //obj bleibt in liste und permanente prio wird berechnet
+        clientListPerm_[clientID][(*itvec).objID].objDiffGS = currentGamestateID - clientListPerm_[clientID][(*itvec).objID].objCurGS;
+//         ((*itpermobj).second).objDiffGS = ((*itpermobj).second).objCurGS - currentGamestateID;
+//         permprio = clientListPerm_[clientID][(*itproc).first].objValuePerm;
+//         itpermprio = (permObjPrio_).find((*itproc).first);
+//         ((*itpermobj).second).objValuePerm = ((*itpermobj).second).objDiffGS * (*itpermprio).second;
+        continue;//check next objId
+      }
+      else
+      {
+        // insert the object into clientListPerm
+        insertinClientListPerm(clientID,*itvec);
+//         itpermobj=(*itperm).find((*itproc).first)
+//         ((*itpermobj).second).objDiffGS = ((*itpermobj).second).objCurGS - currentGamestateID;
+//         itpermprio = (permObjPrio_).find((*itproc).first);
+//         ((*itpermobj).second).objValuePerm = ((*itpermobj).second).objDiffGS * (*itpermprio).second;
+        continue;//check next objId
+      }
+    }
+	  //end compare listToProcess vs clientListPerm
+	
+    //listToProc vs clientListTemp
+    //TODO: uncomment it again and change some things
+    /*
+    std::map<unsigned int, std::map<unsigned int, unsigned int> >::iterator ittemp;
+    std::map<unsigned int, unsigned int>::iterator ittempgs;
+    for( itproc=listToProcess_.begin(); itproc != listToProcess_.end();itproc++)
+    {
+      ittemp = clientListTemp_->find(currentClientID);
+      if( ittempgs = (*ittemp).find(currentGamestateID))
+      {
+        if((*itproc).first == (*ittempgs).find((*itproc).first))//ja, dann ist objekt schon in der zu sendenden liste-muss nicht nochmal gesendet werden
+        {
+          (listToProcess_).erase (itproc);
+        }
+        else
+          continue;
+      }
+      else
+        continue;
+    }*/
+    //end listToProc vs clientListTemp
+    
+    //TODO: check whether we need this, cause i don't think so.
+    //listToProcess contains obj to send now, and since we give gsmanager the copiedlist and not listToProcess shorten copiedlist therefor too.
+    /*std::list<obj>::iterator itvec;
+    for(itvec = copiedVector.begin(); itvec != copiedVector.end(); itvec++)
+    {
+      if ( listToProcess_.find(itvec->objID) )
+      {
+        continue;//therefore object wasnt thrown out yet and has to be sent back to gsmanager
+      }
+      else
+      {
+        copiedVector.remove(itvec);
+      }
+    }*/
+    //sort copied list aufgrund der objprioperm in clientlistperm
+    // use boost bind here because we need to pass a memberfunction to stl sort
+    list->sort(boost::bind(&TrafficControl::priodiffer, this, clientID, _1, _2) );
+    
+    //now we check, that the creator of an object always exists on a client
+    printList(list, clientID);
+    std::list<obj>::iterator itcreator;
+    for(itvec = list->begin(); itvec != list->end(); itvec++)
+    { 
+      fixCreatorDependencies(itvec, list, clientID);
+    }
+    //end of sorting
+    //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden. 
+    cut(list, targetSize);
+    printList(list, clientID);
+    //diese Funktion updateClientList muss noch gemacht werden
+    updateClientListTemp(list);
+    //end of sorting
+  }
+
+  void TrafficControl::printList(std::list<obj> *list, unsigned int clientID)
+  {
+    std::list<obj>::iterator it;
+    COUT(0) << "=========== Objectlist ===========" << endl;
+    for( it=list->begin(); it!=list->end(); it++)
+      COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << endl;
+  }
+  
+  void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID)
+  {
+    if ( (*it1).objCreatorID == OBJECTID_UNKNOWN )
+      return;
+    if( clientListPerm_[clientID][(*it1).objCreatorID].objCurGS != GAMESTATEID_INITIAL )
+      return;
+    std::list<obj>::iterator it2, it3=it1;
+    for( it2 = ++it3; it2 != list->end(); it2++ )
+    {
+      if( (*it2).objID == (*it1).objCreatorID )
+      {
+        it3 = list->insert(it1, *it2); //insert creator before it1
+        list->erase(it2);
+//         printList(list, clientID);
+        fixCreatorDependencies( it3, list, clientID );
+        break;
+      }
+    }
+  }
+
+
+/*
+void bvlabla(list *a){
+//sort a
+list *cache;
+cache = new list<unsigned int>(*a);
+return a;
+}
+*/
+
+
+}//namespace network
Index: code/branches/bugger/src/network/TrafficControl.h
===================================================================
--- code/branches/bugger/src/network/TrafficControl.h	(revision 2531)
+++ code/branches/bugger/src/network/TrafficControl.h	(revision 2531)
@@ -0,0 +1,168 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORK_TRAFFICCONTROL_H
+#define NETWORK_TRAFFICCONTROL_H
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+#include <list>
+#include <map>
+#include <utility>
+#include <algorithm>
+#include "util/Integers.h"
+
+namespace orxonox {
+
+
+  /**
+   *a list of objects of this type will be given by the Server's Gamestate Manager
+   */
+  class objInfo
+  {
+    public:
+      uint32_t objID;
+      uint32_t objCreatorID;
+      uint32_t objCurGS;//current GameState ID
+      uint32_t objDiffGS;//difference between current and latest GameState
+      uint32_t objSize;
+      unsigned int objValuePerm;
+      unsigned int objValueSched;
+      objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched);
+      objInfo();
+  };
+
+/**
+   *a list of objects of this type will be given by the Server's Gamestate Manager
+ */
+  class obj
+  {
+    public:
+      uint32_t objID;
+      uint32_t objCreatorID;
+      uint32_t objSize;
+      uint32_t objDataOffset;
+      obj();
+      obj( uint32_t ID, uint32_t creatorID, uint32_t size, uint32_t offset );
+  };
+  
+
+
+
+/**
+*
+*/
+class TrafficControl{
+  private:
+
+    /**
+    *Lists that will be used:
+    *listToProcess
+    *clientListPerm
+    *clientListTemp
+    *referenceList
+    *permObjPrio list
+    *schedObjPrio
+    */
+    //start: lists to be used
+    /**
+    *creates list (typ map) that contains objids, struct with info concerning object(objid)
+    */
+//     std::map<unsigned int, objInfo> listToProcess_;//copy of argument, when traffic control tool is being called, the original of this must be returned later on, eg the list given by GS
+    /**
+    *permanent client list: contains client ids, object ids and objectInfos (in this order)
+    */
+    std::map<unsigned int, std::map<unsigned int, objInfo > > clientListPerm_;
+    //has to be created with constructor and then needs to be updated by evaluateList().
+
+    /**
+    *temporary client list: contains client ids, gamestate ids and object ids (in this order)
+    */
+    std::map<unsigned int, std::map<unsigned int, std::list<obj> > > clientListTemp_;
+    /**
+    *static priority list: contains obj id, basic priority (in this order)
+    */
+//     std::map<unsigned int, unsigned int> permObjPrio_;
+    /**
+    *dynamic priority list: contains obj id, dynamic priority (eg scheduled) (in this order)
+    */
+//     std::map<unsigned int, unsigned int> schedObjPrio_;
+    //end: lists to be used
+
+    /**updateReferenceList
+    *currentGamestateID and currentClientID will be defined as soon as TrafficControl is being called by Server
+    */
+    unsigned int currentGamestateID;
+    unsigned int currentClientID;
+    unsigned int targetSize;
+    /**
+    *copiedVector is a copy of the given Vector by the GSmanager, on this list all manipulations are performed
+    */
+//     std::list<obj> copiedVector;
+
+//     void updateReferenceList(std::map<unsigned int, objInfo> *list);//done
+    void insertinClientListPerm(unsigned int clientID, obj objinf);//done
+    /**
+    *creates listToProcess, which can be easialy compared with other lists
+    */
+//     void copyList(std::list<obj> *list);//done
+    
+    void cut(std::list<obj> *list, unsigned int targetsize);
+    void updateClientListTemp(std::list<obj> *list);//done
+    /**
+    *evaluates Data given (list) and produces result(->Data to be updated)
+    */
+    void evaluateList(unsigned int clientID, std::list<obj> *list);//done    
+
+  protected:
+    static TrafficControl *instance_;
+
+  public:
+    TrafficControl();
+    virtual ~TrafficControl();
+    /**
+    *is being used by GSManager from Server:
+    *list contains: ObjIds, CreatorIds, Size (in this order) from Client XY 
+    *Elements of list are accessed by *list[i]
+    *Elements of struct i are therefore: *list[i].objID
+    */
+    void processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj>* list); //gets a pointer to the list (containing objectIDs) and sorts it
+    //done
+    void processAck(unsigned int clientID, unsigned int gamestateID);	// this function gets called when the server receives an ack from the client
+    //done
+    void deleteObject(unsigned int objectID);				// this function gets called when an object has been deleted (in order to clean up lists and maps)
+    
+    bool priodiffer(uint32_t clientID, obj i, obj j);
+    void printList(std::list<obj> *list, unsigned int clientID);
+    void fixCreatorDependencies(std::list<obj>::iterator it, std::list<obj> *list, unsigned int clientID);
+};
+
+}
+
+#endif
+
Index: code/branches/bugger/src/network/packet/DeleteObjects.cc
===================================================================
--- code/branches/bugger/src/network/packet/DeleteObjects.cc	(revision 2530)
+++ code/branches/bugger/src/network/packet/DeleteObjects.cc	(revision 2531)
@@ -30,5 +30,5 @@
 #include "DeleteObjects.h"
 #include <enet/enet.h>
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 #include "core/CoreIncludes.h"
 #include <assert.h>
Index: code/branches/bugger/src/network/packet/Gamestate.cc
===================================================================
--- code/branches/bugger/src/network/packet/Gamestate.cc	(revision 2530)
+++ code/branches/bugger/src/network/packet/Gamestate.cc	(revision 2531)
@@ -28,6 +28,7 @@
 
 #include "Gamestate.h"
-#include "network/ClientInformation.h"
-#include "network/GamestateHandler.h"
+#include "../GamestateHandler.h"
+#include "../synchronisable/Synchronisable.h"
+#include "../TrafficControl.h"
 #include "core/Core.h"
 #include "core/CoreIncludes.h"
@@ -49,4 +50,6 @@
 
 #define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
+  
+TrafficControl Gamestate::trafficControl_;
 
 Gamestate::Gamestate()
@@ -74,7 +77,7 @@
 bool Gamestate::collectData(int id, uint8_t mode)
 {
-  unsigned int tempsize=0, currentsize=0;
+  uint32_t tempsize=0, currentsize=0;
   assert(data_==0);
-  unsigned int size = calcGamestateSize(id, mode);
+  uint32_t size = calcGamestateSize(id, mode);
 
   COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
@@ -110,5 +113,7 @@
 
     //if(it->doSelection(id))
-    dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
+    if(tempsize!=0)
+      dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
+//     dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
     if(!it->getData(mem, id, mode))
       return false; // mem pointer gets automatically increased because of call by reference
@@ -150,7 +155,8 @@
     {
       if (!Core::isMaster())
-        Synchronisable::fabricate(mem, mode);
+        s = Synchronisable::fabricate(mem, mode);
       else
         mem += objectheader->size;
+      assert(s);
     }
     else
@@ -170,5 +176,5 @@
 }
 
-unsigned int Gamestate::getSize() const
+uint32_t Gamestate::getSize() const
 {
   assert(data_);
@@ -255,7 +261,7 @@
   assert(HEADER->compressed);
   COUT(4) << "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;
+  uint32_t datasize = HEADER->datasize;
+  uint32_t compsize = HEADER->compsize;
+  uint32_t bufsize;
 //  assert(compsize<=datasize);
   bufsize = datasize;
@@ -306,6 +312,6 @@
   //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
   uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
-  unsigned int of=0; // pointers offset
-  unsigned int dest_length=0;
+  uint32_t of=0; // pointers offset
+  uint32_t dest_length=0;
   dest_length=HEADER->datasize;
   if(dest_length==0)
@@ -336,7 +342,7 @@
 }
 
-Gamestate* Gamestate::doSelection(unsigned int clientID){
+Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
   assert(data_);
-  std::map<unsigned int, Synchronisable *>::iterator it;
+  std::list<obj>::iterator it;
 
   // allocate memory for new data
@@ -345,5 +351,5 @@
   Gamestate *gs = new Gamestate(gdata);
   uint8_t *newdata = gdata + sizeof(GamestateHeader);
-  uint8_t *origdata = GAMESTATE_START(data_);
+//   uint8_t *origdata = GAMESTATE_START(data_);
 
   //copy the GamestateHeader
@@ -351,19 +357,25 @@
 
   synchronisableHeader *oldobjectheader, *newobjectheader;
-  unsigned int objectOffset;
-
+  uint32_t objectOffset;
+  unsigned int objectsize, destsize=0;
+  Synchronisable *object;
+
+  //call TrafficControl
+  trafficControl_.processObjectList( clientID, HEADER->id, &dataMap_ );
+  
   //copy in the zeros
   for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
-    if(it->second->getSize(HEADER->id)==0)
+    if((*it).objSize==0)
       continue;
-    oldobjectheader = (synchronisableHeader*)origdata;
+    oldobjectheader = (synchronisableHeader*)(data_ + (*it).objDataOffset);
     newobjectheader = (synchronisableHeader*)newdata;
-    unsigned int objectsize = oldobjectheader->size;
-    assert(it->second->objectID==oldobjectheader->objectID);
+    object = Synchronisable::getSynchronisable( (*it).objID );
+    assert(object->objectID == oldobjectheader->objectID);
+    objectsize = oldobjectheader->size;
     *newobjectheader = *oldobjectheader;
     objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader
-    if(it->second->doSelection(HEADER->id)){
+    if ( /*object->doSelection(HEADER->id)*/true ){
       assert(newobjectheader->dataAvailable==true);
-      memcpy(newdata+objectOffset, origdata+objectOffset, objectsize-objectOffset);
+      memcpy(newdata+objectOffset, data_ + (*it).objDataOffset + objectOffset, objectsize-objectOffset);
     }else{
       newobjectheader->dataAvailable=false;
@@ -372,6 +384,9 @@
     }
     newdata += objectsize;
-    origdata += objectsize;
-  }
+    destsize += objectsize;
+//     origdata += objectsize;
+  }
+  ((GamestateHeader*)gdata)->datasize = destsize;
+  assert(destsize!=0);
   return gs;
 }
@@ -388,10 +403,11 @@
 
   //preparations
-  std::map<unsigned int, Synchronisable *>::iterator it;
+  std::list<obj>::iterator it;
   uint8_t *origdata, *basedata, *destdata, *ndata;
-  unsigned int objectOffset, streamOffset=0;    //data offset
-  unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
+  uint32_t objectOffset, streamOffset=0;    //data offset
+  uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
   synchronisableHeader *origheader;
   synchronisableHeader *destheader;
+  Synchronisable *object;
 
   origdata = GAMESTATE_START(this->data_);
@@ -403,10 +419,11 @@
   for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
     assert(streamOffset<HEADER->datasize);
-    bool sendData = it->second->doSelection(HEADER->id);
     origheader = (synchronisableHeader *)(origdata+streamOffset);
     destheader = (synchronisableHeader *)(destdata+streamOffset);
+    object = Synchronisable::getSynchronisable(origheader->objectID);
+    bool sendData = object->doSelection(HEADER->id);
 
     //copy and partially diff the object header
-    assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
+    assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool));
     *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)
     *(bool*)(destdata+sizeof(uint32_t)) = sendData;
@@ -456,10 +473,11 @@
 
   //preparations
-  std::map<unsigned int, Synchronisable *>::iterator it;
+  std::list<obj>::iterator it;
   uint8_t *origdata, *basedata, *destdata, *ndata;
-  unsigned int objectOffset, streamOffset=0;    //data offset
-  unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
+  uint32_t objectOffset, streamOffset=0;    //data offset
+  uint32_t minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
   synchronisableHeader *origheader;
   synchronisableHeader *destheader;
+  Synchronisable *object;
 
   origdata = GAMESTATE_START(this->data_);
@@ -473,17 +491,18 @@
     origheader = (synchronisableHeader *)(origdata+streamOffset);
     destheader = (synchronisableHeader *)(destdata+streamOffset);
+    object = Synchronisable::getSynchronisable( origheader->objectID );
     bool sendData;
 
     //copy and partially diff the object header
-    assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
-    *(unsigned int*)destdata = *(unsigned int*)origdata; //size (do not diff)
-    *(bool*)(destdata+sizeof(unsigned int)) = *(bool*)(origdata+sizeof(unsigned int));
-    sendData = *(bool*)(origdata+sizeof(unsigned int));
+    assert(sizeof(synchronisableHeader)==3*sizeof(uint32_t)+sizeof(bool));
+    *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)
+    *(bool*)(destdata+sizeof(uint32_t)) = *(bool*)(origdata+sizeof(uint32_t));
+    sendData = *(bool*)(origdata+sizeof(uint32_t));
     if(sendData){
-      *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+sizeof(unsigned int)+sizeof(bool)); //objectid (diff it)
-      *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+2*sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+2*sizeof(unsigned int)+sizeof(bool)); //classid (diff it)
+      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+sizeof(uint32_t)+sizeof(bool)); //objectid (diff it)
+      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+2*sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+2*sizeof(uint32_t)+sizeof(bool)); //classid (diff it)
     }else{
-      *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;
-      *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;
+      *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0;
+      *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0;
     }
     objectOffset=sizeof(synchronisableHeader);
@@ -523,6 +542,6 @@
   uint8_t *basep = GAMESTATE_START(base->data_);
   uint8_t *gs = GAMESTATE_START(this->data_);
-  unsigned int of=0; // pointers offset
-  unsigned int dest_length=0;
+  uint32_t of=0; // pointers offset
+  uint32_t dest_length=0;
   dest_length=HEADER->datasize;
   if(dest_length==0)
@@ -554,7 +573,7 @@
 
 
-unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)
-{
-  unsigned int size=0;
+uint32_t Gamestate::calcGamestateSize(int32_t id, uint8_t mode)
+{
+  uint32_t size=0;
     // get the start of the Synchronisable list
   ObjectList<Synchronisable>::iterator it;
Index: code/branches/bugger/src/network/packet/Gamestate.h
===================================================================
--- code/branches/bugger/src/network/packet/Gamestate.h	(revision 2530)
+++ code/branches/bugger/src/network/packet/Gamestate.h	(revision 2531)
@@ -31,9 +31,11 @@
 #define NETWORK_PACKETGAMESTATE_H
 
-#include "../NetworkPrereqs.h"
+#include "network/NetworkPrereqs.h"
 
 #include "Packet.h"
-#include "network/Synchronisable.h"
+#include "network/TrafficControl.h"
+#include "core/CoreIncludes.h"
 #include <map>
+#include <list>
 #ifndef NDEBUG
 #include "util/CRC32.h"
@@ -79,5 +81,5 @@
     Gamestate *undiff(Gamestate *base);
     Gamestate* intelligentUnDiff(Gamestate *base);
-    Gamestate* doSelection(unsigned int clientID);
+    Gamestate* doSelection(unsigned int clientID, unsigned int targetSize);
     bool compressData();
     bool decompressData();
@@ -85,12 +87,13 @@
     // Packet functions
   private:
-    virtual unsigned int getSize() const;
+    virtual uint32_t getSize() const;
     virtual bool process();
 
     bool operator ==(packet::Gamestate gs);
   private:
-    unsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0);
+    uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
     void removeObject(ObjectListIterator<Synchronisable> &it);
-    std::map<unsigned int, Synchronisable*> dataMap_;
+    std::list<obj> dataMap_;
+    static TrafficControl trafficControl_;
 };
 
Index: code/branches/bugger/src/network/packet/Welcome.cc
===================================================================
--- code/branches/bugger/src/network/packet/Welcome.cc	(revision 2530)
+++ code/branches/bugger/src/network/packet/Welcome.cc	(revision 2531)
@@ -32,5 +32,5 @@
 #include "Welcome.h"
 #include "network/Host.h"
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 #include "core/CoreIncludes.h"
 #include <assert.h>
@@ -43,4 +43,5 @@
 #define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
 #define _SHIPID               _CLIENTID + sizeof(uint32_t)
+#define _ENDIANTEST           _SHIPID + sizeof(uint32_t)
   
   Welcome::Welcome( unsigned int clientID, unsigned int shipID )
@@ -52,6 +53,7 @@
   assert(data_);
   *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;
-  *(uint32_t *)&data_[ _CLIENTID ] = clientID;
-  *(uint32_t *)&data_[ _SHIPID ] = shipID;
+  *(uint32_t *)(data_ + _CLIENTID ) = clientID;
+  *(uint32_t *)(data_ + _SHIPID ) = shipID;
+  *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321;
 }
 
@@ -70,5 +72,5 @@
 
 unsigned int Welcome::getSize() const{
-  return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t);
+  return sizeof(packet::ENUM::Type) + 3*sizeof(uint32_t);
 }
 
@@ -77,4 +79,5 @@
   clientID = *(uint32_t *)&data_[ _CLIENTID ];
   shipID = *(uint32_t *)&data_[ _SHIPID ];
+  assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321);
   Host::setClientID(clientID);
   Host::setShipID(shipID);
Index: code/branches/bugger/src/network/synchronisable/CMakeLists.txt
===================================================================
--- code/branches/bugger/src/network/synchronisable/CMakeLists.txt	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/CMakeLists.txt	(revision 2531)
@@ -0,0 +1,8 @@
+SET( SRC_FILES
+  NetworkCallbackManager.cc
+  Synchronisable.cc
+  SynchronisableSpecialisations.cc
+  SynchronisableVariable.cc
+)
+
+ADD_SOURCE_FILES(SRC_FILES)
Index: code/branches/bugger/src/network/synchronisable/NetworkCallback.h
===================================================================
--- code/branches/bugger/src/network/synchronisable/NetworkCallback.h	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/NetworkCallback.h	(revision 2531)
@@ -0,0 +1,63 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _NETWORK_CALLBACK__
+#define _NETWORK_CALLBACK__
+
+#include "network/NetworkPrereqs.h"
+#include "NetworkCallbackManager.h"
+
+namespace orxonox{
+  
+  class _NetworkExport NetworkCallbackBase
+  {
+    public:
+      virtual void call() = 0;
+      NetworkCallbackBase(){ NetworkCallbackManager::registerCallback( this ); }
+      virtual ~NetworkCallbackBase() {}
+  };
+
+  template <class T>
+  class NetworkCallback: public NetworkCallbackBase
+  {
+    public:
+      NetworkCallback(T* object, void (T::*function) (void)) : object_(object), function_(function) {}
+	  virtual ~NetworkCallback() {}
+      virtual void call()
+        { (this->object_->*function_)(); }
+
+    private:
+      T* object_;
+      void (T::*function_) (void);
+  };
+
+}
+
+
+#endif
Index: code/branches/bugger/src/network/synchronisable/NetworkCallbackManager.cc
===================================================================
--- code/branches/bugger/src/network/synchronisable/NetworkCallbackManager.cc	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/NetworkCallbackManager.cc	(revision 2531)
@@ -0,0 +1,66 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+ 
+
+#include "NetworkCallbackManager.h"
+#include "NetworkCallback.h"
+
+namespace orxonox{
+
+  std::set<NetworkCallbackBase*> NetworkCallbackManager::callbackSet_;
+  std::queue<NetworkCallbackBase*> NetworkCallbackManager::triggeredCallbacks_;
+  
+  void NetworkCallbackManager::registerCallback(NetworkCallbackBase *cb)
+  { 
+    callbackSet_.insert(cb); 
+  }
+  void NetworkCallbackManager::deleteCallback(NetworkCallbackBase *cb)
+  {
+    std::set<NetworkCallbackBase*>::iterator it = callbackSet_.find(cb);
+    if (it != callbackSet_.end())
+    {
+      delete (*it);
+      callbackSet_.erase(it);
+    }
+  }
+  
+  void NetworkCallbackManager::triggerCallback(NetworkCallbackBase *cb)
+  {
+    if (triggeredCallbacks_.front() != cb)
+      triggeredCallbacks_.push(cb);
+  }
+
+  void NetworkCallbackManager::callCallbacks()
+  {
+    while( triggeredCallbacks_.empty()==false )
+    {
+      triggeredCallbacks_.front()->call();
+      triggeredCallbacks_.pop();
+    }
+  }
+}
Index: code/branches/bugger/src/network/synchronisable/NetworkCallbackManager.h
===================================================================
--- code/branches/bugger/src/network/synchronisable/NetworkCallbackManager.h	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/NetworkCallbackManager.h	(revision 2531)
@@ -0,0 +1,54 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _NETWORK_CALLBACKMANAGER__
+#define _NETWORK_CALLBACKMANAGER__
+
+#include "network/NetworkPrereqs.h"
+#include <set>
+#include <queue>
+
+namespace orxonox{
+  
+  class _NetworkExport NetworkCallbackManager{
+    public:
+      static void registerCallback(NetworkCallbackBase *cb);
+      static void deleteCallback(NetworkCallbackBase *cb);
+      static void triggerCallback(NetworkCallbackBase *cb);
+      static void callCallbacks();
+    private:
+      static std::set<NetworkCallbackBase*> callbackSet_;
+      static std::queue<NetworkCallbackBase*> triggeredCallbacks_;
+  };
+  
+
+}
+
+
+#endif
Index: code/branches/bugger/src/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/bugger/src/network/synchronisable/Synchronisable.cc	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/Synchronisable.cc	(revision 2531)
@@ -0,0 +1,449 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Dumeni Manatschal, (C) 2007
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: synchronisable
+//
+// Description:
+//
+//
+// Author:  Dumeni, Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+
+#include "Synchronisable.h"
+
+#include <cstring>
+#include <string>
+#include <iostream>
+#include <assert.h>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+// #include "core/Identifier.h"
+
+#include "network/Host.h"
+namespace orxonox
+{
+
+  std::map<uint32_t, Synchronisable *> Synchronisable::objectMap_;
+  std::queue<uint32_t> Synchronisable::deletedObjects_;
+
+  uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
+
+  /**
+  * Constructor:
+  * Initializes all Variables and sets the right objectID
+  */
+  Synchronisable::Synchronisable(BaseObject* creator){
+    RegisterRootObject(Synchronisable);
+    static uint32_t idCounter=0;
+    objectFrequency_=1;
+    objectMode_=0x1; // by default do not send data to server
+    if ( !Host::running() || ( Host::running() && Host::isServer() ) )
+    {
+      this->objectID = idCounter++; //this is only needed when running a server
+    //add synchronisable to the objectMap
+      objectMap_[this->objectID] = this;
+    }
+    else
+      objectID=OBJECTID_UNKNOWN;
+    classID = static_cast<uint32_t>(-1);
+
+
+//#ifndef NDEBUG
+//    ObjectList<Synchronisable>::iterator it;
+//    for(it = ObjectList<Synchronisable>::begin(); it!=ObjectList<Synchronisable>::end(); ++it){
+//        if(!(*it==this || (it->objectID==OBJECTID_UNKNOWN && it->objectMode_==0x0)))
+//        {
+//            COUT(1) << "Assertion failed: *it==this || (it->objectID==OBJECTID_UNKNOWN && it->objectMode_==0x0)" << std::endl;
+//            COUT(1) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
+//            abort();
+//        }
+//    }
+//#endif
+
+    this->creatorID = OBJECTID_UNKNOWN;
+
+    searchcreatorID:
+    if (creator)
+    {
+        Synchronisable* synchronisable_creator = dynamic_cast<Synchronisable*>(creator);
+        if (synchronisable_creator && synchronisable_creator->objectMode_)
+        {
+            this->creatorID = synchronisable_creator->getObjectID();
+        }
+        else if (creator != creator->getCreator())
+        {
+            creator = creator->getCreator();
+            goto searchcreatorID;
+        }
+    }
+  }
+
+  /**
+   * Destructor:
+   * Delete all callback objects and remove objectID from the objectMap_
+   */
+  Synchronisable::~Synchronisable(){
+    // delete callback function objects
+    if(!Identifier::isCreatingHierarchy()){
+      for(std::list<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
+        delete (*it);
+      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
+        deletedObjects_.push(objectID);
+//       COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;
+//       COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl;
+//       assert(objectMap_[objectID]->objectID==objectID);
+//       objectMap_.erase(objectID);
+    }
+    std::map<uint32_t, Synchronisable*>::iterator it;
+    it = objectMap_.find(objectID);
+    if (it != objectMap_.end())
+      objectMap_.erase(it);
+  }
+
+
+  /**
+   * This function sets the internal mode for synchronisation
+   * @param b true if this object is located on a client or on a server
+   */
+  void Synchronisable::setClient(bool b){
+    if(b) // client
+      state_=0x2;
+    else  // server
+      state_=0x1;
+  }
+
+  /**
+   * This function fabricated a new synchrnisable (and children of it), sets calls updateData and create
+   * After calling this function the mem pointer will be increased by the size of the needed data
+   * @param mem pointer to where the appropriate data is located
+   * @param mode defines the mode, how the data should be loaded
+   * @return pointer to the newly created synchronisable
+   */
+  Synchronisable *Synchronisable::fabricate(uint8_t*& mem, uint8_t mode)
+  {
+    synchronisableHeader *header = (synchronisableHeader *)mem;
+
+    if(!header->dataAvailable)
+    {
+      mem += header->size;
+      return 0;
+    }
+
+    COUT(4) << "fabricating object with id: " << header->objectID << std::endl;
+
+    Identifier* id = ClassByID(header->classID);
+    if (!id)
+    {
+        COUT(1) << "Assertion failed: id" << std::endl;
+        COUT(1) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl;
+        abort();
+    }
+    assert(id);
+    BaseObject* creator = 0;
+    if (header->creatorID != OBJECTID_UNKNOWN)
+    {
+      Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header->creatorID);
+      if (!synchronisable_creator)
+      {
+        mem += header->size; //.TODO: this suckz.... remove size from header
+        return 0;
+      }
+      else
+        creator = dynamic_cast<BaseObject*>(synchronisable_creator);
+    }
+    assert(getSynchronisable(header->objectID)==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;
+    COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
+          // update data and create object/entity...
+    bool b = no->updateData(mem, mode, true);
+    assert(b);
+    if (b)
+    {
+//        b = no->create();
+        assert(b);
+    }
+    return no;
+  }
+
+
+  /**
+   * Finds and deletes the Synchronisable with the appropriate objectID
+   * @param objectID objectID of the Synchronisable
+   * @return true/false
+   */
+  bool Synchronisable::deleteObject(uint32_t objectID){
+//     assert(getSynchronisable(objectID));
+    if(!getSynchronisable(objectID))
+      return false;
+    assert(getSynchronisable(objectID)->objectID==objectID);
+//     delete objectMap_[objectID];
+    Synchronisable *s = getSynchronisable(objectID);
+    if(s)
+      delete s;
+    else
+      return false;
+    return true;
+  }
+
+  /**
+   * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable
+   * @param objectID objectID of the Synchronisable
+   * @return pointer to the Synchronisable with the objectID
+   */
+  Synchronisable* Synchronisable::getSynchronisable(uint32_t objectID){
+    std::map<uint32_t, Synchronisable*>::iterator it1;
+    it1 = objectMap_.find(objectID);
+    if (it1 != objectMap_.end())
+      return it1->second;
+
+    ObjectList<Synchronisable>::iterator it;
+    for(it = ObjectList<Synchronisable>::begin(); it; ++it){
+      if( it->getObjectID()==objectID ){
+        objectMap_[objectID] = *it;
+        return *it;
+      }
+    }
+    return NULL;
+  }
+
+
+  /**
+  * This function is used to register a variable to be synchronized
+  * also counts the total datasize needed to save the variables
+  * @param var pointer to the variable
+  * @param size size of the datatype the variable consists of
+  * @param t the type of the variable (DATA or STRING
+  * @param mode same as in getData
+  * @param cb callback object that should get called, if the value of the variable changes
+  */
+
+/*  void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){
+    assert( mode==direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);
+    // create temporary synch.Var struct
+    synchronisableVariable *temp = new synchronisableVariable;
+    temp->size = size;
+    temp->var = var;
+    temp->mode = mode;
+    temp->type = t;
+    temp->callback = cb;
+    if( ( mode & direction::bidirectional ) )
+    {
+      if(t!=STRING)
+      {
+        temp->varBuffer = new uint8_t[size];
+        memcpy(temp->varBuffer, temp->var, size); //now fill the buffer for the first time
+      }
+      else
+      {
+        temp->varBuffer=new std::string( *static_cast<std::string*>(var) );
+      }
+      temp->varReference = 0;
+    }
+    COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl;
+    //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl;
+    COUT(5) << "Syncronisable::objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl;
+    syncList->push_back(temp);
+#ifndef NDEBUG
+    std::list<synchronisableVariable *>::iterator it = syncList->begin();
+    while(it!=syncList->end()){
+      assert(*it!=var);
+      it++;
+    }
+#endif
+  }*/
+  
+
+  /**
+   * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID and classID to the given memory
+   * takes a pointer to already allocated memory (must have at least getSize bytes length)
+   * structure of the bitstream:
+   * |totalsize,objectID,classID,var1,var2,string1_length,string1,var3,...|
+   * length of varx: size saved int syncvarlist
+   * @param mem pointer to allocated memory with enough size
+   * @param id gamestateid of the gamestate to be saved (important for priorities)
+   * @param mode defines the direction in which the data will be send/received
+   *             0x1: server->client
+   *             0x2: client->server (not recommended)
+   *             0x3: bidirectional
+   * @return true: if !doSync or if everything was successfully saved
+   */
+  bool Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
+    if(mode==0x0)
+      mode=state_;
+    //if this tick is we dont synchronise, then abort now
+    if(!doSync(id, mode))
+      return true;
+    //std::cout << "inside getData" << std::endl;
+    uint32_t tempsize = 0;
+    if (this->classID==0)
+      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
+
+    if (this->classID == static_cast<uint32_t>(-1))
+        this->classID = this->getIdentifier()->getNetworkID();
+
+    assert(this->classID==this->getIdentifier()->getNetworkID());
+//     this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
+    std::list<SynchronisableVariableBase*>::iterator i;
+    uint32_t size;
+    size=getSize(id, mode);
+
+    // 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);
+    // end copy header
+
+
+    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
+    // copy to location
+    for(i=syncList.begin(); i!=syncList.end(); ++i){
+      (*i)->getData( mem, mode );
+      tempsize += (*i)->getSize( mode );
+    }
+    assert(tempsize==size);
+    return true;
+  }
+
+
+  /**
+   * This function takes a bytestream and loads the data into the registered variables
+   * @param mem pointer to the bytestream
+   * @param mode same as in getData
+   * @return true/false
+   */
+  bool Synchronisable::updateData(uint8_t*& mem, uint8_t mode, bool forceCallback){
+    if(mode==0x0)
+      mode=state_;
+    std::list<SynchronisableVariableBase *>::iterator i;
+    //assert(objectMode_!=0x0);
+    //assert( (mode ^ objectMode_) != 0);
+    if(syncList.empty()){
+      COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
+      return false;
+    }
+
+    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;
+      return true;
+    }
+
+    mem += sizeof(synchronisableHeader);
+    // 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++)
+    {
+      (*i)->putData( mem, mode, forceCallback );
+    }
+    assert(mem == data+syncHeader->size);
+    return true;
+  }
+
+  /**
+  * This function returns the total amount of bytes needed by getData to save the whole content of the variables
+  * @param id id of the gamestate
+  * @param mode same as getData
+  * @return amount of bytes
+  */
+  uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){
+    int tsize=sizeof(synchronisableHeader);
+    if(mode==0x0)
+      mode=state_;
+    if(!doSync(id, mode))
+      return 0;
+    std::list<SynchronisableVariableBase*>::iterator i;
+    for(i=syncList.begin(); i!=syncList.end(); i++){
+      tsize += (*i)->getSize( mode );
+    }
+    return tsize;
+  }
+
+  /**
+   * This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction)
+   * @param id gamestate id
+   * @return true/false
+   */
+  bool Synchronisable::doSync(int32_t id, uint8_t mode){
+    if(mode==0x0)
+      mode=state_;
+    return ( (objectMode_&mode)!=0 && (!syncList.empty() ) );
+  }
+
+  bool Synchronisable::doSelection(int32_t id){
+    return true; //TODO: change this
+    //return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0);
+  }
+
+  /**
+   * This function looks at the header located in the bytestream and checks wheter objectID and classID match with the Synchronisables ones
+   * @param mem pointer to the bytestream
+   */
+  bool Synchronisable::isMyData(uint8_t* mem)
+  {
+    synchronisableHeader *header = (synchronisableHeader *)mem;
+    assert(header->objectID==this->objectID);
+    return header->dataAvailable;
+  }
+
+  /**
+   * This function sets the synchronisation mode of the object
+   * If set to 0x0 variables will not be synchronised at all
+   * If set to 0x1 variables will only be synchronised to the client
+   * If set to 0x2 variables will only be synchronised to the server
+   * If set to 0x3 variables will be synchronised bidirectionally (only if set so in registerVar)
+   * @param mode same as in registerVar
+   */
+  void Synchronisable::setObjectMode(uint8_t mode){
+    assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3);
+    objectMode_=mode;
+  }
+  
+
+}
Index: code/branches/bugger/src/network/synchronisable/Synchronisable.h
===================================================================
--- code/branches/bugger/src/network/synchronisable/Synchronisable.h	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/Synchronisable.h	(revision 2531)
@@ -0,0 +1,167 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Synchronisable_H__
+#define _Synchronisable_H__
+
+#include "network/NetworkPrereqs.h"
+
+#include <list>
+#include <map>
+#include <queue>
+#include <cassert>
+#include "util/Math.h"
+#include "util/mbool.h"
+#include "core/OrxonoxClass.h"
+// TODO: this has to be removed
+// #include <OgreLight.h>
+// #include "OrxonoxPrereqs.h"
+// ============================
+#include "NetworkCallback.h"
+#include "SynchronisableVariable.h"
+
+/*#define REGISTERDATA(varname, ...) \
+    registerVariable((void*)&varname, sizeof(varname), DATA, __VA_ARGS__)
+#define REGISTERSTRING(stringname, ...) \
+    registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)*/
+
+namespace orxonox
+{
+
+  namespace objectDirection{
+    enum objectdirection{
+      toclient=0x1,
+      toserver=0x2,
+      bidirectional=0x3
+    };
+  }
+
+  struct _NetworkExport synchronisableHeader{
+    uint32_t size:31;
+    bool dataAvailable:1;
+    uint32_t objectID;
+    uint32_t creatorID;
+    uint32_t classID;
+  };
+
+
+  /**
+  * 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.
+  * @author Oliver Scheuss
+  */
+  class _NetworkExport Synchronisable : virtual public OrxonoxClass{
+  public:
+    friend class packet::Gamestate;
+//     friend class Server;
+    virtual ~Synchronisable();
+
+    static void setClient(bool b);
+
+    static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0);
+    static bool deleteObject(uint32_t objectID);
+    static Synchronisable *getSynchronisable(uint32_t objectID);
+    static unsigned int getNumberOfDeletedObject(){ return deletedObjects_.size(); }
+    static uint32_t popDeletedObject(){ uint32_t i = deletedObjects_.front(); deletedObjects_.pop(); return i; }
+
+    inline uint32_t getObjectID() const {return objectID;}
+    inline unsigned int getCreatorID() const {return creatorID;}
+    inline uint32_t getClassID() const {return classID;}
+    inline unsigned int getPriority() const { return objectFrequency_;}
+
+  protected:
+    Synchronisable(BaseObject* creator);
+//     void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
+    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
+    template <class T> void unregisterVariable(T& var);
+    void setObjectMode(uint8_t mode);
+    void setObjectPriority(unsigned int freq){ objectFrequency_ = freq; }
+
+
+  private:
+    bool getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
+    uint32_t getSize(int32_t id, uint8_t mode=0x0);
+    bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false);
+    bool isMyData(uint8_t* mem);
+    bool doSelection(int32_t id);
+    bool doSync(int32_t id, uint8_t mode=0x0);
+
+    uint32_t objectID;
+    uint32_t creatorID;
+    uint32_t classID;
+
+    std::list<SynchronisableVariableBase*> syncList;
+    static uint8_t state_; // detemines wheter we are server (default) or client
+    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
+    unsigned int objectFrequency_;
+    int objectMode_;
+    static std::map<uint32_t, Synchronisable *> objectMap_;
+    static std::queue<uint32_t> deletedObjects_;
+  };
+  
+  template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+  {
+    if (bidirectional)
+      syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
+    else
+      syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
+  }
+
+  template <class T> void Synchronisable::unregisterVariable(T& var){
+    std::list<SynchronisableVariableBase*>::iterator it = syncList.begin();
+    while(it!=syncList.end()){
+      if( ((*it)->getReference()) == &var ){
+        delete (*it);
+        syncList.erase(it);
+        return;
+      }
+      else
+        it++;
+    }
+    bool unregistered_nonexistent_variable = false;
+    assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
+    // the variable has not been registered before
+  }
+  
+  // ================= Specialisation declarations
+  template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+  template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+//   template <> _NetworkExport void Synchronisable::registerVariable( LODParticle::LOD& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+//   template <> _NetworkExport void Synchronisable::registerVariable( Ogre::Light::LightTypes& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
+}
+
+#endif /* _Synchronisable_H__ */
Index: code/branches/bugger/src/network/synchronisable/SynchronisableSpecialisations.cc
===================================================================
--- code/branches/bugger/src/network/synchronisable/SynchronisableSpecialisations.cc	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/SynchronisableSpecialisations.cc	(revision 2531)
@@ -0,0 +1,101 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Dumeni Manatschal, (C) 2007
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "network/synchronisable/Synchronisable.h"
+
+// ================ template spezialisation
+  
+  
+namespace orxonox{
+  
+  template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable(variable.r, mode, cb, bidirectional);
+    registerVariable(variable.g, mode, cb, bidirectional);
+    registerVariable(variable.b, mode, cb, bidirectional);
+    registerVariable(variable.a, mode, cb, bidirectional);
+  }
+  template <> void Synchronisable::registerVariable( ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    return Synchronisable::registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
+  }
+
+  template <> void Synchronisable::registerVariable( const Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable(variable.x, mode, cb, bidirectional);
+    registerVariable(variable.y, mode, cb, bidirectional);
+  }
+  template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
+  }
+  
+  template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable(variable.x, mode, cb, bidirectional);
+    registerVariable(variable.y, mode, cb, bidirectional);
+    registerVariable(variable.z, mode, cb, bidirectional);
+  }
+  template <> void Synchronisable::registerVariable( Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable( (const Vector3&)variable, mode, cb, bidirectional);
+  }
+
+  template <> void Synchronisable::registerVariable( const Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable(variable.x, mode, cb, bidirectional);
+    registerVariable(variable.y, mode, cb, bidirectional);
+    registerVariable(variable.z, mode, cb, bidirectional);
+    registerVariable(variable.w, mode, cb, bidirectional);
+  }
+  template <> void Synchronisable::registerVariable( Vector4& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable( (const Vector4&)variable, mode, cb, bidirectional);
+  }
+  
+  template <> void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable(variable.getMemory(), mode, cb, bidirectional);
+  }
+  
+  template <> void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable(variable.x, mode, cb, bidirectional);
+    registerVariable(variable.y, mode, cb, bidirectional);
+    registerVariable(variable.z, mode, cb, bidirectional);
+    registerVariable(variable.w, mode, cb, bidirectional);
+  }
+  template <> void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
+  {
+    registerVariable( (const Quaternion&)variable, mode, cb, bidirectional);
+  }
+
+  
+
+} //namespace
Index: code/branches/bugger/src/network/synchronisable/SynchronisableVariable.cc
===================================================================
--- code/branches/bugger/src/network/synchronisable/SynchronisableVariable.cc	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/SynchronisableVariable.cc	(revision 2531)
@@ -0,0 +1,433 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "SynchronisableVariable.h"
+#include <cstring>
+#include "util/Math.h"
+
+
+namespace orxonox{
+
+uint8_t SynchronisableVariableBase::state_ = 0;
+
+
+
+// =================== Template specialisation stuff =============
+
+// =========== bool
+
+template <> uint32_t SynchronisableVariable<const bool>::returnSize()
+{
+  return sizeof(uint8_t);
+}
+
+template <> void SynchronisableVariable<const bool>::setAndIncrease( uint8_t*& mem )
+{
+  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
+  mem += SynchronisableVariable<const bool>::returnSize();
+}
+
+template <> void SynchronisableVariable<const bool>::getAndIncrease( uint8_t*& mem )
+{
+  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
+  mem += SynchronisableVariable<const bool>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const bool>::checkEquality( uint8_t* mem )
+{
+  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
+}
+
+// =========== char
+
+template <> uint32_t SynchronisableVariable<const char>::returnSize()
+{
+  return sizeof(uint8_t);
+}
+
+template <> void SynchronisableVariable<const char>::setAndIncrease( uint8_t*& mem )
+{
+  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
+  mem += SynchronisableVariable<const char>::returnSize();
+}
+
+template <> void SynchronisableVariable<const char>::getAndIncrease( uint8_t*& mem )
+{
+  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
+  mem += SynchronisableVariable<const char>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const char>::checkEquality( uint8_t* mem )
+{
+  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
+}
+
+// =========== unsigned char
+
+template <> uint32_t SynchronisableVariable<const unsigned char>::returnSize()
+{
+  return sizeof(uint8_t);
+}
+
+template <> void SynchronisableVariable<const unsigned char>::setAndIncrease( uint8_t*& mem )
+{
+  *(uint8_t*)(&this->variable_) = *static_cast<uint8_t*>(mem);
+  mem += SynchronisableVariable<const unsigned char>::returnSize();
+}
+
+template <> void SynchronisableVariable<const unsigned char>::getAndIncrease( uint8_t*& mem )
+{
+  *static_cast<uint8_t*>(mem) = *(uint8_t*)(&this->variable_);
+  mem += SynchronisableVariable<const unsigned char>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const unsigned char>::checkEquality( uint8_t* mem )
+{
+  return *static_cast<uint8_t*>(mem) == *(uint8_t*)(&this->variable_);
+}
+
+// =========== short
+
+template <> uint32_t SynchronisableVariable<const short>::returnSize()
+{
+  return sizeof(int16_t);
+}
+
+template <> void SynchronisableVariable<const short>::setAndIncrease( uint8_t*& mem )
+{
+  *(short*)(&this->variable_) = *(int16_t*)(mem);
+  mem += SynchronisableVariable<const short>::returnSize();
+}
+
+template <> void SynchronisableVariable<const short>::getAndIncrease( uint8_t*& mem )
+{
+  *(int16_t*)(mem) = this->variable_;
+  mem += SynchronisableVariable<const short>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const short>::checkEquality( uint8_t* mem )
+{
+  return *(int16_t*)(mem) == static_cast<int16_t>(this->variable_);
+}
+
+// =========== unsigned short
+
+template <> uint32_t SynchronisableVariable<const unsigned short>::returnSize()
+{
+  return sizeof(uint16_t);
+}
+
+template <> void SynchronisableVariable<const unsigned short>::setAndIncrease( uint8_t*& mem )
+{
+  *(unsigned short*)(&this->variable_) = *(uint16_t*)(mem);
+  mem += SynchronisableVariable<const unsigned short>::returnSize();
+}
+
+template <> void SynchronisableVariable<const unsigned short>::getAndIncrease( uint8_t*& mem )
+{
+  *(uint16_t*)(mem) = this->variable_;
+  mem += SynchronisableVariable<const unsigned short>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const unsigned short>::checkEquality( uint8_t* mem )
+{
+  return *(uint16_t*)(mem) == this->variable_;
+}
+
+// =========== int
+
+template <> uint32_t SynchronisableVariable<const int>::returnSize()
+{
+  return sizeof(int32_t);
+}
+
+template <> void SynchronisableVariable<const int>::setAndIncrease( uint8_t*& mem )
+{
+  *(int *)(&this->variable_) = *(int32_t*)(mem);
+  mem += SynchronisableVariable<const int>::returnSize();
+}
+
+template <> void SynchronisableVariable<const int>::getAndIncrease( uint8_t*& mem )
+{
+  *(int32_t*)(mem) = this->variable_;
+  mem += SynchronisableVariable<const int>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const int>::checkEquality( uint8_t* mem )
+{
+  return *(int32_t*)(mem) == this->variable_;
+}
+
+// =========== unsigned int
+
+template <> uint32_t SynchronisableVariable<const unsigned int>::returnSize()
+{
+  return sizeof(uint32_t);
+}
+    
+template <> void SynchronisableVariable<const unsigned int>::setAndIncrease( uint8_t*& mem )
+{
+  *(unsigned int*)(&this->variable_) = *(uint32_t*)(mem);
+  mem += SynchronisableVariable<const unsigned int>::returnSize();
+}
+
+template <> void SynchronisableVariable<const unsigned int>::getAndIncrease( uint8_t*& mem )
+{
+  *(uint32_t*)(mem) = this->variable_;
+  mem += SynchronisableVariable<const unsigned int>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const unsigned int>::checkEquality( uint8_t* mem )
+{
+  return *(uint32_t*)(mem) == this->variable_;
+}
+
+// =========== long
+
+template <> uint32_t SynchronisableVariable<const long>::returnSize()
+{
+  return sizeof(int32_t);
+}
+
+template <> void SynchronisableVariable<const long>::setAndIncrease( uint8_t*& mem )
+{
+  *(long*)(&this->variable_) = *(int32_t*)(mem);
+  mem += SynchronisableVariable<const long>::returnSize();
+}
+
+template <> void SynchronisableVariable<const long>::getAndIncrease( uint8_t*& mem )
+{
+  *(int32_t*)(mem) = this->variable_;
+  mem += SynchronisableVariable<const long>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const long>::checkEquality( uint8_t* mem )
+{
+  return *(int32_t*)(mem) == this->variable_;
+}
+
+// =========== unsigned long
+
+template <> uint32_t SynchronisableVariable<const unsigned long>::returnSize()
+{
+  return sizeof(uint32_t);
+}
+
+template <> void SynchronisableVariable<const unsigned long>::setAndIncrease( uint8_t*& mem )
+{
+  *(unsigned long*)(&this->variable_) = *(uint32_t*)(mem);
+  mem += SynchronisableVariable<const unsigned long>::returnSize();
+}
+
+template <> void SynchronisableVariable<const unsigned long>::getAndIncrease( uint8_t*& mem )
+{
+  *(uint32_t*)(mem) = this->variable_;
+  mem += SynchronisableVariable<const unsigned long>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const unsigned long>::checkEquality( uint8_t* mem )
+{
+  return *(uint32_t*)(mem) == this->variable_;
+}
+
+// =========== long long
+
+template <> uint32_t SynchronisableVariable<const long long>::returnSize()
+{
+  return sizeof(int64_t);
+}
+
+template <> void SynchronisableVariable<const long long>::setAndIncrease( uint8_t*& mem )
+{
+  *(long long*)(&this->variable_) = *(int64_t*)(mem);
+  mem += SynchronisableVariable<const long long>::returnSize();
+}
+
+template <> void SynchronisableVariable<const long long>::getAndIncrease( uint8_t*& mem )
+{
+  *(int64_t*)(mem) = this->variable_;
+  mem += SynchronisableVariable<const long long>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const long long>::checkEquality( uint8_t* mem )
+{
+  return *(int64_t*)(mem) == this->variable_;
+}
+
+// =========== unsigned long long
+
+template <> uint32_t SynchronisableVariable<const unsigned long long>::returnSize()
+{
+  return sizeof(uint64_t);
+}
+
+template <> void SynchronisableVariable<const unsigned long long>::setAndIncrease( uint8_t*& mem )
+{
+  *(unsigned long long*)(&this->variable_) = *(uint64_t*)(mem);
+  mem += SynchronisableVariable<const unsigned long long>::returnSize();
+}
+
+template <> void SynchronisableVariable<const unsigned long long>::getAndIncrease( uint8_t*& mem )
+{
+  *(uint64_t*)(mem) = this->variable_;
+  mem += SynchronisableVariable<const unsigned long long>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const unsigned long long>::checkEquality( uint8_t* mem )
+{
+  return *(uint64_t*)(mem) == this->variable_;
+}
+
+// =========== float
+
+template <> uint32_t SynchronisableVariable<const float>::returnSize()
+{
+  return sizeof(uint32_t);
+}
+
+template <> void SynchronisableVariable<const float>::setAndIncrease( uint8_t*& mem )
+{
+  *(uint32_t*)(&this->variable_) = *(uint32_t*)(mem);
+  mem += SynchronisableVariable<const float>::returnSize();
+}
+
+template <> void SynchronisableVariable<const float>::getAndIncrease( uint8_t*& mem )
+{
+  *(uint32_t*)(mem) = *(uint32_t*)(&this->variable_);
+  mem += SynchronisableVariable<const float>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const float>::checkEquality( uint8_t* mem )
+{
+  return *(uint32_t*)(mem) == *(uint32_t*)(&this->variable_);
+}
+
+// =========== double
+
+template <> uint32_t SynchronisableVariable<const double>::returnSize()
+{
+  return sizeof(uint64_t);
+}
+
+template <> void SynchronisableVariable<const double>::setAndIncrease( uint8_t*& mem )
+{
+  *(uint64_t*)(&this->variable_) = *(uint64_t*)(mem);
+  mem += SynchronisableVariable<const double>::returnSize();
+}
+
+template <> void SynchronisableVariable<const double>::getAndIncrease( uint8_t*& mem )
+{
+  *(uint64_t*)(mem) = *(uint64_t*)(&this->variable_);
+  mem += SynchronisableVariable<const double>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const double>::checkEquality( uint8_t* mem )
+{
+  return *(uint64_t*)(mem) == *(uint64_t*)(&this->variable_);
+}
+
+// =========== long double
+
+template <> uint32_t SynchronisableVariable<const long double>::returnSize()
+{
+  return sizeof(uint64_t);
+}
+
+template <> void SynchronisableVariable<const long double>::setAndIncrease( uint8_t*& mem )
+{
+  double temp;
+  *(uint64_t*)(&temp) = *(uint64_t*)(mem);
+  *(long double*)(&this->variable_) = static_cast<const long double>(temp);
+  mem += SynchronisableVariable<const long double>::returnSize();
+}
+
+template <> void SynchronisableVariable<const long double>::getAndIncrease( uint8_t*& mem )
+{
+  double temp = static_cast<double>(this->variable_);
+  *(uint64_t*)(mem) = *(uint64_t*)(&temp);
+  mem += SynchronisableVariable<const long double>::returnSize();
+}
+
+template <> bool SynchronisableVariable<const long double>::checkEquality( uint8_t* mem )
+{
+  double temp = static_cast<double>(this->variable_);
+  return *(uint64_t*)(mem) == *(uint64_t*)(&temp);
+}
+
+// =========== string
+
+template <> uint32_t SynchronisableVariable<const std::string>::returnSize()
+{
+  return variable_.length()+1;
+}
+
+template <> void SynchronisableVariable<const std::string>::getAndIncrease( uint8_t*& mem )
+{
+  memcpy(mem, this->variable_.c_str(), this->variable_.length()+1);
+  mem += this->variable_.length()+1;
+}
+
+template <> void SynchronisableVariable<const std::string>::setAndIncrease( uint8_t*& mem )
+{
+  *(std::string*)(&this->variable_) = std::string((const char *)mem);
+  mem += this->variable_.length()+1;
+}
+
+template <> bool SynchronisableVariable<const std::string>::checkEquality( uint8_t* mem )
+{
+  return std::string((const char*)mem)==this->variable_;
+}
+
+// =========== Degree
+
+template <> uint32_t SynchronisableVariable<const Degree>::returnSize()
+{
+  return sizeof(Ogre::Real);
+}
+
+template <> void SynchronisableVariable<const Degree>::getAndIncrease( uint8_t*& mem )
+{
+  Ogre::Real r = this->variable_.valueDegrees();
+  memcpy(mem, &r, returnSize());
+  mem += returnSize();
+}
+
+template <> void SynchronisableVariable<const Degree>::setAndIncrease( uint8_t*& mem )
+{
+  Ogre::Real* r = (Ogre::Real*)mem;
+  (Degree&)this->variable_ = *r;
+  mem += returnSize();
+}
+
+template <> bool SynchronisableVariable<const Degree>::checkEquality( uint8_t* mem )
+{
+  Ogre::Real* r = (Ogre::Real*)mem;
+  return this->variable_==Degree(*r);
+}
+
+}
Index: code/branches/bugger/src/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/branches/bugger/src/network/synchronisable/SynchronisableVariable.h	(revision 2531)
+++ code/branches/bugger/src/network/synchronisable/SynchronisableVariable.h	(revision 2531)
@@ -0,0 +1,316 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#ifndef _NETWORK_SYNCHRONISABLEVARIABLE__
+#define _NETWORK_SYNCHRONISABLEVARIABLE__
+
+#include "network/NetworkPrereqs.h"
+
+#include <string>
+#include <cassert>
+#include "util/Integers.h"
+#include "core/Core.h"
+#include "core/CoreIncludes.h"
+#include "network/synchronisable/NetworkCallback.h"
+#include "network/synchronisable/NetworkCallbackManager.h"
+
+namespace orxonox{
+  
+  namespace variableDirection{
+    enum syncdirection{
+      toclient=0x1,
+      toserver=0x2
+    };
+    enum bidirectional{
+      serverMaster=0x1,
+      clientMaster=0x2
+    };
+  }
+  
+  class _NetworkExport SynchronisableVariableBase
+  {
+    public:
+      virtual void getData(uint8_t*& mem, uint8_t mode)=0;
+      virtual void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false)=0;
+      virtual uint32_t getSize(uint8_t mode)=0;
+      virtual void* getReference()=0;
+      virtual uint8_t getMode()=0;
+      virtual ~SynchronisableVariableBase() {}
+    protected:
+      static uint8_t state_;
+  };
+
+  template <class T>
+  class SynchronisableVariable: public SynchronisableVariableBase
+  {
+    public:
+      SynchronisableVariable(T& variable, uint8_t syncDirection=variableDirection::toclient, NetworkCallbackBase *cb=0);
+      virtual ~SynchronisableVariable();
+
+      virtual inline uint8_t getMode(){ return mode_; }
+      virtual void getData(uint8_t*& mem, uint8_t mode);
+      virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
+      virtual uint32_t getSize(uint8_t mode);
+      virtual inline void* getReference(){ return (void *)&this->variable_; }
+    protected:
+      bool checkEquality(uint8_t* mem);
+      void setAndIncrease(uint8_t*& mem);
+      void getAndIncrease(uint8_t*& mem);
+      uint32_t returnSize();
+      
+      T& variable_;
+      uint8_t mode_;
+      NetworkCallbackBase *callback_;
+  };
+  
+  template <class T>
+  class SynchronisableVariableBidirectional: public SynchronisableVariable<T>
+  {
+    public:
+      SynchronisableVariableBidirectional(T& variable, uint8_t master=variableDirection::serverMaster, NetworkCallbackBase *cb=0);
+      virtual ~SynchronisableVariableBidirectional();
+      
+      virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
+      virtual void getData(uint8_t*& mem, uint8_t mode);
+      virtual void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
+      virtual uint32_t getSize(uint8_t mode);
+    private:
+      T varBuffer_;
+      uint8_t varReference_;
+  };
+
+  // ================= Unidirectional Part ===============
+
+  template <class T> SynchronisableVariable<T>::SynchronisableVariable(T& variable, uint8_t syncDirection, NetworkCallbackBase *cb):
+      variable_( variable ), mode_( syncDirection ), callback_( cb )
+  {
+    if ( state_ == 0x0 )
+    {
+      state_ = Core::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
+    }
+  }
+  
+  template <class T> SynchronisableVariable<T>::~SynchronisableVariable()
+  {
+    if (this->callback_ != 0)
+      NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
+  }
+
+  template <class T> void SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
+  {
+    if ( state_ == this->mode_ )
+      getAndIncrease( mem );
+//   mem += SynchronisableVariable<T>::getSize();
+  }
+
+  template <class T> void SynchronisableVariable<T>::putData(uint8_t*& mem, uint8_t mode, bool forceCallback)
+  {
+    assert ( mode == 0x1 || mode == 0x2 );
+    bool callback = false;
+    if ( mode == this->mode_ ) //don't do anything
+      return;
+  // check whether we need to consider a callback
+    if ( this->callback_ != 0 )
+    {
+      if( forceCallback || !checkEquality( mem ) )
+        callback = true;
+    }
+  // write the data
+    setAndIncrease( mem );
+//   mem += SynchronisableVariable<T>::getSize();
+  // now do a callback if neccessary
+    if ( callback )
+      NetworkCallbackManager::triggerCallback( this->callback_ );
+      //this->callback_->call();
+  }
+
+  template <class T> uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
+  {
+    if ( mode == this->mode_ )
+      return returnSize();
+    else
+      return 0;
+  }
+
+  template <> _NetworkExport uint32_t SynchronisableVariable<const bool>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const bool>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const bool>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const bool>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned char>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const unsigned char>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const short>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const short>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const short>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const short>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned short>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const unsigned short>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const int>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const int>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const int>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const int>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned int>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const unsigned int>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const long>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const long>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const long>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const long>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned long>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const unsigned long>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const long long>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const long long>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const long long>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const long long>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned long long>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const unsigned long long>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const float>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const float>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const float>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const float>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const double>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const double>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const double>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const double>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const long double>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const long double>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const long double>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const long double>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const std::string>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const std::string>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const std::string>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const std::string>::checkEquality(uint8_t* mem);
+  template <> _NetworkExport uint32_t SynchronisableVariable<const Degree>::returnSize();
+  template <> _NetworkExport void     SynchronisableVariable<const Degree>::setAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport void     SynchronisableVariable<const Degree>::getAndIncrease(uint8_t*& mem);
+  template <> _NetworkExport bool     SynchronisableVariable<const Degree>::checkEquality(uint8_t* mem);
+
+
+
+// ================= Bidirectional Part ================
+
+    template <class T> SynchronisableVariableBidirectional<T>::SynchronisableVariableBidirectional(T& variable, uint8_t master, NetworkCallbackBase *cb):
+    SynchronisableVariable<T>( variable, master, cb ), varBuffer_( variable ), varReference_( 0 )
+    {
+    }
+
+    template <class T> SynchronisableVariableBidirectional<T>::~SynchronisableVariableBidirectional()
+    {
+    }
+
+    template <class T> void SynchronisableVariableBidirectional<T>::getData(uint8_t*& mem, uint8_t mode)
+    {
+      if ( this->mode_ == mode )
+      {   // we are master for this variable and have to check whether to change the varReference
+        if( this->varBuffer_ != this->variable_ )
+        {
+          this->varReference_++;
+          memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(this->variable_));
+        }
+      }
+  // write the reference number to the stream
+      *static_cast<uint8_t*>(mem) = varReference_;
+      mem += sizeof(this->varReference_);
+  // now write the content
+      SynchronisableVariable<T>::getAndIncrease( mem );
+//   mem += SynchronisableVariable<T>::getSize();
+    }
+
+    template <class T> void SynchronisableVariableBidirectional<T>::putData(uint8_t*& mem, uint8_t mode, bool forceCallback)
+    {
+      bool callback = false;
+      if ( this->mode_ == mode )
+      {   //        MASTER
+        // check that the client (source of the data) has a recent version of this variable
+        if ( *static_cast<uint8_t*>(mem) != this->varReference_ )
+        { // wrong reference number, so discard the data
+          mem += getSize( mode ); // SynchronisableVariableBidirectional::getSize returns size of variable + reference
+          return;
+        }
+        else{
+          // apply data
+          mem += sizeof(varReference_);
+          if ( SynchronisableVariableBidirectional<T>::checkEquality( mem )==true )
+          {
+            mem += SynchronisableVariable<T>::getSize( mode );
+            return;
+          }
+          else
+          {
+            memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(T));
+            if ( this->callback_ != 0 )
+              callback = true;
+          }
+        }
+      }
+      else
+      {   // we are slave for this variable
+        if (*static_cast<uint8_t*>(mem) == this->varReference_ && !forceCallback)
+        {
+          mem += getSize( mode ); //just skip the variable because nothing changed
+          return;
+        }
+        else
+        {
+          this->varReference_ = *static_cast<uint8_t*>(mem);
+          mem += sizeof(varReference_);
+          if ( SynchronisableVariable<T>::checkEquality( mem ) == false )
+          {
+            // value changed so remark for callback
+            if ( this->callback_ != 0 )
+              callback = true;
+          }
+        }
+      }
+  // now write the data
+      SynchronisableVariable<T>::setAndIncrease(mem);
+  // now do a callback if neccessary
+      if ( callback )
+        NetworkCallbackManager::triggerCallback( this->callback_ );
+        //this->callback_->call();
+    }
+
+    template <class T> uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
+    {
+      return SynchronisableVariable<T>::returnSize() + sizeof(varReference_);
+    }
+  
+
+}
+
+
+#endif
Index: code/branches/bugger/src/orxonox/OrxonoxStableHeaders.h
===================================================================
--- code/branches/bugger/src/orxonox/OrxonoxStableHeaders.h	(revision 2530)
+++ code/branches/bugger/src/orxonox/OrxonoxStableHeaders.h	(revision 2531)
@@ -95,5 +95,5 @@
 #include "core/input/InputManager.h"
 
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 
 #include "Settings.h"
Index: code/branches/bugger/src/orxonox/objects/GlobalShader.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/GlobalShader.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/GlobalShader.cc	(revision 2531)
@@ -66,6 +66,6 @@
     void GlobalShader::registerVariables()
     {
-        REGISTERDATA  (this->bVisible_, direction::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
-        REGISTERSTRING(const_cast<std::string&>(this->shader_.getCompositor()), direction::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
+        registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
+        registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), variableDirection::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
     }
 
Index: code/branches/bugger/src/orxonox/objects/GlobalShader.h
===================================================================
--- code/branches/bugger/src/orxonox/objects/GlobalShader.h	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/GlobalShader.h	(revision 2531)
@@ -33,5 +33,5 @@
 
 #include "core/BaseObject.h"
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 #include "tools/Shader.h"
 
Index: code/branches/bugger/src/orxonox/objects/Level.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/Level.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/Level.cc	(revision 2531)
@@ -83,7 +83,7 @@
     void Level::registerVariables()
     {
-        REGISTERSTRING(this->xmlfilename_, direction::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
-        REGISTERSTRING(this->name_,        direction::toclient, new NetworkCallback<Level>(this, &Level::changedName));
-        REGISTERSTRING(this->description_, direction::toclient);
+        registerVariable(this->xmlfilename_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
+        registerVariable(this->name_,        variableDirection::toclient, new NetworkCallback<Level>(this, &Level::changedName));
+        registerVariable(this->description_, variableDirection::toclient);
     }
 
Index: code/branches/bugger/src/orxonox/objects/Level.h
===================================================================
--- code/branches/bugger/src/orxonox/objects/Level.h	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/Level.h	(revision 2531)
@@ -32,5 +32,5 @@
 #include "OrxonoxPrereqs.h"
 
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 #include "core/BaseObject.h"
 
Index: code/branches/bugger/src/orxonox/objects/Scene.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/Scene.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/Scene.cc	(revision 2531)
@@ -101,7 +101,7 @@
     void Scene::registerVariables()
     {
-        REGISTERSTRING(this->skybox_,     direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
-        REGISTERDATA(this->ambientLight_, direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
-        REGISTERDATA(this->bShadows_,     direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
+        registerVariable(this->skybox_,     variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
+        registerVariable(this->ambientLight_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
+        registerVariable(this->bShadows_,     variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
     }
 
Index: code/branches/bugger/src/orxonox/objects/Scene.h
===================================================================
--- code/branches/bugger/src/orxonox/objects/Scene.h	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/Scene.h	(revision 2531)
@@ -32,5 +32,5 @@
 #include "OrxonoxPrereqs.h"
 
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 #include "core/BaseObject.h"
 #include "util/Math.h"
Index: code/branches/bugger/src/orxonox/objects/Test.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/Test.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/Test.cc	(revision 2531)
@@ -61,8 +61,13 @@
 	void Test::setConfigValues()
 	{
-		SetConfigValue ( v1, 1 )/*.callback ( this, &Test::checkV1 )*/;
-    SetConfigValue ( v2, 2 )/*.callback ( this, &Test::checkV2 )*/;
-    SetConfigValue ( v3, 3 )/*.callback ( this, &Test::checkV3 )*/;
-    SetConfigValue ( v4, 4 )/*.callback ( this, &Test::checkV4 )*/;
+		SetConfigValue ( u1, 1 )/*.callback ( this, &Test::checkV1 )*/;
+    SetConfigValue ( u2, 2 )/*.callback ( this, &Test::checkV2 )*/;
+    SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/;
+    SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/;
+    
+    SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/;
+    SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/;
+    SetConfigValue ( s3, 3 )/*.callback ( this, &Test::checkV3 )*/;
+    SetConfigValue ( s4, 4 )/*.callback ( this, &Test::checkV4 )*/;
 	}
 
@@ -70,26 +75,24 @@
 	void Test::registerVariables()
 	{
-		REGISTERDATA ( v1,direction::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ) );
-    REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) );
-		REGISTERDATA ( v3,direction::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ) );
-    REGISTERDATA ( v4,direction::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ) );
+		registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
+    registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
+		registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
+    registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
+    
+    registerVariable ( s1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkS1 ));
+    registerVariable ( s2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkS2 ));
+    registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
+    registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
 	}
 
-  void Test::checkV1(){
-    COUT(1) << "V1 changed: " << v1 << std::endl;
-  }
+  void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
+  void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
+  void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
+  void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; }
 
-  void Test::checkV2(){
-    COUT(1) << "V2 changed: " << v2 << std::endl;
-  }
-
-  void Test::checkV3(){
-    COUT(1) << "V3 changed: " << v3 << std::endl;
-  }
-  
-  void Test::checkV4(){
-    COUT(1) << "V4 changed: " << v4 << std::endl;
-  }
-
+  void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; }
+  void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; }
+  void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
+  void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
 
 }
Index: code/branches/bugger/src/orxonox/objects/Test.h
===================================================================
--- code/branches/bugger/src/orxonox/objects/Test.h	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/Test.h	(revision 2531)
@@ -32,5 +32,10 @@
 #include "OrxonoxPrereqs.h"
 #include "core/BaseObject.h"
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
+
+
+typedef int TYPE;
+typedef unsigned int UTYPE;
+
 
 namespace orxonox
@@ -45,24 +50,40 @@
       void registerVariables();
 
-      void setV1(unsigned int value){ v1 = value; }
-      void setV2(unsigned int value){ v2 = value; }
-      void setV3(unsigned int value){ v3 = value; }
-      void setV4(unsigned int value){ v4 = value; }
 
-      void checkV1();
-      void checkV2();
-      void checkV3();
-      void checkV4();
+      //unsigned functions
+      void setU1(UTYPE value){ u1 = value; }
+      void setU2(UTYPE value){ u2 = value; }
+      void setU3(UTYPE value){ u3 = value; }
+      void setU4(UTYPE value){ u4 = value; }
+      void checkU1();
+      void checkU2();
+      void checkU3();
+      void checkU4();
       
-      void printV1(){ instance_->checkV1(); }
-      void printV2(){ instance_->checkV2(); }
-      void printV3(){ instance_->checkV3(); }
-      void printV4(){ instance_->checkV4(); }
+      //signed functions
+      void setS1(TYPE value){ s1 = value; }
+      void setS2(TYPE value){ s2 = value; }
+      void setS3(TYPE value){ s3 = value; }
+      void setS4(TYPE value){ s4 = value; }
+      void checkS1();
+      void checkS2();
+      void checkS3();
+      void checkS4();
+      
+      static void printV1(){ instance_->checkU1(); }
+      static void printV2(){ instance_->checkU2(); }
+      static void printV3(){ instance_->checkU3(); }
+      static void printV4(){ instance_->checkU4(); }
 
     private:
-      unsigned int v1;
-      unsigned int v2;
-      unsigned int v3;
-      unsigned int v4;
+      UTYPE u1;
+      UTYPE u2;
+      UTYPE u3;
+      UTYPE u4;
+      
+      TYPE s1;
+      TYPE s2;
+      TYPE s3;
+      TYPE s4;
       
       static Test* instance_;
Index: code/branches/bugger/src/orxonox/objects/infos/GametypeInfo.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/infos/GametypeInfo.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/infos/GametypeInfo.cc	(revision 2531)
@@ -54,8 +54,8 @@
     void GametypeInfo::registerVariables()
     {
-        REGISTERDATA(this->bStarted_,               direction::toclient);
-        REGISTERDATA(this->bEnded_,                 direction::toclient);
-        REGISTERDATA(this->startCountdown_,         direction::toclient);
-        REGISTERDATA(this->bStartCountdownRunning_, direction::toclient);
+        registerVariable(this->bStarted_,               variableDirection::toclient);
+        registerVariable(this->bEnded_,                 variableDirection::toclient);
+        registerVariable(this->startCountdown_,         variableDirection::toclient);
+        registerVariable(this->bStartCountdownRunning_, variableDirection::toclient);
     }
 }
Index: code/branches/bugger/src/orxonox/objects/infos/HumanPlayer.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/infos/HumanPlayer.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/infos/HumanPlayer.cc	(revision 2531)
@@ -69,9 +69,9 @@
     void HumanPlayer::registerVariables()
     {
-        REGISTERSTRING(this->synchronize_nick_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
+        registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
 
-        REGISTERDATA(this->clientID_,           direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
-        REGISTERDATA(this->server_initialized_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
-        REGISTERDATA(this->client_initialized_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
+        registerVariable(this->clientID_,           variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
+        registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
+        registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
     }
 
@@ -106,5 +106,5 @@
 
             if (!Core::isMaster())
-                this->setObjectMode(direction::bidirectional);
+                this->setObjectMode(objectDirection::bidirectional);
             else
                 this->setName(this->nick_);
Index: code/branches/bugger/src/orxonox/objects/infos/Info.h
===================================================================
--- code/branches/bugger/src/orxonox/objects/infos/Info.h	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/infos/Info.h	(revision 2531)
@@ -32,5 +32,5 @@
 #include "OrxonoxPrereqs.h"
 
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 #include "core/BaseObject.h"
 
Index: code/branches/bugger/src/orxonox/objects/infos/PlayerInfo.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/infos/PlayerInfo.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/infos/PlayerInfo.cc	(revision 2531)
@@ -73,7 +73,7 @@
     void PlayerInfo::registerVariables()
     {
-        REGISTERSTRING(this->name_,                 direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
-        REGISTERDATA  (this->controllableEntityID_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
-        REGISTERDATA  (this->bReadyToSpawn_,        direction::toserver);
+        registerVariable(this->name_,                 variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
+        registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
+        registerVariable(this->bReadyToSpawn_,        variableDirection::toserver);
     }
 
Index: code/branches/bugger/src/orxonox/objects/items/Engine.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/items/Engine.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/items/Engine.cc	(revision 2531)
@@ -104,19 +104,19 @@
     void Engine::registerVariables()
     {
-        REGISTERDATA(this->shipID_, direction::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
-
-        REGISTERDATA(this->speedFactor_, direction::toclient);
-        REGISTERDATA(this->boostFactor_, direction::toclient);
-
-        REGISTERDATA(this->maxSpeedFront_,     direction::toclient);
-        REGISTERDATA(this->maxSpeedBack_,      direction::toclient);
-        REGISTERDATA(this->maxSpeedLeftRight_, direction::toclient);
-        REGISTERDATA(this->maxSpeedUpDown_,    direction::toclient);
-
-        REGISTERDATA(this->accelerationFront_,     direction::toclient);
-        REGISTERDATA(this->accelerationBrake_,     direction::toclient);
-        REGISTERDATA(this->accelerationBack_,      direction::toclient);
-        REGISTERDATA(this->accelerationLeftRight_, direction::toclient);
-        REGISTERDATA(this->accelerationUpDown_,    direction::toclient);
+        registerVariable(this->shipID_, variableDirection::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
+
+        registerVariable(this->speedFactor_, variableDirection::toclient);
+        registerVariable(this->boostFactor_, variableDirection::toclient);
+
+        registerVariable(this->maxSpeedFront_,     variableDirection::toclient);
+        registerVariable(this->maxSpeedBack_,      variableDirection::toclient);
+        registerVariable(this->maxSpeedLeftRight_, variableDirection::toclient);
+        registerVariable(this->maxSpeedUpDown_,    variableDirection::toclient);
+
+        registerVariable(this->accelerationFront_,     variableDirection::toclient);
+        registerVariable(this->accelerationBrake_,     variableDirection::toclient);
+        registerVariable(this->accelerationBack_,      variableDirection::toclient);
+        registerVariable(this->accelerationLeftRight_, variableDirection::toclient);
+        registerVariable(this->accelerationUpDown_,    variableDirection::toclient);
     }
 
Index: code/branches/bugger/src/orxonox/objects/items/Item.h
===================================================================
--- code/branches/bugger/src/orxonox/objects/items/Item.h	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/items/Item.h	(revision 2531)
@@ -33,5 +33,5 @@
 
 #include "core/BaseObject.h"
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 
 namespace orxonox
Index: code/branches/bugger/src/orxonox/objects/items/MultiStateEngine.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/items/MultiStateEngine.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/items/MultiStateEngine.cc	(revision 2531)
@@ -83,5 +83,5 @@
     void MultiStateEngine::registerVariables()
     {
-        REGISTERDATA(this->state_, direction::toserver);
+        registerVariable(this->state_, variableDirection::toserver);
     }
 
@@ -92,5 +92,5 @@
             if (this->getShip()->hasLocalController())
             {
-                this->setObjectMode(direction::bidirectional);
+                this->setObjectMode(objectDirection::bidirectional);
 
                 const Vector3& direction = this->getDirection();
Index: code/branches/bugger/src/orxonox/objects/worldentities/Backlight.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/Backlight.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/Backlight.cc	(revision 2531)
@@ -109,9 +109,9 @@
     void Backlight::registerVariables()
     {
-        REGISTERDATA  (this->width_,         direction::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_width));
-        REGISTERDATA  (this->lifetime_,      direction::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime));
-        REGISTERDATA  (this->length_,        direction::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_length));
-        REGISTERDATA  (this->maxelements_,   direction::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements));
-        REGISTERSTRING(this->trailmaterial_, direction::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial));
+        registerVariable  (this->width_,         variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_width));
+        registerVariable  (this->lifetime_,      variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime));
+        registerVariable  (this->length_,        variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_length));
+        registerVariable  (this->maxelements_,   variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements));
+        registerVariable  (this->trailmaterial_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/Billboard.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/Billboard.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/Billboard.cc	(revision 2531)
@@ -67,6 +67,6 @@
     void Billboard::registerVariables()
     {
-        REGISTERSTRING(this->material_, direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
-        REGISTERDATA  (this->colour_,   direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
+        registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
+        registerVariable(this->colour_,   variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2531)
@@ -238,5 +238,5 @@
             {
                 this->client_overwrite_ = this->server_overwrite_;
-                this->setObjectMode(direction::bidirectional);
+                this->setObjectMode(objectDirection::bidirectional);
             }
         }
@@ -252,5 +252,5 @@
         this->bHasLocalController_ = false;
         this->bHasHumanController_ = false;
-        this->setObjectMode(direction::toclient);
+        this->setObjectMode(objectDirection::toclient);
 
         if (this->bDestroyWhenPlayerLeft_)
@@ -345,21 +345,21 @@
     void ControllableEntity::registerVariables()
     {
-        REGISTERSTRING(this->cameraPositionTemplate_, direction::toclient);
-        REGISTERSTRING(this->hudtemplate_, direction::toclient);
-
-        REGISTERDATA(this->client_overwrite_,   direction::toserver);
-
-        REGISTERDATA(this->server_position_,    direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
-        REGISTERDATA(this->server_velocity_,    direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
-        REGISTERDATA(this->server_orientation_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
-        REGISTERDATA(this->server_overwrite_,   direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
-
-        REGISTERDATA(this->client_position_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
-        REGISTERDATA(this->client_velocity_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
-        REGISTERDATA(this->client_orientation_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
-
-
-        REGISTERDATA(this->playerID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
-        REGISTERDATA(this->gtinfoID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID));
+        registerVariable(this->cameraPositionTemplate_, variableDirection::toclient);
+        registerVariable(this->hudtemplate_, variableDirection::toclient);
+
+        registerVariable(this->client_overwrite_,   variableDirection::toserver);
+          
+        registerVariable(this->server_position_,    variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
+        registerVariable(this->server_velocity_,    variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
+        registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
+        registerVariable(this->server_overwrite_,   variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
+  
+        registerVariable(this->client_position_,    variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
+        registerVariable(this->client_velocity_,    variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
+        registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
+  
+  
+        registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
+        registerVariable(this->gtinfoID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/ExplosionChunk.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/ExplosionChunk.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/ExplosionChunk.cc	(revision 2531)
@@ -91,6 +91,6 @@
     void ExplosionChunk::registerVariables()
     {
-        REGISTERDATA(this->LOD_,   direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));
-        REGISTERDATA(this->bStop_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));
+        registerVariable((int&)this->LOD_,   variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));
+        registerVariable(this->bStop_, variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/FadingBillboard.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/FadingBillboard.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/FadingBillboard.cc	(revision 2531)
@@ -66,6 +66,6 @@
     void FadingBillboard::registerVariables()
     {
-        REGISTERDATA(this->turnontime_,         direction::toclient);
-        REGISTERDATA(this->turnofftime_,        direction::toclient);
+        registerVariable(this->turnontime_,         variableDirection::toclient);
+        registerVariable(this->turnofftime_,        variableDirection::toclient);
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/Light.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/Light.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/Light.cc	(revision 2531)
@@ -103,9 +103,9 @@
     void Light::registerVariables()
     {
-        REGISTERDATA(this->type_,           direction::toclient, new NetworkCallback<Light>(this, &Light::updateType));
-        REGISTERDATA(this->diffuse_,        direction::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
-        REGISTERDATA(this->specular_,       direction::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
-        REGISTERDATA(this->attenuation_,    direction::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
-        REGISTERDATA(this->spotlightRange_, direction::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
+        registerVariable((int &)this->type_,    variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateType));
+        registerVariable(this->diffuse_,        variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
+        registerVariable(this->specular_,       variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
+        registerVariable(this->attenuation_,    variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
+        registerVariable(this->spotlightRange_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/Model.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/Model.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/Model.cc	(revision 2531)
@@ -40,4 +40,5 @@
     Model::Model(BaseObject* creator) : PositionableEntity(creator)
     {
+        static unsigned int i=10;
         RegisterObject(Model);
 
@@ -45,4 +46,5 @@
 
         this->registerVariables();
+        this->setObjectPriority(i++);
     }
 
@@ -63,6 +65,6 @@
     void Model::registerVariables()
     {
-        REGISTERSTRING(this->meshSrc_,    direction::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));
-        REGISTERDATA(this->bCastShadows_, direction::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));
+        registerVariable(this->meshSrc_,    variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));
+        registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/MovableEntity.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/MovableEntity.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/MovableEntity.cc	(revision 2531)
@@ -85,16 +85,16 @@
     void MovableEntity::registerVariables()
     {
-        REGISTERDATA(this->velocity_.x, direction::toclient);
-        REGISTERDATA(this->velocity_.y, direction::toclient);
-        REGISTERDATA(this->velocity_.z, direction::toclient);
-
-        REGISTERDATA(this->rotationAxis_.x, direction::toclient);
-        REGISTERDATA(this->rotationAxis_.y, direction::toclient);
-        REGISTERDATA(this->rotationAxis_.z, direction::toclient);
-
-        REGISTERDATA(this->rotationRate_, direction::toclient);
-
-        REGISTERDATA(this->overwrite_position_,    direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
-        REGISTERDATA(this->overwrite_orientation_, direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
+        registerVariable(this->velocity_.x, variableDirection::toclient);
+        registerVariable(this->velocity_.y, variableDirection::toclient);
+        registerVariable(this->velocity_.z, variableDirection::toclient);
+  
+        registerVariable(this->rotationAxis_.x, variableDirection::toclient);
+        registerVariable(this->rotationAxis_.y, variableDirection::toclient);
+        registerVariable(this->rotationAxis_.z, variableDirection::toclient);
+  
+        registerVariable(this->rotationRate_, variableDirection::toclient);
+  
+        registerVariable(this->overwrite_position_,    variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
+        registerVariable(this->overwrite_orientation_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/ParticleEmitter.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/ParticleEmitter.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/ParticleEmitter.cc	(revision 2531)
@@ -75,6 +75,6 @@
     void ParticleEmitter::registerVariables()
     {
-        REGISTERSTRING(this->source_, direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
-        REGISTERDATA  (this->LOD_,    direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
+        registerVariable(this->source_, variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
+        registerVariable((int&)(this->LOD_),    variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/PositionableEntity.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/PositionableEntity.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/PositionableEntity.cc	(revision 2531)
@@ -48,12 +48,12 @@
     void PositionableEntity::registerVariables()
     {
-        REGISTERDATA(this->getPosition().x, direction::toclient);
-        REGISTERDATA(this->getPosition().y, direction::toclient);
-        REGISTERDATA(this->getPosition().z, direction::toclient);
+        registerVariable(this->getPosition().x, variableDirection::toclient);
+        registerVariable(this->getPosition().y, variableDirection::toclient);
+        registerVariable(this->getPosition().z, variableDirection::toclient);
 
-        REGISTERDATA(this->getOrientation().w, direction::toclient);
-        REGISTERDATA(this->getOrientation().x, direction::toclient);
-        REGISTERDATA(this->getOrientation().y, direction::toclient);
-        REGISTERDATA(this->getOrientation().z, direction::toclient);
+        registerVariable(this->getOrientation().w, variableDirection::toclient);
+        registerVariable(this->getOrientation().x, variableDirection::toclient);
+        registerVariable(this->getOrientation().y, variableDirection::toclient);
+        registerVariable(this->getOrientation().z, variableDirection::toclient);
     }
 }
Index: code/branches/bugger/src/orxonox/objects/worldentities/WorldEntity.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/WorldEntity.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/WorldEntity.cc	(revision 2531)
@@ -105,14 +105,14 @@
     void WorldEntity::registerVariables()
     {
-        REGISTERSTRING(this->mainStateName_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
+        registerVariable(this->mainStateName_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
 
-        REGISTERDATA(this->bActive_,  direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
-        REGISTERDATA(this->bVisible_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
-
-        REGISTERDATA(this->getScale3D().x, direction::toclient);
-        REGISTERDATA(this->getScale3D().y, direction::toclient);
-        REGISTERDATA(this->getScale3D().z, direction::toclient);
-
-        REGISTERDATA(this->parentID_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
+        registerVariable(this->bActive_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
+        registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
+  
+        registerVariable(this->getScale3D().x, variableDirection::toclient);
+        registerVariable(this->getScale3D().y, variableDirection::toclient);
+        registerVariable(this->getScale3D().z, variableDirection::toclient);
+  
+        registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/WorldEntity.h
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/WorldEntity.h	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/WorldEntity.h	(revision 2531)
@@ -36,5 +36,5 @@
 #include <OgreSceneNode.h>
 
-#include "network/Synchronisable.h"
+#include "network/synchronisable/Synchronisable.h"
 #include "core/BaseObject.h"
 #include "util/Math.h"
Index: code/branches/bugger/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 2531)
@@ -99,7 +99,7 @@
     void Pawn::registerVariables()
     {
-        REGISTERDATA(this->bAlive_, direction::toclient);
-        REGISTERDATA(this->health_, direction::toclient);
-        REGISTERDATA(this->initialHealth_, direction::toclient);
+        registerVariable(this->bAlive_, variableDirection::toclient);
+        registerVariable(this->health_, variableDirection::toclient);
+        registerVariable(this->initialHealth_, variableDirection::toclient);
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/pawns/SpaceShip.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/pawns/SpaceShip.cc	(revision 2531)
@@ -85,7 +85,7 @@
     void SpaceShip::registerVariables()
     {
-        REGISTERDATA(this->maxRotation_,             direction::toclient);
-        REGISTERDATA(this->rotationAcceleration_,    direction::toclient);
-        REGISTERDATA(this->translationDamping_,      direction::toclient);
+        registerVariable(this->maxRotation_,             variableDirection::toclient);
+        registerVariable(this->rotationAcceleration_,    variableDirection::toclient);
+        registerVariable(this->translationDamping_,      variableDirection::toclient);
     }
 
Index: code/branches/bugger/src/orxonox/objects/worldentities/pawns/Spectator.cc
===================================================================
--- code/branches/bugger/src/orxonox/objects/worldentities/pawns/Spectator.cc	(revision 2530)
+++ code/branches/bugger/src/orxonox/objects/worldentities/pawns/Spectator.cc	(revision 2531)
@@ -91,6 +91,6 @@
     void Spectator::registerVariables()
     {
-        REGISTERDATA(this->bGreetingFlareVisible_, direction::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
-        REGISTERDATA(this->bGreeting_,             direction::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
+        registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
+        registerVariable(this->bGreeting_,             variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
     }
 
Index: code/branches/bugger/src/util/mbool.h
===================================================================
--- code/branches/bugger/src/util/mbool.h	(revision 2530)
+++ code/branches/bugger/src/util/mbool.h	(revision 2531)
@@ -36,4 +36,5 @@
     struct _UtilExport mbool
     {
+//        friend Synchronisable::registerVariable<>()
         public:
             inline mbool(bool value = false)
@@ -67,4 +68,6 @@
             inline bool operator!() const
                 { return (!this->value_.bool_); }
+            
+            inline unsigned char& getMemory(){ return value_.memory_; }
 
         private:
Index: code/branches/bugger/visual_studio/vc8/network.vcproj
===================================================================
--- code/branches/bugger/visual_studio/vc8/network.vcproj	(revision 2530)
+++ code/branches/bugger/visual_studio/vc8/network.vcproj	(revision 2531)
@@ -197,5 +197,5 @@
 			</File>
 			<File
-				RelativePath="..\..\src\network\Synchronisable.cc"
+				RelativePath="..\..\src\network\TrafficControl.cc"
 				>
 			</File>
@@ -229,4 +229,24 @@
 				<File
 					RelativePath="..\..\src\network\packet\Welcome.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="synchronisable"
+				>
+				<File
+					RelativePath="..\..\src\network\synchronisable\NetworkCallbackManager.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\synchronisable\Synchronisable.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\synchronisable\SynchronisableSpecialisations.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\synchronisable\SynchronisableVariable.cc"
 					>
 				</File>
@@ -279,8 +299,4 @@
 			</File>
 			<File
-				RelativePath="..\..\src\network\NetworkCallback.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\network\NetworkPrereqs.h"
 				>
@@ -292,8 +308,4 @@
 			<File
 				RelativePath="..\..\src\network\Server.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\network\Synchronisable.h"
 				>
 			</File>
@@ -327,4 +339,24 @@
 				<File
 					RelativePath="..\..\src\network\packet\Welcome.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="synchronisable"
+				>
+				<File
+					RelativePath="..\..\src\network\synchronisable\NetworkCallback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\synchronisable\NetworkCallbackManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\synchronisable\Synchronisable.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\synchronisable\SynchronisableVariable.h"
 					>
 				</File>
