Index: code/branches/network/src/core/Factory.cc
===================================================================
--- code/branches/network/src/core/Factory.cc	(revision 2737)
+++ code/branches/network/src/core/Factory.cc	(revision 2749)
@@ -87,7 +87,15 @@
     void Factory::changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID)
     {
-        getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
+//        getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
         getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier;
 //std::cout << identifier->getName() << ": " << oldID << " -> " << newID << std::endl;
+    }
+
+    /**
+        @brief Cleans the NetworkID map (needed on clients for correct initialization)
+    */
+    void Factory::cleanNetworkIDs()
+    {
+        getFactoryPointer()->identifierNetworkIDMap_.clear();
     }
 
Index: code/branches/network/src/core/Factory.h
===================================================================
--- code/branches/network/src/core/Factory.h	(revision 2737)
+++ code/branches/network/src/core/Factory.h	(revision 2749)
@@ -63,4 +63,5 @@
             static void add(const std::string& name, Identifier* identifier);
             static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);
+	    static void cleanNetworkIDs();
             static void createClassHierarchy();
 
Index: code/branches/network/src/network/ConnectionManager.cc
===================================================================
--- code/branches/network/src/network/ConnectionManager.cc	(revision 2737)
+++ code/branches/network/src/network/ConnectionManager.cc	(revision 2749)
@@ -46,7 +46,7 @@
 #include <boost/bind.hpp>
 
-#include "core/CoreIncludes.h"
-#include "core/BaseObject.h"
-#include "core/Iterator.h"
+// #include "core/CoreIncludes.h"
+// #include "core/BaseObject.h"
+// #include "core/Iterator.h"
 #include "util/Math.h"
 #include "util/Sleep.h"
@@ -303,30 +303,41 @@
    * @param clientID
    */
+//   void ConnectionManager::syncClassid(unsigned int clientID) {
+//     unsigned int network_id=0, failures=0;
+//     std::string classname;
+//     Identifier *id;
+//     std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
+//     while(it != Factory::getFactoryMapEnd()){
+//       id = (*it).second;
+//       if(id == NULL)
+//         continue;
+//       classname = id->getName();
+//       network_id = id->getNetworkID();
+//       if(network_id==0)
+//         COUT(3) << "we got a null class id: " << id->getName() << std::endl;
+//       COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
+// 
+//       packet::ClassID *classid = new packet::ClassID( network_id, classname );
+//       classid->setClientID(clientID);
+//       while(!classid->send() && failures < 10){
+//         failures++;
+//       }
+//       ++it;
+//     }
+//     //sendPackets();
+//     COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
+//   }
+
   void ConnectionManager::syncClassid(unsigned int clientID) {
-    unsigned int network_id=0, failures=0;
-    std::string classname;
-    Identifier *id;
-    std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
-    while(it != Factory::getFactoryMapEnd()){
-      id = (*it).second;
-      if(id == NULL)
-        continue;
-      classname = id->getName();
-      network_id = id->getNetworkID();
-      if(network_id==0)
-        COUT(3) << "we got a null class id: " << id->getName() << std::endl;
-      COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
-
-      packet::ClassID *classid = new packet::ClassID( network_id, classname );
-      classid->setClientID(clientID);
-      while(!classid->send() && failures < 10){
-        failures++;
-      }
-      ++it;
-    }
-    //sendPackets();
+    int failures=0;
+    packet::ClassID *classid = new packet::ClassID();
+    classid->setClientID(clientID);
+    while(!classid->send() && failures < 10){
+      failures++;
+    }
+    assert(failures<10);
     COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
   }
