Index: /code/branches/objecthierarchy/TODO
===================================================================
--- /code/branches/objecthierarchy/TODO	(revision 2131)
+++ /code/branches/objecthierarchy/TODO	(revision 2132)
@@ -1,3 +1,5 @@
 todo: 
+
+	test network functionality with paketloss/delay: http://www.linuxfoundation.org/en/Net:Netem#Packet_loss
 
 	bidirectional
Index: /code/branches/objecthierarchy/src/network/Synchronisable.cc
===================================================================
--- /code/branches/objecthierarchy/src/network/Synchronisable.cc	(revision 2131)
+++ /code/branches/objecthierarchy/src/network/Synchronisable.cc	(revision 2132)
@@ -50,4 +50,5 @@
 // #include "core/Identifier.h"
 
+#include "Host.h"
 namespace orxonox
 {
@@ -57,5 +58,5 @@
   std::queue<unsigned int> Synchronisable::deletedObjects_;
 
-  int Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
+  uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
 
   /**
@@ -99,5 +100,5 @@
       for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)
         delete (*it)->callback;
-      if (this->objectMode_ != 0x0)
+      if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
         deletedObjects_.push(objectID);
 //       COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;
@@ -143,5 +144,5 @@
    * @return pointer to the newly created synchronisable
    */
-  Synchronisable *Synchronisable::fabricate(uint8_t*& mem, int mode)
+  Synchronisable *Synchronisable::fabricate(uint8_t*& mem, uint8_t mode)
   {
     synchronisableHeader *header = (synchronisableHeader *)mem;
@@ -238,5 +239,5 @@
   * @param cb callback object that should get called, if the value of the variable changes
   */
-  void Synchronisable::registerVar(void *var, int size, variableType t, int mode, NetworkCallbackBase *cb){
+  void Synchronisable::registerVar(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
@@ -249,6 +250,13 @@
     if( ( mode & direction::bidirectional ) )
     {
-      temp->varBuffer = new uint8_t[size];
-      memcpy(temp->varBuffer, temp->var, size); //now fill the buffer for the first time
+      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;
     }
@@ -280,12 +288,12 @@
    * @return true: if !doSync or if everything was successfully saved
    */
-  bool Synchronisable::getData(uint8_t*& mem, unsigned int id, int mode){
+  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))
+    if(!doSync(id, mode))
       return true;
     //std::cout << "inside getData" << std::endl;
     unsigned int tempsize = 0;
-    if(mode==0x0)
-      mode=state_;
     if(classID==0)
       COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
@@ -307,6 +315,6 @@
     header->classID = this->classID;
     header->dataAvailable = true;
-    tempsize+=sizeof(synchronisableHeader);
-    mem+=sizeof(synchronisableHeader);
+    tempsize += sizeof(synchronisableHeader);
+    mem += sizeof(synchronisableHeader);
     // end copy header
 
@@ -319,25 +327,50 @@
         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;
+          mem += (*i)->size;
+          tempsize += (*i)->size;
           break;
         case STRING:
           memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(size_t) );
-          mem+=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);
+          mem += (*i)->size;
+          tempsize += (*i)->size + sizeof(size_t);
           break;
       }
@@ -354,8 +387,10 @@
    * @return true/false
    */
-  bool Synchronisable::updateData(uint8_t*& mem, int mode, bool forceCallback){
+  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;
@@ -367,14 +402,13 @@
     synchronisableHeader *syncHeader = (synchronisableHeader *)mem;
     assert(syncHeader->objectID==this->objectID);
-//    assert(syncHeader->creatorID==this->creatorID);
+    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;
+      mem += syncHeader->size;
       return true;
     }
 
-    mem+=sizeof(synchronisableHeader);
+    mem += sizeof(synchronisableHeader);
     // stop extract header
-    assert(this->objectID==syncHeader->objectID);
-//    assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ?
 
     COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl;
@@ -382,59 +416,85 @@
       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)->mode & direction::bidirectional ) == direction::bidirectional )
+          if((*i)->callback) // check whether this variable changed (but only if callback was set)
           {
-            if( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \
-                  ( mode == 0x2 && (*i)->mode == direction::clientMaster ) )    // if true we are master on this variable
-            {
-              uint8_t refNr = *(uint8_t *)mem;
-              if( refNr != (*i)->varReference )
-              {
-                mem += sizeof((*i)->varReference) + (*i)->size; // the reference for this variable is not recent, discard data
-                break;
-              }
-            }
-            else //we are slave for this variable
-            {
-              (*i)->varReference = *(uint8_t *)mem; //copy the reference value for this variable
-            }
-            mem += sizeof((*i)->varReference);
+            if(memcmp((*i)->var, mem, (*i)->size) != 0)
+              callback=true;
           }
