Index: code/trunk/src/network/Client.cc
===================================================================
--- code/trunk/src/network/Client.cc	(revision 871)
+++ code/trunk/src/network/Client.cc	(revision 1021)
@@ -184,5 +184,5 @@
     while(!(client_connection.queueEmpty())){
       packet = client_connection.getPacket();
-      //std::cout << "tick packet size " << packet->dataLength << std::endl;
+      COUT(5) << "tick packet size " << packet->dataLength << std::endl;
       elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
     }
@@ -191,7 +191,8 @@
 
   void Client::processGamestate( GameStateCompressed *data){
+    int id = data->id;
+    COUT(5) << "received gamestate id: " << data->id << std::endl;
     gamestate.pushGameState(data);
-    std::cout << "received gamestate id: " << data->id << std::endl;
-    client_connection.addPacket(pck_gen.acknowledgement(data->id));
+    client_connection.addPacket(pck_gen.acknowledgement(id));
     client_connection.sendPackets();
     return;
@@ -203,9 +204,10 @@
     if(id!=NULL)
       id->setNetworkID(clid->clid);
+    COUT(4) << "received and set network id: " << clid->clid << "; classname: " << clid->message << std::endl;
     return;
   }
 
   void Client::processChat( chat *data){
-    std::cout << "Server: " << data->message << std::endl;
+    COUT(0) << "Server: " << data->message << std::endl;
   }
 
Index: code/trunk/src/network/Client.h
===================================================================
--- code/trunk/src/network/Client.h	(revision 871)
+++ code/trunk/src/network/Client.h	(revision 1021)
@@ -17,8 +17,11 @@
 
 #include "NetworkPrereqs.h"
+
+#include "core/Tickable.h"
 #include "ClientConnection.h"
 #include "PacketManager.h"
 #include "GameStateClient.h"
 //#include "NetworkFrameListener.h"
+
 
 
@@ -32,5 +35,5 @@
   *
   */
