Index: code/trunk/src/network/synchronisable/NetworkCallbackManager.cc
===================================================================
--- code/trunk/src/network/synchronisable/NetworkCallbackManager.cc	(revision 3068)
+++ code/trunk/src/network/synchronisable/NetworkCallbackManager.cc	(revision 3084)
@@ -32,5 +32,5 @@
 
 namespace orxonox{
-
+  
   std::set<NetworkCallbackBase*> NetworkCallbackManager::callbackSet_;
   std::queue<NetworkCallbackBase*> NetworkCallbackManager::triggeredCallbacks_;
@@ -60,5 +60,7 @@
     while( triggeredCallbacks_.empty()==false )
     {
-      triggeredCallbacks_.front()->call();
+      //make sure callback hasn't been deleted before
+      if ( callbackSet_.find(triggeredCallbacks_.front()) != callbackSet_.end() )
+        triggeredCallbacks_.front()->call();
       triggeredCallbacks_.pop();
     }
Index: code/trunk/src/network/synchronisable/Synchronisable.cc
===================================================================
--- code/trunk/src/network/synchronisable/Synchronisable.cc	(revision 3068)
+++ code/trunk/src/network/synchronisable/Synchronisable.cc	(revision 3084)
@@ -66,5 +66,7 @@
       objectID=OBJECTID_UNKNOWN;
     classID = static_cast<uint32_t>(-1);
-
+    
+    // set dataSize to 0
+    this->dataSize_ = 0;
     // set standard priority
     this->setPriority( priority::normal );
@@ -96,5 +98,5 @@
     // delete callback function objects
     if(!Identifier::isCreatingHierarchy()){
-      for(std::list<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
+      for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
         delete (*it);
       if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
@@ -236,10 +238,10 @@
    * @return true: if !doSync or if everything was successfully saved
    */
-  bool Synchronisable::getData(uint8_t*& mem, int32_t id, uint8_t mode){
+  uint32_t 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;
+      return 0;
     uint32_t tempsize = 0;
     if (this->classID==0)
@@ -250,28 +252,32 @@
 
     assert(this->classID==this->getIdentifier()->getNetworkID());
-    std::list<SynchronisableVariableBase*>::iterator i;
-    uint32_t size;
-    size=getSize(id, mode);
+    std::vector<SynchronisableVariableBase*>::iterator i;
 
     // start copy header
     SynchronisableHeader header(mem);
-    header.setDataSize( size );
+    mem += SynchronisableHeader::getSize();
+    // end copy header
+
+
+    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << std::endl;
+    // copy to location
+    for(i=syncList.begin(); i!=syncList.end(); ++i){
+      tempsize += (*i)->getData( mem, mode );
+      //tempsize += (*i)->getSize( mode );
+    }
+    
+    tempsize += SynchronisableHeader::getSize();
     header.setObjectID( this->objectID );
     header.setCreatorID( this->creatorID );
     header.setClassID( this->classID );
     header.setDataAvailable( true );
-    tempsize += SynchronisableHeader::getSize();
-    mem += SynchronisableHeader::getSize();
-    // 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 );
-    }
+    header.setDataSize( tempsize );
+    
+#ifndef NDEBUG
+    uint32_t size;
+    size=getSize(id, mode);
     assert(tempsize==size);
-    return true;
+#endif
+    return tempsize;
   }
 
@@ -286,5 +292,5 @@
     if(mode==0x0)
       mode=state_;
-    std::list<SynchronisableVariableBase *>::iterator i;
+    std::vector<SynchronisableVariableBase *>::iterator i;
     if(syncList.empty()){
       assert(0);
@@ -325,10 +331,12 @@
   uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){
     int tsize=SynchronisableHeader::getSize();
-    if(mode==0x0)
+    if (mode==0x0)
       mode=state_;
-    if(!doSync(id, mode))
+    if (!doSync(id, mode))
       return 0;
-    std::list<SynchronisableVariableBase*>::iterator i;
-    for(i=syncList.begin(); i!=syncList.end(); i++){
+    assert( mode==state_ );
+    tsize += this->dataSize_;
+    std::vector<SynchronisableVariableBase*>::iterator i;
+    for(i=stringList.begin(); i!=stringList.end(); ++i){
       tsize += (*i)->getSize( mode );
     }
Index: code/trunk/src/network/synchronisable/Synchronisable.h
===================================================================
--- code/trunk/src/network/synchronisable/Synchronisable.h	(revision 3068)
+++ code/trunk/src/network/synchronisable/Synchronisable.h	(revision 3084)
@@ -33,7 +33,9 @@
 
 #include <list>
+#include <vector>
 #include <map>
 #include <queue>
 #include <cassert>
+#include <string>
 #include "util/Math.h"
 #include "util/mbool.h"
@@ -120,5 +122,4 @@
   public:
     friend class packet::Gamestate;
-//     friend class Server;
     virtual ~Synchronisable();
 
@@ -139,5 +140,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);
+    //template <class T> void unregisterVariable(T& var);
     void setObjectMode(uint8_t mode);
     void setPriority(unsigned int freq){ objectFrequency_ = freq; }
@@ -145,5 +146,5 @@
 
   private:
-    bool getData(uint8_t*& men, int32_t id, uint8_t mode=0x0);
+    uint32_t 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);
@@ -155,5 +156,7 @@
     uint32_t classID;
 
-    std::list<SynchronisableVariableBase*> syncList;
+    std::vector<SynchronisableVariableBase*> syncList;
+    std::vector<SynchronisableVariableBase*> stringList;
+    uint32_t dataSize_; //size of all variables except strings
     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)
@@ -164,29 +167,8 @@
   };
 