-          if((*i)->callback) // check whether this variable changed (but only if callback was set)
-            if(strncmp((char *)(*i)->var, (char *)mem, (*i)->size)!=0)
-              callback=true;
-          memcpy((void*)(*i)->var, mem, (*i)->size);
-          mem+=(*i)->size;
+          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:
-          if( ( (*i)->mode & direction::bidirectional ) == direction::bidirectional )
+          (*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( ( mode == 0x1 && (*i)->mode == direction::serverMaster ) || \
-                  ( mode == 0x2 && (*i)->mode == direction::clientMaster ) )    // if true we are master for this variable
-            {
-              uint8_t refNr = *(uint8_t *)mem;
-              mem += sizeof( (*i)->varReference );
-              if( refNr != (*i)->varReference ){
-                mem += sizeof(size_t) + *(size_t *)mem; // the reference for this variable is not recent, discard data
-                break;
-              }
-            }
-            else //we are slave for this variable
-            {
-              (*i)->varReference = *(uint8_t *)mem; //copy the reference value for this variable
-            }
-            mem += sizeof( (*i)->varReference );
+            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)) );
           }
-          (*i)->size = *(size_t *)mem;
-          COUT(5) << "string size: " << (*i)->size << std::endl;
-          mem += sizeof(size_t);
-          if((*i)->callback) // check whether this string changed
-            if( *(std::string *)((*i)->var) != std::string((char *)mem) )
-              callback=true;
+          
           *((std::string *)((*i)->var)) = std::string((const char*)mem);
           COUT(5) << "synchronisable: char: " << (const char*)mem << " string: " << std::string((const char*)mem) << std::endl;
@@ -446,4 +506,5 @@
         (*i)->callback->call();
     }
+    assert(mem == data+syncHeader->size);
     return true;
   }
@@ -455,10 +516,10 @@
   * @return amount of bytes
   */
-  uint32_t Synchronisable::getSize(unsigned int id, int mode){
-    if(!doSync(id))
-      return 0;
+  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++){
@@ -489,10 +550,13 @@
    * @return true/false
    */
-  bool Synchronisable::doSync(unsigned int id){
-    return ( (objectMode_&state_)!=0 && (!syncList->empty() ) );
+  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 ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0);
+    return true; //TODO: change this
+    //return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0);
   }
 
@@ -510,4 +574,5 @@
   /**
    * 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
@@ -515,5 +580,5 @@
    * @param mode same as in registerVar
    */
