Index: code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/synchronisable/CMakeLists.txt	(revision 6073)
+++ code/trunk/src/libraries/network/synchronisable/CMakeLists.txt	(revision 6417)
@@ -2,5 +2,4 @@
   NetworkCallbackManager.cc
   Synchronisable.cc
-  SynchronisableSpecialisations.cc
   SynchronisableVariable.cc
 )
Index: code/trunk/src/libraries/network/synchronisable/NetworkCallback.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/NetworkCallback.h	(revision 6073)
+++ code/trunk/src/libraries/network/synchronisable/NetworkCallback.h	(revision 6417)
@@ -33,7 +33,10 @@
 #include "network/NetworkPrereqs.h"
 #include "NetworkCallbackManager.h"
+// #include "util/MultiType.h"
 
 namespace orxonox{
-  
+
+  struct EmptyType{};
+
   class _NetworkExport NetworkCallbackBase
   {
@@ -58,4 +61,20 @@
   };
 
+  template <class T, class U>
+  class NetworkCallbackNotify: public NetworkCallbackBase
+  {
+    public:
+      NetworkCallbackNotify(T* object, void (T::*function) (const U&)) : object_(object), function_(function) {}
+      NetworkCallbackNotify() {}
+      virtual ~NetworkCallbackNotify() {}
+      virtual void call()
+        { (this->object_->*function_)( this->oldValue_ ); }
+      void setOldValue(const U& value){ this->oldValue_ = value; }
+    private:
+      T* object_;
+      U oldValue_;
+      void (T::*function_) (const U&);
+  };
+
 }
 
Index: code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.cc	(revision 6073)
+++ code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.cc	(revision 6417)
@@ -26,16 +26,16 @@
  *
  */
- 
+
 #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); 
+  {
+    callbackSet_.insert(cb);
   }
   void NetworkCallbackManager::deleteCallback(NetworkCallbackBase *cb)
@@ -48,5 +48,5 @@
     }
   }
-  
+
   void NetworkCallbackManager::triggerCallback(NetworkCallbackBase *cb)
   {
Index: code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.h	(revision 6073)
+++ code/trunk/src/libraries/network/synchronisable/NetworkCallbackManager.h	(revision 6417)
@@ -37,5 +37,5 @@
 
 namespace orxonox{
-  
+
   class _NetworkExport NetworkCallbackManager{
     public:
@@ -48,5 +48,5 @@
       static std::queue<NetworkCallbackBase*> triggeredCallbacks_;
   };
-  
+
 
 }
Index: code/trunk/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Serialise.h	(revision 6417)
+++ code/trunk/src/libraries/network/synchronisable/Serialise.h	(revision 6417)
@@ -0,0 +1,79 @@
+/*
+ *   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
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Functions to serialise pointers to objects that inherit from Synchronisable
+*/
+
+#ifndef _NetworkSerialise_H__
+#define _NetworkSerialise_H__
+
+#include "util/Serialise.h"
+#include "util/TypeTraits.h"
+#include "core/CorePrereqs.h"
+
+namespace orxonox{
+    
+    // These functions implement loading / saving / etc. for pointer types
+    
+    /** @brief returns the size of the objectID needed to synchronise the pointer */
+    template <class T> inline uint32_t returnSize( T*& variable )
+    {
+      return sizeof(uint32_t);
+    }
+    
+    /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
+    template <class T> inline void loadAndIncrease( T*& variable, uint8_t*& mem )
+    {
+        *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
+        mem += returnSize( variable );
+    }
+    
+    /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
+    template <class T> inline void saveAndIncrease( T*& variable, uint8_t*& mem )
+    {
+        if ( variable )
+            *(uint32_t*)(mem) = static_cast<uint32_t>(variable->getObjectID());
+        else
+            *(uint32_t*)(mem) = OBJECTID_UNKNOWN;
+        mem += returnSize( variable );
+    }
+    
+    /** @brief checks whether the objectID of the variable is the same as in the bytestream */
+    template <class T> inline  bool checkEquality( T*& variable, uint8_t* mem )
+    {
+        if ( variable )
+            return *(uint32_t*)(mem) == variable->getObjectID();
+        else
+            return *(uint32_t*)(mem) == OBJECTID_UNKNOWN;
+    }
+}
+
+
+#endif
Index: code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	(revision 6073)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	(revision 6417)
@@ -62,5 +62,5 @@
     }
     classID_ = static_cast<uint32_t>(-1);
-    
+
     // set dataSize to 0
     this->dataSize_ = 0;
@@ -277,5 +277,5 @@
       //tempsize += (*i)->getSize( mode );
     }
-    
+
     tempsize += SynchronisableHeader::getSize();
     header.setObjectID( this->objectID_ );
@@ -284,5 +284,5 @@
     header.setDataAvailable( true );
     header.setDataSize( tempsize );
-    
+
 #ifndef NDEBUG
     uint32_t size;
@@ -390,4 +390,15 @@
   }
 
+  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+  {
+    SynchronisableVariableBase* sv;
+    if (bidirectional)
+      sv = new SynchronisableVariableBidirectional<std::string>(variable, mode, cb);
+    else
+      sv = new SynchronisableVariable<std::string>(variable, mode, cb);
+    syncList.push_back(sv);
+    stringList.push_back(sv);
+  }
+
 
 }