-  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 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);
@@ -200,4 +182,39 @@
   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));
+      this->dataSize_ += syncList.back()->getSize(state_);
+    }
+    else
+    {
+      syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
+      if ( this->state_ == mode )
+        this->dataSize_ += syncList.back()->getSize(state_);
+    }
+  }
+  
+
+
+//   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/network/synchronisable/SynchronisableSpecialisations.cc
===================================================================
--- code/trunk/src/network/synchronisable/SynchronisableSpecialisations.cc	(revision 3068)
+++ code/trunk/src/network/synchronisable/SynchronisableSpecialisations.cc	(revision 3084)
@@ -29,4 +29,5 @@
 
 #include "network/synchronisable/Synchronisable.h"
+#include <string>
 
 // ================ template spezialisation
@@ -34,4 +35,22 @@
   
 namespace orxonox{
+  
+//   template <> void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+//   {
+//     if (bidirectional)
+//       syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
+//     else
+//       syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
+//     stringList.push_back(syncList.back());
+//   }
+  
+  template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
+  {
+    if (bidirectional)
+      syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
+    else
+      syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
+    stringList.push_back(syncList.back());
+  }
   
   template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
@@ -52,8 +71,8 @@
     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( 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)
Index: code/trunk/src/network/synchronisable/SynchronisableVariable.cc
===================================================================
--- code/trunk/src/network/synchronisable/SynchronisableVariable.cc	(revision 3068)
+++ code/trunk/src/network/synchronisable/SynchronisableVariable.cc	(revision 3084)
@@ -21,5 +21,5 @@
  *
  *   Author:
- *      Oliver Scheuss, (C) 2008
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
@@ -28,7 +28,4 @@
 
 #include "SynchronisableVariable.h"
-#include <cstring>
-#include "util/Math.h"
-#include "core/GameMode.h"
 
 
@@ -37,405 +34,4 @@
 uint8_t SynchronisableVariableBase::state_ = 0;
 
-/*static*/ void SynchronisableVariableBase::setState()
-{
-  if ( state_ == 0x0 )
-  {
-    state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
-  }
-}
 
-
-// =================== 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;
-  memcpy(&temp, mem, sizeof(uint64_t));
-  *(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_);
-  memcpy(mem, &temp, sizeof(uint64_t));
-  mem += SynchronisableVariable<const long double>::returnSize();
-}
-
-template <> bool SynchronisableVariable<const long double>::checkEquality( uint8_t* mem )
-{
-  double temp = static_cast<double>(this->variable_);
-  return memcmp(&temp, mem, sizeof(uint64_t))==0;
-}
-
-// =========== 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);
-}
-
-}
+} //namespace
Index: code/trunk/src/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/trunk/src/network/synchronisable/SynchronisableVariable.h	(revision 3068)
+++ code/trunk/src/network/synchronisable/SynchronisableVariable.h	(revision 3084)
@@ -21,5 +21,5 @@
  *
  *   Author:
- *      Oliver Scheuss, (C) 2008
+ *      Oliver Scheuss
  *   Co-authors:
  *      ...
@@ -35,5 +35,8 @@
 #include <string>
 #include <cassert>
-#include "util/Math.h"
+#include "util/Serialise.h"
+#include "core/Core.h"
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
 #include "network/synchronisable/NetworkCallback.h"
 #include "network/synchronisable/NetworkCallbackManager.h"