-  void Synchronisable::setObjectMode(int mode){
+  void Synchronisable::setObjectMode(uint8_t mode){
     assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3);
     objectMode_=mode;
Index: /code/branches/objecthierarchy/src/network/Synchronisable.h
===================================================================
--- /code/branches/objecthierarchy/src/network/Synchronisable.h	(revision 2131)
+++ /code/branches/objecthierarchy/src/network/Synchronisable.h	(revision 2132)
@@ -62,5 +62,5 @@
   namespace syncmode{
     enum mode{
-      one=0,
+      once=0,
       always=1
     };
@@ -81,6 +81,6 @@
 
   struct _NetworkExport synchronisableVariable{
-    unsigned int size;
-    int mode; // this determines in which direction the variable gets synchronised
+    size_t size;
+    uint8_t mode; // this determines in which direction the variable gets synchronised
     void *var;
     variableType type;
@@ -98,6 +98,5 @@
   public:
     friend class packet::Gamestate;
-    friend class GamestateClient;
-    friend class Server;
+//     friend class Server;
     virtual ~Synchronisable();
 
@@ -106,5 +105,5 @@
     static void setClient(bool b);
 
-    static Synchronisable *fabricate(uint8_t*& mem, int mode=0x0);
+    static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0);
     static bool deleteObject(unsigned int objectID);
     static Synchronisable *getSynchronisable(unsigned int objectID);
@@ -116,16 +115,16 @@
   protected:
     Synchronisable(BaseObject* creator);
-    void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
-    void setObjectMode(int mode);
+    void registerVar(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
+    void setObjectMode(uint8_t mode);
     void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
 
 
   private:
-    bool getData(uint8_t*& men, unsigned int id, int mode=0x0);
-    uint32_t getSize(unsigned int id, int mode=0x0);
-    bool updateData(uint8_t*& mem, int mode=0x0, bool forceCallback=false);
+    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);
+    bool doSync(unsigned int id, uint8_t mode=0x0);
 
     unsigned int objectID;
@@ -134,5 +133,5 @@
 
     std::list<synchronisableVariable *> *syncList;
-    static int state_; // detemines wheter we are server (default) or client
+    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_;
Index: /code/branches/objecthierarchy/src/network/packet/Gamestate.cc
===================================================================
--- /code/branches/objecthierarchy/src/network/packet/Gamestate.cc	(revision 2131)
+++ /code/branches/objecthierarchy/src/network/packet/Gamestate.cc	(revision 2132)
@@ -71,9 +71,9 @@
 }
 
-bool Gamestate::collectData(int id, int mode)
-{
-  int tempsize=0, currentsize=0;
+bool Gamestate::collectData(int id, uint8_t mode)
+{
+  unsigned int tempsize=0, currentsize=0;
   assert(data_==0);
-  int size = calcGamestateSize(id, mode);
+  unsigned int size = calcGamestateSize(id, mode);
 
   COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
@@ -86,8 +86,4 @@
   }
 
-#ifndef NDEBUG
-  std::list<Synchronisable*> slist;
-  std::list<Synchronisable*>::iterator iit;
-#endif
   //start collect data synchronisable by synchronisable
   uint8_t *mem=data_;
@@ -98,4 +94,5 @@
 
     if(currentsize+tempsize > size){
+      assert(0); // if we don't use multithreading this part shouldn't be neccessary
       // start allocate additional memory
       COUT(3) << "G.St.Man: need additional memory" << std::endl;
@@ -110,9 +107,4 @@
     }// stop allocate additional memory
 
-#ifndef NDEBUG
-    for(iit=slist.begin(); iit!=slist.end(); iit++)
-      assert((*iit)!=*it);
-    slist.push_back(*it);
-#endif
 
     //if(it->doSelection(id))
@@ -127,5 +119,4 @@
   //start write gamestate header
   HEADER->packetType = ENUM::Gamestate;
-  assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);
   HEADER->datasize = currentsize;
   HEADER->id = id;
@@ -140,5 +131,5 @@
 }
 
-bool Gamestate::spreadData(int mode)
+bool Gamestate::spreadData(uint8_t mode)
 {
   assert(data_);
@@ -163,6 +154,4 @@
       bool b = s->updateData(mem, mode);
       assert(b);
-      //if(!s->updateData(mem, mode))
-        //return false;
     }
   }
@@ -367,5 +356,5 @@
     assert(it->second->objectID==oldobjectheader->objectID);
     *newobjectheader = *oldobjectheader;
-    objectOffset=sizeof(uint8_t)+sizeof(bool); //skip the size and the availableData variables in the objectheader
+    objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader
     if(it->second->doSelection(HEADER->id)){
       newobjectheader->dataAvailable=true; //TODO: probably not neccessary
@@ -565,7 +554,7 @@
 
 
-unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)
-{
-  int size=0;
+unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)
+{
+  unsigned int size=0;
     // get the start of the Synchronisable list
   ObjectList<Synchronisable>::iterator it;
Index: /code/branches/objecthierarchy/src/network/packet/Gamestate.h
===================================================================
--- /code/branches/objecthierarchy/src/network/packet/Gamestate.h	(revision 2131)
+++ /code/branches/objecthierarchy/src/network/packet/Gamestate.h	(revision 2132)
@@ -69,6 +69,6 @@
     ~Gamestate();
 
-    bool collectData(int id, int mode=0x0);
-    bool spreadData(int mode=0x0);
+    bool collectData(int id, uint8_t mode=0x0);
+    bool spreadData( uint8_t mode=0x0);
     int getID();
     bool isDiffed();
@@ -90,5 +90,5 @@
     bool operator ==(packet::Gamestate gs);
   private:
-    unsigned int calcGamestateSize(unsigned int id, int mode=0x0);
+    unsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0);
     void removeObject(ObjectListIterator<Synchronisable> &it);
     std::map<unsigned int, Synchronisable*> dataMap_;
Index: /code/branches/objecthierarchy/src/network/packet/Packet.cc
===================================================================
--- /code/branches/objecthierarchy/src/network/packet/Packet.cc	(revision 2131)
+++ /code/branches/objecthierarchy/src/network/packet/Packet.cc	(revision 2132)
@@ -53,5 +53,5 @@
 #define _PACKETID           0
 
