Index: code/branches/core5/src/libraries/network/Client.cc
===================================================================
--- code/branches/core5/src/libraries/network/Client.cc	(revision 5914)
+++ code/branches/core5/src/libraries/network/Client.cc	(revision 5916)
@@ -49,4 +49,6 @@
 #include "packet/Gamestate.h"
 #include "FunctionCallManager.h"
+#include "core/CoreIncludes.h"
+#include "core/Game.h"
 
 namespace orxonox
@@ -158,4 +160,21 @@
     return;
   }
+  
+  void Client::connectionClosed()
+  {
+    ObjectList<Synchronisable>::iterator it;
+    for(it = ObjectList<Synchronisable>::begin(); it; )
+    {
+      if( it->getSyncMode() != 0x0 )
+        (it++)->destroy();
+      else
+      {
+        Synchronisable* blub = *it;
+        ++it;
+      }
+    }
+    Game::getInstance().popState();
+    Game::getInstance().popState();
+  }
 
 }
Index: code/branches/core5/src/libraries/network/Client.h
===================================================================
--- code/branches/core5/src/libraries/network/Client.h	(revision 5914)
+++ code/branches/core5/src/libraries/network/Client.h	(revision 5916)
@@ -74,5 +74,6 @@
 
     void update(const Clock& time);
-
+  protected:
+    virtual void connectionClosed();
   private:
     Client(const Client& copy); // not used
Index: code/branches/core5/src/libraries/network/ClientConnection.cc
===================================================================
--- code/branches/core5/src/libraries/network/ClientConnection.cc	(revision 5914)
+++ code/branches/core5/src/libraries/network/ClientConnection.cc	(revision 5916)
@@ -118,4 +118,5 @@
           case ENET_EVENT_TYPE_DISCONNECT:
             COUT(4) << "received disconnect confirmation from server" << endl;
+            this->connectionClosed();
             return true;
         }
@@ -123,4 +124,5 @@
     }
     enet_peer_reset( this->server_ );
+    this->connectionClosed();
     return false;
   }
@@ -142,4 +144,5 @@
     COUT(1) << "Received disconnect Packet from Server!" << endl;
         // server closed the connection
+    this->connectionClosed();
   }
 
Index: code/branches/core5/src/libraries/network/ClientConnection.h
===================================================================
--- code/branches/core5/src/libraries/network/ClientConnection.h	(revision 5914)
+++ code/branches/core5/src/libraries/network/ClientConnection.h	(revision 5916)
@@ -53,4 +53,6 @@
     bool addPacket(ENetPacket *packet);
     inline bool isConnected(){ return this->established_; }
+  protected:
+    virtual void connectionClosed()=0;
   private:
     virtual void addPeer(ENetEvent* event);
Index: code/branches/core5/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/core5/src/libraries/network/synchronisable/Synchronisable.cc	(revision 5914)
+++ code/branches/core5/src/libraries/network/synchronisable/Synchronisable.cc	(revision 5916)
@@ -47,7 +47,7 @@
   /**
   * Constructor:
-  * Initializes all Variables and sets the right objectID
+  * Initializes all Variables and sets the right objectID_
   */