@@ -55,5 +58,5 @@
   {
     public:
-      virtual void getData(uint8_t*& mem, uint8_t mode)=0;
+      virtual uint32_t 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;
@@ -62,5 +65,4 @@
       virtual ~SynchronisableVariableBase() {}
     protected:
-      static void setState();
       static uint8_t state_;
   };
@@ -74,13 +76,9 @@
 
       virtual inline uint8_t getMode(){ return mode_; }
-      virtual inline void getData(uint8_t*& mem, uint8_t mode);
+      virtual inline uint32_t getData(uint8_t*& mem, uint8_t mode);
       virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
       virtual inline 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_;
@@ -97,7 +95,7 @@
       
       virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
-      virtual void getData(uint8_t*& mem, uint8_t mode);
+      virtual inline uint32_t 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);
+      virtual inline uint32_t getSize(uint8_t mode);
     private:
       T varBuffer_;
@@ -110,5 +108,8 @@
       variable_( variable ), mode_( syncDirection ), callback_( cb )
   {
-      setState();
+    if ( state_ == 0x0 )
+    {
+      state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
+    }
   }
   
@@ -119,9 +120,13 @@
   }
 
-  template <class T> void SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
+  template <class T> inline uint32_t SynchronisableVariable<T>::getData(uint8_t*& mem, uint8_t mode)
   {
     if ( state_ == this->mode_ )
-      getAndIncrease( mem );
-//   mem += SynchronisableVariable<T>::getSize();
+    {
+      saveAndIncrease( this->variable_, mem );
+      return returnSize( this->variable_ );
+    }
+    else
+      return 0;
   }
 
@@ -135,84 +140,22 @@
     if ( this->callback_ != 0 )
     {
-      if( forceCallback || !checkEquality( mem ) )
+      if( forceCallback || !checkEquality( this->variable_, mem ) )
         callback = true;
     }
   // write the data
-    setAndIncrease( mem );
-//   mem += SynchronisableVariable<T>::getSize();
+    loadAndIncrease( this->variable_, mem );
   // 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)
+  }
+
+  template <class T> inline uint32_t SynchronisableVariable<T>::getSize(uint8_t mode)
   {
     if ( mode == this->mode_ )
-      return returnSize();
+      return returnSize( this->variable_ );
     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);
 
 
@@ -229,5 +172,5 @@
     }
 
-    template <class T> void SynchronisableVariableBidirectional<T>::getData(uint8_t*& mem, uint8_t mode)
+    template <class T> uint32_t SynchronisableVariableBidirectional<T>::getData(uint8_t*& mem, uint8_t mode)
     {
       if ( this->mode_ == mode )
@@ -243,6 +186,6 @@
       mem += sizeof(this->varReference_);
   // now write the content
-      SynchronisableVariable<T>::getAndIncrease( mem );
-//   mem += SynchronisableVariable<T>::getSize();
+      saveAndIncrease( this->variable_, mem );
+      return SynchronisableVariableBidirectional::getSize(mode);
     }
 
@@ -255,4 +198,5 @@
         if ( *static_cast<uint8_t*>(mem) != this->varReference_ )
         { // wrong reference number, so discard the data
+//           COUT(0) << "discharding data" << endl;
           mem += getSize( mode ); // SynchronisableVariableBidirectional::getSize returns size of variable + reference
           return;
@@ -260,12 +204,12 @@
         else{
           // apply data
-          mem += sizeof(varReference_);
-          if ( SynchronisableVariableBidirectional<T>::checkEquality( mem )==true )
+          if ( checkEquality( this->variable_, mem+sizeof(varReference_) )==true )
           {
-            mem += SynchronisableVariable<T>::getSize( mode );
+            mem += getSize( mode );
             return;
           }
           else
           {
+            mem += sizeof(varReference_);
             memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(T));
             if ( this->callback_ != 0 )
@@ -285,5 +229,5 @@
           this->varReference_ = *static_cast<uint8_t*>(mem);
           mem += sizeof(varReference_);
-          if ( SynchronisableVariable<T>::checkEquality( mem ) == false )
+          if ( checkEquality( this->variable_, mem ) == false )
           {
             // value changed so remark for callback
@@ -294,14 +238,13 @@
       }
   // now write the data
-      SynchronisableVariable<T>::setAndIncrease(mem);
+      loadAndIncrease(this->variable_, 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_);
+    }
+
+    template <class T> inline uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
+    {
+      return returnSize( this->variable_ ) + sizeof(varReference_);
     }
   