Index: code/trunk/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.h	(revision 6073)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.h	(revision 6417)
@@ -66,6 +66,6 @@
 
   /**
-   * @brief: stores information about a Synchronisable 
-   * 
+   * @brief: stores information about a Synchronisable
+   *
    * This class stores the information about a Synchronisable (objectID_, classID_, creatorID_, dataSize)
    * in an emulated bitset.
@@ -132,5 +132,5 @@
     inline unsigned int getPriority() const { return this->objectFrequency_;}
     inline uint8_t getSyncMode() const { return this->objectMode_; }
-    
+
     void setSyncMode(uint8_t mode);
 
@@ -138,5 +138,5 @@
     Synchronisable(BaseObject* creator);
     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 setPriority(unsigned int freq){ objectFrequency_ = freq; }
 
@@ -148,5 +148,5 @@
     bool isMyData(uint8_t* mem);
     bool doSync(int32_t id, uint8_t mode=0x0);
-    
+
     inline void setObjectID(uint32_t id){ this->objectID_ = id; objectMap_[this->objectID_] = this; }
     inline void setClassID(uint32_t id){ this->classID_ = id; }
@@ -167,54 +167,22 @@
   };
 
-  // ================= Specialisation declarations
-  
-//   template <> _NetworkExport void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
-  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
-  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 <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));
+      syncList.push_back(new SynchronisableVariableBidirectional<T>(variable, mode, cb));
       this->dataSize_ += syncList.back()->getSize(state_);
     }
     else
     {
-      syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
+      syncList.push_back(new SynchronisableVariable<T>(variable, mode, cb));
       if ( this->state_ == mode )
         this->dataSize_ += syncList.back()->getSize(state_);
     }
   }
-  
+
+  template <> _NetworkExport void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional);
 
 
-//   template <class T> void Synchronisable::unregisterVariable(T& var){
-//     std::vector<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
-//   }
-
-  
 }
 
Index: code/trunk/src/libraries/network/synchronisable/SynchronisableSpecialisations.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableSpecialisations.cc	(revision 6073)
+++ 	(revision )
@@ -1,111 +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:
- *      ...
- *
- */
-
-#include <string>
-#include "util/Math.h"
-#include "Synchronisable.h"
-#include "SynchronisableVariable.h"
-
-// ================ template spezialisation
-  
-  
-namespace orxonox{
-  
-  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
-  {
-    SynchronisableVariableBase* sv;
-    if (bidirectional)
-      sv = new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb);
-    else
-      sv = new SynchronisableVariable<const std::string>(variable, mode, cb);
-    syncList.push_back(sv);
-    stringList.push_back(sv);
-  }
-  
-  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( 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/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h	(revision 6073)
+++ code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h	(revision 6417)
@@ -35,5 +35,5 @@
 #include <cassert>
 #include <cstring>
-#include "util/Serialise.h"
+#include "Serialise.h"
 #include "util/TypeTraits.h"
 #include "core/GameMode.h"
@@ -41,5 +41,5 @@
 
 namespace orxonox{
-  
+
   namespace VariableDirection{
     enum Value{
@@ -54,5 +54,5 @@
     };
   }
-  
+
   class _NetworkExport SynchronisableVariableBase
   {
@@ -81,10 +81,9 @@
       virtual inline void* getReference(){ return static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->variable_)); }
     protected:
-      
-      T& variable_;
-      uint8_t mode_;
-      NetworkCallbackBase *callback_;
+      T&                       variable_;
+      uint8_t                  mode_;
+      NetworkCallbackBase      *callback_;
   };
-  
+
   template <class T>
   class SynchronisableVariableBidirectional: public SynchronisableVariable<T>
@@ -93,5 +92,5 @@
       SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0);
       virtual ~SynchronisableVariableBidirectional();
-      
+
       virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
       virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
@@ -113,8 +112,8 @@
     }
   }
-  
+
   template <class T> SynchronisableVariable<T>::~SynchronisableVariable()
   {
-    if (this->callback_ != 0)
+    if (this->callback_)
     {
       NetworkCallbackManager::deleteCallback(this->callback_); //safe call for deletion
@@ -141,14 +140,15 @@
       return;
   // check whether we need to consider a callback
-    if ( this->callback_ != 0 )
-    {
-      if( forceCallback || !checkEquality( this->variable_, mem ) )
-        callback = true;
+    if ( this->callback_ )
+    {
+      callback = forceCallback || !checkEquality( this->variable_, mem );
+    }
+  // now do a callback if neccessary
+    if ( callback )
+    {
+      NetworkCallbackManager::triggerCallback( this->callback_ );
     }
   // write the data
     loadAndIncrease( this->variable_, mem );
-  // now do a callback if neccessary
-    if ( callback )
-      NetworkCallbackManager::triggerCallback( this->callback_ );
   }
 
@@ -216,5 +216,5 @@
             mem += sizeof(varReference_);
             memcpy(static_cast<void*>(const_cast<typename Loki::TypeTraits<T>::UnqualifiedType*>(&this->varBuffer_)), &this->variable_, sizeof(T));
-            if ( this->callback_ != 0 )
+            if ( this->callback_ )
               callback = true;
           }
@@ -235,14 +235,16 @@
           {
             // value changed so remark for callback
-            if ( this->callback_ != 0 )
+            if ( this->callback_ )
               callback = true;
           }
         }
       }
+  // now do a callback if neccessary
+      if ( callback )
+      {
+        NetworkCallbackManager::triggerCallback( this->callback_ );
+      }
   // now write the data
       loadAndIncrease(this->variable_, mem);
-  // now do a callback if neccessary
-      if ( callback )
-        NetworkCallbackManager::triggerCallback( this->callback_ );
     }
 
@@ -251,5 +253,5 @@
       return returnSize( this->variable_ ) + sizeof(varReference_);
     }
-  
+
 
 }