-  Synchronisable::Synchronisable(BaseObject* creator){
+  Synchronisable::Synchronisable(BaseObject* creator ){
     RegisterRootObject(Synchronisable);
     static uint32_t idCounter=0;
@@ -55,14 +55,11 @@
     if ( GameMode::isMaster() || ( Host::running() && Host::isServer() ) )
     {
-      this->objectID = idCounter++; //this is only needed when running a server
-    //add synchronisable to the objectMap
-      objectMap_[this->objectID] = this;
+      this->setObjectID( idCounter++ );
     }
     else
     {
-      objectID=OBJECTID_UNKNOWN;
-      this->setObjectMode(0x0);   //make sure this object doesn't get synchronized
-    }
-    classID = static_cast<uint32_t>(-1);
+      objectID_=OBJECTID_UNKNOWN;
+    }
+    classID_ = static_cast<uint32_t>(-1);
     
     // set dataSize to 0
@@ -73,7 +70,7 @@
     // get creator id
     if( creator )
-      this->creatorID = creator->getSceneID();
+      this->creatorID_ = creator->getSceneID();
     else
-      this->creatorID = OBJECTID_UNKNOWN;
+      this->creatorID_ = OBJECTID_UNKNOWN;
 
     /*searchcreatorID:
@@ -95,5 +92,5 @@
   /**
    * Destructor:
-   * Delete all callback objects and remove objectID from the objectMap_
+   * Delete all callback objects and remove objectID_ from the objectMap_
    */
   Synchronisable::~Synchronisable(){
@@ -102,5 +99,5 @@
       // remove object from the static objectMap
       if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
-        deletedObjects_.push(objectID);
+        deletedObjects_.push(objectID_);
     }
     // delete all Synchronisable Variables from syncList ( which are also in stringList )
@@ -110,5 +107,5 @@
     stringList.clear();
     std::map<uint32_t, Synchronisable*>::iterator it;
-    it = objectMap_.find(objectID);
+    it = objectMap_.find(objectID_);
     if (it != objectMap_.end())
       objectMap_.erase(it);
@@ -175,13 +172,12 @@
     Synchronisable *no = orxonox_cast<Synchronisable*>(bo);
     assert(no);
-    no->objectID=header.getObjectID();
+    assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
+    no->setObjectID(header.getObjectID());
     //no->creatorID=header.getCreatorID(); //TODO: remove this
-    no->classID=header.getClassID();
-    assert(no->creatorID == header.getCreatorID());
-    //assert(no->classID == header.getClassID());
-    COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
+    no->setClassID(header.getClassID());
+    assert(no->creatorID_ == header.getCreatorID());
+    //assert(no->classID_ == header.getClassID());
+    COUT(4) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << std::endl;
           // update data and create object/entity...
-    assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
-    Synchronisable::objectMap_[header.getObjectID()] = no;
     bool b = no->updateData(mem, mode, true);
     assert(b);
@@ -196,13 +192,13 @@
 
   /**
-   * Finds and deletes the Synchronisable with the appropriate objectID
-   * @param objectID objectID of the Synchronisable
+   * Finds and deletes the Synchronisable with the appropriate objectID_
+   * @param objectID_ objectID_ of the Synchronisable
    * @return true/false
    */
-  bool Synchronisable::deleteObject(uint32_t objectID){
-    if(!getSynchronisable(objectID))
+  bool Synchronisable::deleteObject(uint32_t objectID_){
+    if(!getSynchronisable(objectID_))
       return false;
-    assert(getSynchronisable(objectID)->objectID==objectID);
-    Synchronisable *s = getSynchronisable(objectID);
+    assert(getSynchronisable(objectID_)->objectID_==objectID_);
+    Synchronisable *s = getSynchronisable(objectID_);
     if(s)
       s->destroy(); // or delete?
@@ -213,11 +209,11 @@
 
   /**
-   * 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){
+   * 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);
+    it1 = objectMap_.find(objectID_);
     if (it1 != objectMap_.end())
       return it1->second;
@@ -225,6 +221,6 @@
 //     ObjectList<Synchronisable>::iterator it;
 //     for(it = ObjectList<Synchronisable>::begin(); it; ++it){
-//       if( it->getObjectID()==objectID ){
-//         objectMap_[objectID] = *it;
+//       if( it->getObjectID()==objectID_ ){
+//         objectMap_[objectID_] = *it;
 //         return *it;
 //       }
@@ -236,8 +232,8 @@
 
   /**
-   * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID and classID to the given memory
+   * 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,...|
+   * |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
@@ -257,13 +253,14 @@
     uint32_t tempsize = 0;
 #ifndef NDEBUG
-    if (this->classID==0)
+    if (this->classID_==0)
       COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
 #endif
 
-    if (this->classID == static_cast<uint32_t>(-1))
-        this->classID = this->getIdentifier()->getNetworkID();
-
-    assert(ClassByID(this->classID));
-    assert(this->classID==this->getIdentifier()->getNetworkID());
+    if (this->classID_ == static_cast<uint32_t>(-1))
+        this->classID_ = this->getIdentifier()->getNetworkID();
+
+    assert(ClassByID(this->classID_));
+    assert(this->classID_==this->getIdentifier()->getNetworkID());
+    assert(this->objectID_!=OBJECTID_UNKNOWN);
     std::vector<SynchronisableVariableBase*>::iterator i;
 
@@ -274,5 +271,5 @@
 
 
-    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << std::endl;
+    COUT(5) << "Synchronisable getting data from objectID_: " << objectID_ << " classID_: " << classID_ << std::endl;
     // copy to location
     for(i=syncList.begin(); i!=syncList.end(); ++i){
@@ -282,7 +279,7 @@
     
     tempsize += SynchronisableHeader::getSize();
-    header.setObjectID( this->objectID );
-    header.setCreatorID( this->creatorID );
-    header.setClassID( this->classID );
+    header.setObjectID( this->objectID_ );
+    header.setCreatorID( this->creatorID_ );
+    header.setClassID( this->classID_ );
     header.setDataAvailable( true );
     header.setDataSize( tempsize );
@@ -316,7 +313,7 @@
     // start extract header
     SynchronisableHeader syncHeader(mem);
-    assert(syncHeader.getObjectID()==this->objectID);
-    assert(syncHeader.getCreatorID()==this->creatorID);
-    assert(syncHeader.getClassID()==this->classID);
+    assert(syncHeader.getObjectID()==this->objectID_);
+    assert(syncHeader.getCreatorID()==this->creatorID_);
+    assert(syncHeader.getClassID()==this->classID_);
     if(syncHeader.isDataAvailable()==false){
       mem += syncHeader.getDataSize();
@@ -327,5 +324,5 @@
     // stop extract header
 
-    //COUT(5) << "Synchronisable: objectID " << syncHeader.getObjectID() << ", classID " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;
+    //COUT(5) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;
     for(i=syncList.begin(); i!=syncList.end(); i++)
     {
@@ -366,9 +363,9 @@
     if(mode==0x0)
       mode=state_;
-    return ( (objectMode_&mode)!=0 && (!syncList.empty() ) );
-  }
-
-  /**
-   * This function looks at the header located in the bytestream and checks wheter objectID and classID match with the Synchronisables ones
+    return ( (this->objectMode_ & mode)!=0 && (!syncList.empty() ) );
+  }
+
+  /**
+   * 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
    */
@@ -376,5 +373,5 @@
   {
     SynchronisableHeader header(mem);
-    assert(header.getObjectID()==this->objectID);
+    assert(header.getObjectID()==this->objectID_);
     return header.isDataAvailable();
   }
@@ -388,7 +385,7 @@
    * @param mode same as in registerVar
    */
-  void Synchronisable::setObjectMode(uint8_t mode){
+  void Synchronisable::setSyncMode(uint8_t mode){
     assert(mode==0x0 || mode==0x1 || mode==0x2 || mode==0x3);
-    objectMode_=mode;
+    this->objectMode_=mode;
   }
 
Index: code/branches/core5/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/branches/core5/src/libraries/network/synchronisable/Synchronisable.h	(revision 5914)
+++ code/branches/core5/src/libraries/network/synchronisable/Synchronisable.h	(revision 5916)
@@ -68,11 +68,11 @@
    * @brief: stores information about a Synchronisable 
    * 
-   * This class stores the information about a Synchronisable (objectID, classID, creatorID, dataSize)
+   * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
    * in an emulated bitset.
    * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
    * Bit 32 is a bool and defines whether the data is actually stored or is just filled up with 0
-   * Byte 5 to 8: objectID
-   * Byte 9 to 12: classID
-   * Byte 13 to 16: creatorID
+   * Byte 5 to 8: objectID_
+   * Byte 9 to 12: classID_
+   * Byte 13 to 16: creatorID_
    */
   class _NetworkExport SynchronisableHeader{
@@ -94,14 +94,14 @@
       inline uint32_t getObjectID() const
         { return *(uint32_t*)(data_+4); }
-      inline void setObjectID(uint32_t objectID)
-        { *(uint32_t*)(data_+4) = objectID; }
+      inline void setObjectID(uint32_t objectID_)
+        { *(uint32_t*)(data_+4) = objectID_; }
       inline uint32_t getClassID() const
         { return *(uint32_t*)(data_+8); }
-      inline void setClassID(uint32_t classID)
-        { *(uint32_t*)(data_+8) = classID; }
+      inline void setClassID(uint32_t classID_)
+        { *(uint32_t*)(data_+8) = classID_; }
       inline uint32_t getCreatorID() const
         { return *(uint32_t*)(data_+12); }
-      inline void setCreatorID(uint32_t creatorID)
-        { *(uint32_t*)(data_+12) = creatorID; }
+      inline void setCreatorID(uint32_t creatorID_)
+        { *(uint32_t*)(data_+12) = creatorID_; }
       inline void operator=(SynchronisableHeader& h)
         { memcpy(data_, h.data_, getSize()); }
@@ -122,13 +122,16 @@
 
     static Synchronisable *fabricate(uint8_t*& mem, uint8_t mode=0x0);
-    static bool deleteObject(uint32_t objectID);
-    static Synchronisable *getSynchronisable(uint32_t objectID);
+    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_;}
+    inline uint32_t getObjectID() const {return this->objectID_;}
+    inline unsigned int getCreatorID() const {return this->creatorID_;}
+    inline uint32_t getClassID() const {return this->classID_;}
+    inline unsigned int getPriority() const { return this->objectFrequency_;}
+    inline uint8_t getSyncMode() const { return this->objectMode_; }
+    
+    void setSyncMode(uint8_t mode);
 
   protected:
@@ -136,5 +139,4 @@
     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 setPriority(unsigned int freq){ objectFrequency_ = freq; }
 
@@ -146,8 +148,11 @@
     bool isMyData(uint8_t* mem);
     bool doSync(int32_t id, uint8_t mode=0x0);
-
-    uint32_t objectID;
-    uint32_t creatorID;
-    uint32_t classID;
+    
+    inline void setObjectID(uint32_t id){ this->objectID_ = id; objectMap_[this->objectID_] = this; }
+    inline void setClassID(uint32_t id){ this->classID_ = id; }
+
+    uint32_t objectID_;
+    uint32_t creatorID_;
+    uint32_t classID_;
 
     std::vector<SynchronisableVariableBase*> syncList;