-  class _NetworkExport Client : PacketDecoder{
+  class _NetworkExport Client : PacketDecoder, public orxonox::Tickable{
   public:
     Client();
Index: code/trunk/src/network/ClientConnection.cc
===================================================================
--- code/trunk/src/network/ClientConnection.cc	(revision 871)
+++ code/trunk/src/network/ClientConnection.cc	(revision 1021)
@@ -43,4 +43,5 @@
 
 #include "util/Sleep.h"
+#include "orxonox/core/Debug.h"
 #include "ClientConnection.h"
 
@@ -159,5 +160,5 @@
       case ENET_EVENT_TYPE_CONNECT:
       case ENET_EVENT_TYPE_RECEIVE:
-        //std::cout << "got packet" << std::endl;
+        COUT(5) << "receiver-Thread: got new packet" << std::endl;
         processData(&event);
         break;
@@ -215,5 +216,5 @@
 
   bool ClientConnection::processData(ENetEvent *event) {
-    //std::cout << "got packet, pushing to queue" << std::endl;
+    COUT(5) << "got packet, pushing to queue" << std::endl;
     // just add packet to the buffer
     // this can be extended with some preprocessing
Index: code/trunk/src/network/ConnectionManager.cc
===================================================================
--- code/trunk/src/network/ConnectionManager.cc	(revision 871)
+++ code/trunk/src/network/ConnectionManager.cc	(revision 1021)
@@ -257,27 +257,53 @@
 
   void ConnectionManager::syncClassid(int clientID) {
-    int i=0;
+    unsigned int network_id=0;
     std::string classname;
-    bool abort=false;
     orxonox::Identifier *id;
-    while(!abort){
-      id = ID(i);
-      std::cout << "syncid: " << i << ", ID(id): " << id << std::endl;
-      if(id == NULL){
-        if(i!=0)
-          abort=true;
-        else{
-          ++i;
-          continue;
-        }
-      }
-      else{
-        classname = id->getName();
-        addPacket(packet_gen.clid( i, classname ),clientID);
-      }
-      ++i;
+    std::map<std::string, orxonox::Identifier*>::const_iterator it = orxonox::Factory::getFactoryBegin();
+    while(it != orxonox::Factory::getFactoryEnd()){
+      id = (*it).second;
+      if(id == NULL)
+        continue;
+      classname = id->getName();
+      network_id = id->getNetworkID();
+      COUT(4) << "network_id: " << network_id << ", classname: " << classname << std::endl;
+      
+      addPacket(packet_gen.clid( (int)network_id, classname ), clientID);
+      
+      ++it;
     }
     sendPackets();
   }
 
+  
+  
+  void ConnectionManager::addClientsObjectID( int clientID, int objectID ) {
+    COUT(4) << "ship of client: " << clientID << ": " << objectID << " mapped" << std::endl;
+    clientsShip.insert( std::make_pair( clientID, objectID ) );
+  }
+
+  int ConnectionManager::getClientsShipID( int clientID ) {
+    return clientsShip[clientID];
+  }
+
+  int ConnectionManager::getObjectsClientID( int objectID ) {
+    std::map<int, int>::iterator iter = clientsShip.begin();
+    while( iter != clientsShip.end() ) {
+      if( iter->second == objectID ) return iter->first;
+    }
+    return -99;
+  }
+
+  void ConnectionManager::deleteClientIDReg( int clientID ) {
+    clientsShip.erase( clientID );
+  }
+
+  void ConnectionManager::deleteObjectIDReg( int objectID ) {
+    std::map<int, int>::iterator iter = clientsShip.begin();
+    while( iter != clientsShip.end() ) {
+      if( iter->second == objectID ) break; 
+    }
+    clientsShip.erase( iter->first );
+  }
+  
 }
Index: code/trunk/src/network/ConnectionManager.h
===================================================================
--- code/trunk/src/network/ConnectionManager.h	(revision 871)
+++ code/trunk/src/network/ConnectionManager.h	(revision 1021)
@@ -14,4 +14,5 @@
 
 #include <string>
+#include <map>
 // enet library for networking support
 #include <enet/enet.h>
@@ -73,4 +74,12 @@
     bool quit; // quit-variable (communication with threads)
     ClientInformation *head_;
+    
+    //functions to map what object every clients uses
+    std::map<int, int> clientsShip;
+    void addClientsObjectID( int clientID, int objectID );
+    int getClientsShipID( int clientID );
+    int getObjectsClientID( int objectID );
+    void deleteClientIDReg( int clientID );
+    void deleteObjectIDReg( int objectID );
   };
 
Index: code/trunk/src/network/GameStateClient.cc
===================================================================
--- code/trunk/src/network/GameStateClient.cc	(revision 871)
+++ code/trunk/src/network/GameStateClient.cc	(revision 1021)
@@ -40,8 +40,13 @@
 
   bool GameStateClient::pushGameState(GameStateCompressed *compstate) {
+    GameState *gs;
     if(compstate->diffed)
-      return loadSnapshot(decode(reference, *compstate));
+      gs = decode(reference, compstate);
     else
-      return loadSnapshot(decode(*compstate));
+      gs = decode(compstate);
+    if(gs)
+      return loadSnapshot(gs);
+    COUT(4) << "could not use gamestate sent by server" << std::endl;
+    return false;
   }
 
@@ -61,12 +66,12 @@
   * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot)
   */
-  bool GameStateClient::loadSnapshot(GameState state) {
-    unsigned char *data=state.data;
-    std::cout << "loadSnapshot: loading gs: " << state.id << std::endl;
+  bool GameStateClient::loadSnapshot(GameState *state) {
+    unsigned char *data=state->data;
+    COUT(4) << "loadSnapshot: loading gs: " << state->id << std::endl;
     // get the start of the Synchronisable list
     orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
     syncData sync;
     // loop as long as we have some data ;)
-    while(data < state.data+state.size){
+    while(data < state->data+state->size){
       // prepare the syncData struct
       sync.length = (int)*data;
@@ -82,10 +87,11 @@
         // bad luck ;)
         // delete the synchronisable (obviously seems to be deleted on the server)
-        while(it && it->objectID!=sync.objectID){
+        while(it && it->objectID!=sync.objectID)
           removeObject(it);
-        }
-        if(it==0){
-          std::cout << "classid: " << sync.classID << ", name: " << ID(sync.classID)->getName() << std::endl;
-          Synchronisable *no = (Synchronisable*)(ID(sync.classID)->fabricate());
+        
+        
+        if(!it){
+          COUT(5) << "classid: " << sync.classID << ", name: " << ID((unsigned int) sync.classID)->getName() << std::endl;
+          Synchronisable *no = (Synchronisable*)(ID((unsigned int) sync.classID)->fabricate());
           no->objectID=sync.objectID;
           no->classID=sync.classID;
@@ -93,5 +99,5 @@
           // update data and create object/entity...
           if( !no->updateData(sync) && !no->create() )
-            COUT(0) << "We couldn't create/update the object: " << sync.objectID << std::endl;
+            COUT(1) << "We couldn't create/update the object: " << sync.objectID << std::endl;
           ++it;
         }
@@ -99,5 +105,5 @@
         // we have our object
         if(! it->updateData(sync))
-          std::cout << "We couldn't update objectID: " \
+          COUT(1) << "We couldn't update objectID: " \
           << sync.objectID << "; classID: " << sync.classID << std::endl;
       }
@@ -108,20 +114,20 @@
   }
 
-  GameState GameStateClient::diff(GameState a, GameState b) {
-    unsigned char *ap = a.data, *bp = b.data;
+  GameState *GameStateClient::undiff(GameState *a, GameState *b) {
+    unsigned char *ap = a->data, *bp = b->data;
     int of=0; // pointers offset
     int dest_length=0;
-    if(a.size>=b.size)
-      dest_length=a.size;
+    if(a->size>=b->size)
+      dest_length=a->size;
     else
-      dest_length=b.size;
+      dest_length=b->size;
     unsigned char *dp = (unsigned char *)malloc(dest_length*sizeof(unsigned char));
-    while(of<a.size && of<b.size){
+    while(of<a->size && of<b->size){
       *(dp+of)=*(ap+of)^*(bp+of); // do the xor
       ++of;
     }
-    if(a.size!=b.size){ // do we have to fill up ?
+    if(a->size!=b->size){ // do we have to fill up ?
       unsigned char n=0;
-      if(a.size<b.size){
+      if(a->size<b->size){
         while(of<dest_length){
           *(dp+of)=n^*(bp+of);
@@ -137,11 +143,15 @@
     // should be finished now
     // FIXME: is it true or false now? (struct has changed, producing warnings)
-    GameState r = {b.id, dest_length, true, dp};
+    GameState *r = new GameState;
+    r->id = b->id;
+    r->size = dest_length;
+    r->diffed = false;
+    r->data = dp;
     return r;
   }
 
-  GameState GameStateClient::decompress(GameStateCompressed a) {
-    int normsize = a.normsize;
-    int compsize = a.compsize;
+  GameState *GameStateClient::decompress(GameStateCompressed *a) {
+    int normsize = a->normsize;
+    int compsize = a->compsize;
     int bufsize;
     if(normsize < compsize)
@@ -154,29 +164,32 @@
     //std::cout << "gamestateclient" << std::endl;
     //std::cout << "normsize " << a.normsize << " compsize " << a.compsize << " " << bufsize << std::endl;
-    retval = uncompress( dest, &length, a.data, (uLong)compsize );
+    retval = uncompress( dest, &length, a->data, (uLong)compsize );
     //std::cout << "length " << length << std::endl;
     switch ( retval ) {
-      case Z_OK: std::cout << "successfully decompressed" << std::endl; break;
-      case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break;
-      case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break;
-      case Z_DATA_ERROR: std::cout << "data corrupted" << std::endl; break;
+      case Z_OK: COUT(4) << "successfully decompressed" << std::endl; break;
+      case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return NULL;
+      case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return NULL;
+      case Z_DATA_ERROR: COUT(2) << "data corrupted" << std::endl; return NULL;
     }
 
-    GameState gamestate;
-    gamestate.id = a.id;
-    gamestate.size = normsize;
-    gamestate.data = dest;
-    gamestate.diffed = a.diffed;
+    GameState *gamestate = new GameState;
+    gamestate->id = a->id;
+    gamestate->size = normsize;
+    gamestate->data = dest;
+    gamestate->diffed = a->diffed;
+    
+    delete a->data; //delete compressed data
+    delete a; //we do not need the old (struct) gamestate anymore
 
     return gamestate;
   }
 
-  GameState GameStateClient::decode(GameState a, GameStateCompressed x) {
-    GameState t = decompress(x);
-    return diff(a, t);
+  GameState *GameStateClient::decode(GameState *a, GameStateCompressed *x) {
+    GameState *t = decompress(x);
+    return undiff(a, t);
   }
 
-  GameState GameStateClient::decode(GameStateCompressed x) {
-    GameState t = decompress(x);
+  GameState *GameStateClient::decode(GameStateCompressed *x) {
+    GameState *t = decompress(x);
     return t;
   }
Index: code/trunk/src/network/GameStateClient.h
===================================================================
--- code/trunk/src/network/GameStateClient.h	(revision 871)
+++ code/trunk/src/network/GameStateClient.h	(revision 1021)
@@ -25,12 +25,12 @@
     bool pushGameState(GameStateCompressed *compstate);
   private:
-    bool loadSnapshot(GameState state);
-    GameState diff(GameState a, GameState b);
-    GameState decompress(GameStateCompressed a);
-    GameState decode(GameState a, GameStateCompressed x);
-    GameState decode(GameStateCompressed x);
+    bool loadSnapshot(GameState *state);
+    GameState *undiff(GameState *a, GameState *b);
+    GameState *decompress(GameStateCompressed *a);
+    GameState *decode(GameState *a, GameStateCompressed *x);
+    GameState *decode(GameStateCompressed *x);
     void removeObject(orxonox::Iterator<Synchronisable> &it);
 
-    GameState reference;
+    GameState *reference;
   };
 
Index: code/trunk/src/network/GameStateManager.cc
===================================================================
--- code/trunk/src/network/GameStateManager.cc	(revision 871)
+++ code/trunk/src/network/GameStateManager.cc	(revision 1021)
@@ -43,4 +43,5 @@
 
 #include "core/CoreIncludes.h"
+
 #include "ClientInformation.h"
 #include "Synchronisable.h"
@@ -65,7 +66,7 @@
   }
 
-  GameStateCompressed GameStateManager::popGameState(int clientID) {
+  GameStateCompressed *GameStateManager::popGameState(int clientID) {
     int gID = head_->findClient(clientID)->getGamestateID();
-    std::cout << "popgamestate: sending gstate id: " << id << "diffed from: " << gID << std::endl;
+    COUT(4) << "popgamestate: sending gstate id: " << id << "diffed from: " << gID << std::endl;
     if(gID!=GAMESTATEID_INITIAL){
       GameState *client = gameStateMap[gID];
@@ -100,9 +101,9 @@
     GameState *retval=new GameState; //return value
     retval->id=id++;
-    std::cout << "producing gamestate with id: " << retval->id << std::endl;
+    COUT(4) << "producing gamestate with id: " << retval->id << std::endl;
     // reserve a little memory and increase it later on
-    //COUT(2) << "mallocing" << std::endl;
+    COUT(5) << "mallocing" << std::endl;
     retval->data = (unsigned char*)malloc(memsize);
-    //COUT(2) << "malloced" << std::endl;
+    COUT(5) << "malloced" << std::endl;
 
     // offset of memory functions
@@ -113,5 +114,5 @@
       //get size of the synchronisable
       tempsize=it->getSize();
-      //std::cout << "size of temp gamestate: " << tempsize << std::endl;
+//       COUT(5) << "size of temp gamestate: " << tempsize << std::endl;
       //COUT(2) << "size of synchronisable: " << tempsize << std::endl;
       // add place for data and 3 ints (length,classid,objectid)
@@ -137,22 +138,23 @@
       offset+=tempsize+3*sizeof(int);
     }
+    COUT(5) << "Gamestate size: " << totalsize << std::endl;
     retval->size=totalsize;
     return retval;
   }
 
-  GameStateCompressed GameStateManager::encode(GameState *a, GameState *b) {
+  GameStateCompressed *GameStateManager::encode(GameState *a, GameState *b) {
     //GameState r = diff(a,b);
     //r.diffed = true;
-    GameState r = *b;
-    r.diffed = false;
-    return compress_(&r);
-  }
-
-  GameStateCompressed GameStateManager::encode(GameState *a) {
+    GameState *r = b;
+    r->diffed = false;
+    return compress_(r);
+  }
+
+  GameStateCompressed *GameStateManager::encode(GameState *a) {
     a->diffed=false;
     return compress_(a);
   }
 
-  GameState GameStateManager::diff(GameState *a, GameState *b) {
+  GameState *GameStateManager::diff(GameState *a, GameState *b) {
     unsigned char *ap = a->data, *bp = b->data;
     int of=0; // pointers offset
@@ -181,12 +183,15 @@
       }
     }
-    // should be finished now
-    // FIXME: is it true or false now? (struct has changed, producing warnings)
-    GameState r = {b->id, dest_length, true, dp};
+    
+    GameState *r = new GameState;
+    r->id = b->id;
+    r->size = dest_length;
+    r->diffed = true;
+    r->data = dp;
     return r;
   }
 
-  GameStateCompressed GameStateManager::compress_(GameState *a) {
-    //COUT(2) << "compressing gamestate" << std::endl;
+  GameStateCompressed *GameStateManager::compress_(GameState *a) {
+    COUT(5) << "compressing gamestate" << std::endl;
     int size = a->size;
     uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
@@ -198,18 +203,21 @@
 
     switch ( retval ) {
-      case Z_OK: std::cout << "successfully compressed" << std::endl; break;
-      case Z_MEM_ERROR: std::cout << "not enough memory available" << std::endl; break;
-      case Z_BUF_ERROR: std::cout << "not enough memory available in the buffer" << std::endl; break;
-      case Z_DATA_ERROR: std::cout << "decompress: data corrupted" << std::endl; break;
-    }
-
-    GameStateCompressed compressedGamestate;
-    compressedGamestate.compsize = buffer;
-    //std::cout << "compressedGamestate.compsize = buffer; " << buffer << std::endl;
-    compressedGamestate.normsize = size;
-    //std::cout << "compressedGamestate.normsize = size; " << size << std::endl;
-    compressedGamestate.id = a->id;
-    compressedGamestate.data = dest;
-    compressedGamestate.diffed = a->diffed;
+      case Z_OK: COUT(5) << "successfully compressed" << std::endl; break;
+      case Z_MEM_ERROR: COUT(1) << "not enough memory available in gamestate.compress" << std::endl; 
+      return NULL;
+      case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer in gamestate.compress" << std::endl;
+      return NULL;
+      case Z_DATA_ERROR: COUT(2) << "decompress: data corrupted in gamestate.compress" << std::endl;
+      return NULL;
+    }
+
+    GameStateCompressed *compressedGamestate = new GameStateCompressed;
+    compressedGamestate->compsize = buffer;
+//     std::cout << "compressedGamestate.compsize = buffer; " << buffer << std::endl;
+    compressedGamestate->normsize = size;
+//     std::cout << "compressedGamestate.normsize = size; " << size << std::endl;
+    compressedGamestate->id = a->id;
+    compressedGamestate->data = dest;
+    compressedGamestate->diffed = a->diffed;
 
     return compressedGamestate;
Index: code/trunk/src/network/GameStateManager.h
===================================================================
--- code/trunk/src/network/GameStateManager.h	(revision 871)
+++ code/trunk/src/network/GameStateManager.h	(revision 1021)
@@ -43,13 +43,13 @@
     ~GameStateManager();
     void update();
-    GameStateCompressed popGameState(int clientID);
+    GameStateCompressed *popGameState(int clientID);
     void ackGameState(int clientID, int gamestateID);
     int id;
   private:
     GameState *getSnapshot(int id);
-    GameStateCompressed encode(GameState *a, GameState *b);
-    GameStateCompressed encode(GameState *a);
-    GameState diff(GameState *a, GameState *b);
-    GameStateCompressed compress_(GameState *a);
+    GameStateCompressed *encode(GameState *a, GameState *b);
+    GameStateCompressed *encode(GameState *a);
+    GameState *diff(GameState *a, GameState *b);
+    GameStateCompressed *compress_(GameState *a);
     bool deleteUnusedGameState(int gamestateID);
 
Index: code/trunk/src/network/NetworkPrereqs.h
===================================================================
--- code/trunk/src/network/NetworkPrereqs.h	(revision 871)
+++ code/trunk/src/network/NetworkPrereqs.h	(revision 1021)
Index: code/trunk/src/network/PacketDecoder.cc
===================================================================
--- code/trunk/src/network/PacketDecoder.cc	(revision 871)
+++ code/trunk/src/network/PacketDecoder.cc	(revision 1021)
@@ -38,8 +38,8 @@
 #include "PacketTypes.h"
 #include "PacketManager.h"
+#include "orxonox/core/Debug.h"
 
 namespace network
 {
-  using namespace std;
 
   PacketDecoder::PacketDecoder(){}
@@ -52,8 +52,8 @@
   {
     int client = clientId;
-    cout << "clientId: " << client << endl; //control cout, not important, just debugging info
+    COUT(5) << "clientId: " << client << std::endl; //control cout, not important, just debugging info
     int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
-    std::cout << "packet id: " << id << std::endl;
-    std::cout << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
+    COUT(5) << "packet id: " << id << std::endl;
+//     COUT(5) << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
     switch( id ) {
   case ACK:
@@ -93,5 +93,5 @@
 
 
-    std::cout << "got ack id: " << a->id << std::endl;
+    COUT(5) << "got ack id: " << a->id << std::endl;
     processAck( a, clientId ); //debug info
 
@@ -144,37 +144,44 @@
   void PacketDecoder::gstate( ENetPacket* packet )
   {
-    GameStateCompressed* currentState = new GameStateCompressed;
+    GameStateCompressed* currentState = NULL;
+    currentState = new GameStateCompressed;
+    if(currentState == NULL){
+      COUT(3) << "could not generate new GameStateCompressed" << std::endl;
+      return;
+    }
     //since it's not alowed to use void* for pointer arithmetic
-    unsigned char* data = (unsigned char*)packet->data;
+    unsigned char* data = (unsigned char *)(packet->data);
     //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int )
     //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
-    currentState->id = (int)*(data+sizeof(int));
-    std::cout << "id: " << currentState->id << std::endl;
+    //currentState->id = *((int *)packet->data+sizeof(int));
+    memcpy( (void*)&(currentState->id), (const void*)(packet->data+1*sizeof( int )), sizeof( int) );
+    COUT(5) << "decoder: received gs id: " << currentState->id << std::endl;
+//     std::cout << "id: " << currentState->id << std::endl;
     //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
     //position of the data stream, data+2*sizeof( int )
-    memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
+    memcpy( (void*)&(currentState->compsize), (const void*)(packet->data+2*sizeof( int )), sizeof( int) );
     //currentState->compsize = (int)*(data+2*sizeof(int));
-    std::cout << "compsize: " << currentState->compsize << std::endl;
+//     std::cout << "compsize: " << currentState->compsize << std::endl;
     //size of uncompressed data
-    memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
+    memcpy( (void*)&(currentState->normsize), (const void*)(packet->data+3*sizeof( int )), sizeof( int ) );
     //currentState->normsize = (int)*(data+3*sizeof(int));
-    std::cout << "normsize. " << currentState->normsize << std::endl;
+//     std::cout << "normsize. " << currentState->normsize << std::endl;
     //since the packetgenerator was changed, due to a new parameter, change this function too
-    memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
+    memcpy( (void*)&(currentState->diffed), (const void*)(packet->data+4*sizeof(int)), sizeof(bool));
     //currentState->diffed = (bool)*(data+4*sizeof(int));
-    std::cout << "diffed: " << currentState->diffed << std::endl;
+//     std::cout << "diffed: " << currentState->diffed << std::endl;
     //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
+    if(currentState->compsize==0)
+      COUT(2) << "compsize is 0" << std::endl;
     currentState->data = (unsigned char*)(malloc( currentState->compsize ));
     if(currentState->data==NULL)
-      std::cout << "memory leak" << std::endl;
+      COUT(2) << "Gamestatepacket-decoder: memory leak" << std::endl;
     //copy the GameStateCompressed data
     //std::cout << "packet size (enet): " << packet->dataLength << std::endl;
     //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;
-    memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
-
-    //clean memory
-    enet_packet_destroy( packet );
-    //run processGameStateCompressed
-    //TODO: not yet implemented!
+    memcpy( (void*)(currentState->data), (const void*)(packet->data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
+
+    //clean memory
+    enet_packet_destroy( packet );
     processGamestate(currentState);
   }
@@ -189,5 +196,5 @@
     void *data  = (void *)cid->message;
     memcpy(data, (const void*)(packet->data+3*sizeof(int)), cid->length);
-    std::cout << "classid: " << cid->clid << ", name: " << cid->message << std::endl;
+    COUT(4) << "classid: " << cid->clid << ", name: " << cid->message << std::endl;
     enet_packet_destroy( packet );
     processClassid(cid);
@@ -223,18 +230,18 @@
   void PacketDecoder::printAck( ack* data )
   {
-    cout << "data id: " << data->id << endl;
-    cout << "data:    " << data->a << endl;
+    COUT(5) << "data id: " << data->id << std::endl;
+    COUT(5) << "data:    " << data->a << std::endl;
   }
 
   void PacketDecoder::printMouse( mouse* data )
   {
-    cout << "data id: " << data->id << endl;
-    cout << "data:    " << data->x << " " << data->y << endl;
+    COUT(5) << "data id: " << data->id << std::endl;
+    COUT(5) << "data:    " << data->x << " " << data->y << std::endl;
   }
 
   void PacketDecoder::printKey( keyboard* data )
   {
-    cout << "data id: " << data->id << endl;
-    cout << "data:    " << (char)data->press << endl;
+    COUT(5) << "data id: " << data->id << std::endl;
+    COUT(5) << "data:    " << (char)data->press << std::endl;
   }
 
@@ -242,21 +249,21 @@
   {
     if(clientId!=CLIENTID_CLIENT)
-      cout << "client: " << clientId << endl;
-    cout << "data id: " << data->id << endl;
-    cout << "data:    " << data->message << endl;
+      COUT(5) << "client: " << clientId << std::endl;
+    COUT(5) << "data id: " << data->id << std::endl;
+    COUT(5) << "data:    " << data->message << std::endl;
   }
 
   void PacketDecoder::printGamestate( GameStateCompressed* data )
   {
-    cout << "id of GameStateCompressed:   " << data->id << endl;
-    cout << "size of GameStateCompressed: " << data->compsize << endl;
+    COUT(5) << "id of GameStateCompressed:   " << data->id << std::endl;
+    COUT(5) << "size of GameStateCompressed: " << data->compsize << std::endl;
   }
 
   void PacketDecoder::printClassid( classid *cid)
   {
-    cout << "id of classid:    " << cid->id << endl;
-    cout << "size of classid:  " << cid->length << endl;
-    cout << "ID of classid:    " << cid->clid <<endl;
-    cout << "data of classid:  " << cid->message <<endl;
+    COUT(5) << "id of classid:    " << cid->id << std::endl;
+    COUT(5) << "size of classid:  " << cid->length << std::endl;
+    COUT(5) << "ID of classid:    " << cid->clid << std::endl;
+    COUT(5) << "data of classid:  " << cid->message << std::endl;
   }
 
Index: code/trunk/src/network/PacketGenerator.cc
===================================================================
--- code/trunk/src/network/PacketGenerator.cc	(revision 871)
+++ code/trunk/src/network/PacketGenerator.cc	(revision 1021)
@@ -50,5 +50,5 @@
   ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
   {
-    std::cout << "generating new acknowledgement, id: " << state << std::endl;
+    COUT(4) << "generating new acknowledgement, id: " << state << std::endl;
     ack* ackreq = new ack;
     ackreq->id = ACK;
@@ -63,5 +63,5 @@
   ENetPacket* PacketGenerator::mousem( double x, double y, int reliable )
   {
-    std::cout << "generating new mouse" << std::endl;
+    COUT(4) << "generating new mouse" << std::endl;
     mouse* mousemove = new mouse;
     mousemove->id = MOUSE;
@@ -77,5 +77,5 @@
   ENetPacket* PacketGenerator::keystrike( char press, int reliable )
   {
-    std::cout << "generating new keyboard" << std::endl;
+    COUT(4) << "generating new keyboard" << std::endl;
     keyboard* key = new keyboard;
     key->id = KEYBOARD;
Index: code/trunk/src/network/PacketManager.h
===================================================================
--- code/trunk/src/network/PacketManager.h	(revision 871)
+++ code/trunk/src/network/PacketManager.h	(revision 1021)
@@ -4,4 +4,6 @@
 #include <string>
 #include <enet/enet.h>
+
+#include "core/CoreIncludes.h"
 
 #include "NetworkPrereqs.h"
@@ -65,5 +67,5 @@
     virtual void processGamestate(GameStateCompressed *state);
     virtual void processAck( ack *data, int clientID);
-    void processClassid( classid *cid);
+    virtual void processClassid( classid *cid);
     //virtual void processAck( ack *data);
 
Index: code/trunk/src/network/Server.cc
===================================================================
--- code/trunk/src/network/Server.cc	(revision 871)
+++ code/trunk/src/network/Server.cc	(revision 1021)
@@ -18,4 +18,5 @@
 #include "ClientInformation.h"
 //#include "NetworkFrameListener.h"
+#include "util/Sleep.h"
 #include "Server.h"
 
@@ -112,4 +113,6 @@
     processQueue();
     updateGamestate();
+
+    sleep(1); // TODO remove
     return;
   }
@@ -134,5 +137,6 @@
     gamestates->update();
     //std::cout << "updated gamestate, sending it" << std::endl;
-    sendGameState();
+    //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
+      sendGameState();
     //std::cout << "sent gamestate" << std::endl;
   }
@@ -142,5 +146,5 @@
   */
   bool Server::sendGameState() {
-    std::cout << "starting gamestate" << std::endl;
+    COUT(5) << "starting sendGameState" << std::endl;
     ClientInformation *temp = clients;
     bool added=false;
@@ -151,13 +155,17 @@
       }
       if( !(temp->getSynched()) ){
-        std::cout << "not sending gamestate" << std::endl;
+        COUT(5) << "not sending gamestate" << std::endl;
         temp=temp->next();
         continue;
       }
-      std::cout << "doing gamestate" << std::endl;
+      COUT(5) << "doing gamestate gamestate preparation" << std::endl;
       int gid = temp->getGamestateID();
       int cid = temp->getID();
-      std::cout << "server, got acked ID: " << gid << std::endl;
-      GameStateCompressed *gs = &(gamestates->popGameState(cid)); // FIXME: taking address of temporary, check if correct
+      COUT(5) << "server, got acked (gamestate) ID: " << gid << std::endl;
+      GameStateCompressed *gs = gamestates->popGameState(cid);
+      if(gs==NULL){
+        COUT(2) << "could not generate gamestate" << std::endl;
+        return false;
+      }
       //std::cout << "adding gamestate" << std::endl;
       connection->addPacket(packet_gen.gstate(gs), cid);
@@ -168,9 +176,10 @@
     if(added)
       return connection->sendPackets();
-    else
-      return false;
+    COUT(5) << "had no gamestates to send" << std::endl;
+    return false;
   }
 
   void Server::processAck( ack *data, int clientID) {
+    COUT(5) << "processing ack from client: " << clientID << "; ack-id: " << data->id << std::endl;
     clients->findClient(clientID)->setGamestateID(data->a);
   }
Index: code/trunk/src/network/Server.h
===================================================================
--- code/trunk/src/network/Server.h	(revision 871)
+++ code/trunk/src/network/Server.h	(revision 1021)
@@ -16,6 +16,10 @@
 #include <string>
 
+#include "NetworkPrereqs.h"
+
+#include "core/Tickable.h"
 #include "PacketManager.h"
-#include "NetworkPrereqs.h"
+
+
 
 namespace network
@@ -25,5 +29,5 @@
   * It implements all functions necessary for a Server
   */
-  class _NetworkExport Server : public PacketDecoder{
+  class _NetworkExport Server : public PacketDecoder, public orxonox::Tickable{
   public:
     Server();
Index: code/trunk/src/network/Synchronisable.h
===================================================================
--- code/trunk/src/network/Synchronisable.h	(revision 871)
+++ code/trunk/src/network/Synchronisable.h	(revision 1021)
@@ -56,5 +56,5 @@
     int getSize();
     bool updateData(syncData vars);
-    void registerAllVariables();
+    virtual void registerAllVariables()=0;
     virtual bool create()=0;
   protected:
Index: code/trunk/src/network/dummyclient3.cc
===================================================================
--- code/trunk/src/network/dummyclient3.cc	(revision 871)
+++ code/trunk/src/network/dummyclient3.cc	(revision 1021)
@@ -13,8 +13,8 @@
   network::PacketGenerator pck;
   const int PORT = 55556;
-  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
+  COUT(0) << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
   std::string str;
   std::getline(std::cin, str);
-  std::cout << "You entered: " << str << std::endl;
+  COUT(3) << "You entered: " << str << std::endl;
   if(str.compare("")==0)
     str="127.0.0.1";
@@ -22,6 +22,6 @@
   Client client( str, PORT );
   if ( client.establishConnection() )
-    std::cout << "connection established" << std::endl;
-  else std::cout << "problems establishing connection" << std::endl;
+    COUT(3) << "connection established" << std::endl;
+  else COUT(0) << "problems establishing connection" << std::endl;
   char message[10000];
   char signs[] = "abcdefghijklmnopqrstuvwxy";