-
+  
 
   void ConnectionManager::disconnectClient(ClientInformation *client){
Index: code/branches/network/src/network/packet/ClassID.cc
===================================================================
--- code/branches/network/src/network/packet/ClassID.cc	(revision 2737)
+++ code/branches/network/src/network/packet/ClassID.cc	(revision 2749)
@@ -31,6 +31,10 @@
 #include "ClassID.h"
 #include "core/CoreIncludes.h"
+#include "core/Factory.h"
 #include <cstring>
+#include <string>
 #include <assert.h>
+#include <map>
+#include <queue>
 
 namespace orxonox {
@@ -38,17 +42,56 @@
 
 
+#define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID             0
 
-  ClassID::ClassID( uint32_t classID, std::string className )
- : Packet()
-{
+
+ClassID::ClassID( ) : Packet(){
+  Identifier *id;
+  std::string classname;
+  unsigned int nrOfClasses=0; 
+  unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
+  uint32_t network_id;
   flags_ = flags_ | PACKET_FLAGS_CLASSID;
-  classNameLength_=className.length()+1;
-  assert(getSize());
-  data_=new unsigned char[ getSize() ];
-  assert(data_);
-  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::ClassID;
-  *(uint32_t *)(data_ + _CLASSID ) = classID;
-  *(uint32_t *)(data_ + _CLASSNAMELENGTH ) = classNameLength_;
-  memcpy( data_+_CLASSNAME, (void *)className.c_str(), classNameLength_ );
+  std::queue<std::pair<uint32_t, std::string> > tempQueue;
+  
+  //calculate total needed size (for all strings and integers)
+  std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
+  for(;it != Factory::getFactoryMapEnd();++it){
+    id = (*it).second;
+    if(id == NULL)
+      continue;
+    classname = id->getName();
+    network_id = id->getNetworkID();
+    if(network_id==0)
+      COUT(3) << "we got a null class id: " << id->getName() << std::endl;
+    // now push the network id and the classname to the stack
+    tempQueue.push( std::pair<unsigned int, std::string>(network_id, classname) );
+    ++nrOfClasses;
+    packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t);
+  }
+  
+  this->data_=new uint8_t[ packetSize ];
+  //set the appropriate packet id
+  assert(this->data_);
+  *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::ClassID;
+  
+  uint8_t *temp=data_+sizeof(uint32_t);
+  // save the number of all classes
+  *(uint32_t*)temp = nrOfClasses;
+  temp += sizeof(uint32_t);
+  
+  // now save all classids and classnames
+  std::pair<uint32_t, std::string> tempPair;
+  while( !tempQueue.empty() ){
+    tempPair = tempQueue.front();
+    tempQueue.pop();
+    *(uint32_t*)temp = tempPair.first;
+    *(uint32_t*)(temp+sizeof(uint32_t)) = tempPair.second.size()+1;
+    memcpy(temp+2*sizeof(uint32_t), tempPair.second.c_str(), tempPair.second.size()+1);
+    temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
+  }
+  
+  COUT(0) << "classid packetSize is " << packetSize << endl;
+  
 }
 
@@ -56,5 +99,4 @@
   : Packet(data, clientID)
 {
-  memcpy( (void *)&classNameLength_, &data[ _CLASSNAMELENGTH ], sizeof(classNameLength_) );
 }
 
@@ -63,13 +105,49 @@
 }
 
+uint32_t ClassID::getSize() const{
+  uint8_t *temp = data_+sizeof(uint32_t); // packet identification
+  uint32_t totalsize = sizeof(uint32_t); // packet identification
+  uint32_t nrOfClasses = *(uint32_t*)temp;
+  temp += sizeof(uint32_t);
+  totalsize += sizeof(uint32_t); // storage size for nr of all classes
+  
+  for(unsigned int i=0; i<nrOfClasses; i++){
+    totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
+  }
+  return totalsize;
+}
+
 
 bool ClassID::process(){
-  COUT(3) << "processing classid: " << getClassID() << " name: " << getClassName() << std::endl;
-  Identifier *id=ClassByString( std::string(getClassName()) );
-  if(id==NULL){
-    COUT(0) << "Recieved a bad classname" << endl;
-    abort();
+  int nrOfClasses;
+  uint8_t *temp = data_+sizeof(uint32_t); //skip the packetid
+  uint32_t networkID;
+  uint32_t stringsize;
+  unsigned char *classname;
+  
+  
+  //clean the map of network ids
+  Factory::cleanNetworkIDs();
+  
+  COUT(4) << "=== processing classids: " << endl;
+  std::pair<uint32_t, std::string> tempPair;
+  Identifier *id;
+  // read the total number of classes
+  nrOfClasses = *(uint32_t*)temp;
+  temp += sizeof(uint32_t);
+  
+  for( int i=0; i<nrOfClasses; i++){
+    networkID = *(uint32_t*)temp;
+    stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
+    classname = temp+2*sizeof(uint32_t);
+    id=ClassByString( std::string((const char*)classname) );
+    COUT(0) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
+    if(id==NULL){
+      COUT(0) << "Recieved a bad classname" << endl;
+      abort();
+    }
+    id->setNetworkID( networkID );
+    temp += 2*sizeof(uint32_t) + stringsize;
   }
-  id->setNetworkID( getClassID() );
   delete this;
   return true;
@@ -77,7 +155,7 @@
 
 
-uint32_t ClassID::getClassID(){
-  return *(uint32_t *)(data_ + _CLASSID);
-}
+// uint32_t ClassID::getClassID(){
+//   return *(uint32_t *)(data_ + _CLASSID);
+// }
 
 } //namespace packet
Index: code/branches/network/src/network/packet/ClassID.h
===================================================================
--- code/branches/network/src/network/packet/ClassID.h	(revision 2737)
+++ code/branches/network/src/network/packet/ClassID.h	(revision 2749)
@@ -38,9 +38,4 @@
 namespace packet {
 
-#define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
-#define _PACKETID             0
-#define _CLASSID              _PACKETID + sizeof(ENUM::Type)
-#define _CLASSNAMELENGTH      _CLASSID + sizeof(uint32_t)
-#define _CLASSNAME            _CLASSNAMELENGTH + sizeof(classNameLength_)
   
 /**
@@ -50,16 +45,17 @@
 {
 public:
-  ClassID( uint32_t classID, std::string className );
+  ClassID( );
   ClassID( uint8_t* data, unsigned int clientID );
   ~ClassID();
 
-  inline uint32_t getSize() const{ return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t) + classNameLength_; }
+  uint32_t getSize() const;
   bool process();
 
-  uint32_t getClassID();
-  uint32_t getClassNameLength(){ return classNameLength_; }
-  const char *getClassName(){ return (const char*)(data_+_CLASSNAME); }
+//   uint32_t getClassID();
+//   uint32_t getClassNameLength(){ return classNameLength_; }
+//   const char *getClassName(){ return (const char*)(data_+_CLASSNAME); }
 private:
-  uint32_t classNameLength_;
+//   uint32_t classNameLength_;
+//   static bool alreadySetOneClassID_;
 };
 
Index: code/branches/network/src/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/network/src/network/synchronisable/Synchronisable.cc	(revision 2737)
+++ code/branches/network/src/network/synchronisable/Synchronisable.cc	(revision 2749)
@@ -158,4 +158,6 @@
     if (!id)
     {
+        for(int i = 0; i<100; i++)
+            COUT(0) << "classid: " << i << " identifier: " << ClassByID(i) << endl;
         COUT(0) << "Assertion failed: id" << std::endl;
         COUT(0) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl;