-std::map<ENetPacket *, Packet *> Packet::packetMap_;
+std::map<size_t, Packet *> Packet::packetMap_;
 
 Packet::Packet(){
@@ -134,5 +134,5 @@
     // Add the packet to a global list so we can access it again once enet calls our
     // deletePacket method. We can of course only give a one argument function to the ENet C library.
-    packetMap_[enetPacket_] = this;
+    packetMap_[(size_t)(void*)enetPacket_] = this;
   }
 #ifndef NDEBUG
@@ -208,5 +208,5 @@
 void Packet::deletePacket(ENetPacket *enetPacket){
   // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
-  std::map<ENetPacket*, Packet*>::iterator it = packetMap_.find(enetPacket);
+  std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket);
   assert(it != packetMap_.end());
   // Make sure we don't delete it again in the destructor
Index: /code/branches/objecthierarchy/src/network/packet/Packet.h
===================================================================
--- /code/branches/objecthierarchy/src/network/packet/Packet.h	(revision 2131)
+++ /code/branches/objecthierarchy/src/network/packet/Packet.h	(revision 2132)
@@ -92,5 +92,5 @@
     bool bDataENetAllocated_;
   private:
-    static std::map<ENetPacket *, Packet *> packetMap_;
+    static std::map<size_t, Packet *> packetMap_;
     ENetPacket *enetPacket_;
 };
Index: /code/branches/objecthierarchy/src/orxonox/objects/Test.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/Test.cc	(revision 2131)
+++ /code/branches/objecthierarchy/src/orxonox/objects/Test.cc	(revision 2132)
@@ -30,4 +30,5 @@
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
 #include "Test.h"
 
@@ -35,10 +36,19 @@
 {
 	CreateFactory ( Test );
+  
+  SetConsoleCommand(Test, printV1, true).accessLevel(AccessLevel::User);
+  SetConsoleCommand(Test, printV2, true).accessLevel(AccessLevel::User);
+  SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
+  SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
+  
+  Test* Test::instance_ = 0;
 
 	Test::Test(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
 	{
+    assert(instance_==0);
+    instance_=this;
 		RegisterObject ( Test );
-                setConfigValues();
-                registerVariables();
+    setConfigValues();
+    registerVariables();
 		setObjectMode(0x3);
 	}
@@ -46,12 +56,13 @@
 	Test::~Test()
 	{
-
+    instance_=0;
 	}
 
 	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 ( 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 )*/;
 	}
 
@@ -60,19 +71,24 @@
 	{
 		REGISTERDATA ( v1,direction::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ) );
-                REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) );
-		REGISTERDATA ( v3,direction::bidirectional, new NetworkCallback<Test> ( this, &Test::checkV3 ) );
+    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 ) );
 	}
 
-        void Test::checkV1(){
-                COUT(1) << "V1 changed: " << v1 << std::endl;
-        }
+  void Test::checkV1(){
+    COUT(1) << "V1 changed: " << v1 << std::endl;
+  }
 
-        void Test::checkV2(){
-                COUT(1) << "V2 changed: " << v2 << std::endl;
-        }
+  void Test::checkV2(){
+    COUT(1) << "V2 changed: " << v2 << std::endl;
+  }
 
-        void Test::checkV3(){
-                COUT(1) << "V3 changed: " << v3 << std::endl;
-        }
+  void Test::checkV3(){
+    COUT(1) << "V3 changed: " << v3 << std::endl;
+  }
+  
+  void Test::checkV4(){
+    COUT(1) << "V4 changed: " << v4 << std::endl;
+  }
 
 
Index: /code/branches/objecthierarchy/src/orxonox/objects/Test.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/Test.h	(revision 2131)
+++ /code/branches/objecthierarchy/src/orxonox/objects/Test.h	(revision 2132)
@@ -48,8 +48,15 @@
       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();
+      
+      void printV1(){ instance_->checkV1(); }
+      void printV2(){ instance_->checkV2(); }
+      void printV3(){ instance_->checkV3(); }
+      void printV4(){ instance_->checkV4(); }
 
     private:
@@ -57,4 +64,7 @@
       unsigned int v2;
       unsigned int v3;
+      unsigned int v4;
+      
+      static Test* instance_;
   };
 }
Index: /code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2131)
+++ /code/branches/objecthierarchy/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 2132)
@@ -250,11 +250,11 @@
         REGISTERSTRING(this->cameraPositionTemplate_, direction::toclient);
 
+        REGISTERDATA(this->server_overwrite_,   direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
+        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_overwrite_,   direction::toserver);
-
         REGISTERDATA(this->client_position_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
         REGISTERDATA(this->client_velocity_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
