Index: code/branches/FICN/src/network/Client.cc
===================================================================
--- code/branches/FICN/src/network/Client.cc	(revision 619)
+++ code/branches/FICN/src/network/Client.cc	(revision 620)
@@ -189,5 +189,5 @@
 
   void Client::processGamestate( GameStateCompressed *data){
-    gamestate.pushGameState(*data);
+    gamestate.pushGameState(data);
     client_connection.addPacket(pck_gen.acknowledgement(data->id));
     client_connection.sendPackets();
Index: code/branches/FICN/src/network/ClientConnection.cc
===================================================================
--- code/branches/FICN/src/network/ClientConnection.cc	(revision 619)
+++ code/branches/FICN/src/network/ClientConnection.cc	(revision 620)
@@ -148,5 +148,5 @@
     while(!quit){
       //std::cout << "connection loop" << std::endl;
-      if(enet_host_service(client, &event, NETWORK_WAIT_TIMEOUT)<0){
+      if(enet_host_service(client, &event, NETWORK_CLIENT_TIMEOUT)<0){
         // we should never reach this point
         quit=true;
@@ -157,5 +157,5 @@
       case ENET_EVENT_TYPE_CONNECT:
       case ENET_EVENT_TYPE_RECEIVE:
-        std::cout << "got packet" << std::endl;
+        //std::cout << "got packet" << std::endl;
         processData(&event);
         break;
@@ -180,5 +180,5 @@
     ENetEvent event;
     enet_peer_disconnect(server, 0);
-    while(enet_host_service(client, &event, NETWORK_WAIT_TIMEOUT) > 0){
+    while(enet_host_service(client, &event, NETWORK_CLIENT_TIMEOUT) > 0){
       switch (event.type)
       {
@@ -204,5 +204,5 @@
       return false;
     // handshake
-    if(enet_host_service(client, &event, NETWORK_WAIT_TIMEOUT)>0 && event.type == ENET_EVENT_TYPE_CONNECT){
+    if(enet_host_service(client, &event, NETWORK_CLIENT_TIMEOUT)>0 && event.type == ENET_EVENT_TYPE_CONNECT){
       established=true;
       return true;
@@ -213,5 +213,5 @@
 
   bool ClientConnection::processData(ENetEvent *event){
-    std::cout << "got packet, pushing to queue" << std::endl;
+    //std::cout << "got packet, pushing to queue" << std::endl;
     // just add packet to the buffer
     // this can be extended with some preprocessing
Index: code/branches/FICN/src/network/ClientConnection.h
===================================================================
--- code/branches/FICN/src/network/ClientConnection.h	(revision 619)
+++ code/branches/FICN/src/network/ClientConnection.h	(revision 620)
@@ -28,5 +28,5 @@
 #define NETWORK_PORT 55556
 #define NETWORK_CLIENT_MAX_CONNECTIONS 5
-#define NETWORK_WAIT_TIMEOUT 5
+#define NETWORK_CLIENT_TIMEOUT 5
 #define NETWORK_SEND_WAIT 5
 #define NETWORK_CLIENT_CHANNELS 2
Index: code/branches/FICN/src/network/ClientInformation.cc
===================================================================
--- code/branches/FICN/src/network/ClientInformation.cc	(revision 619)
+++ code/branches/FICN/src/network/ClientInformation.cc	(revision 620)
@@ -190,7 +190,7 @@
 ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards){
   ClientInformation *temp = this;
+  if (temp->head)
+    temp=temp->next();
   while(temp!=0 && temp->getID()!=clientID){
-    if (temp->head)
-      continue;
     temp = temp->next();
   }
Index: code/branches/FICN/src/network/ConnectionManager.cc
===================================================================
--- code/branches/FICN/src/network/ConnectionManager.cc	(revision 619)
+++ code/branches/FICN/src/network/ConnectionManager.cc	(revision 620)
@@ -200,4 +200,5 @@
           break;
         case ENET_EVENT_TYPE_DISCONNECT:
+          std::cout << "disconnecting client" << std::endl;
           delete head_->findClient(&(event.peer->address));
           temp = temp->next();
@@ -227,5 +228,8 @@
   bool ConnectionManager::addClient(ENetEvent *event){
     ClientInformation *temp = head_->insertBack(new ClientInformation);
-    temp->setID(temp->prev()->getID()+1);
+    if(temp->prev()->head)
+      temp->setID(1);
+    else
+      temp->setID(temp->prev()->getID()+1);
     temp->setPeer(event->peer);
     std::cout << "added client id: " << temp->prev()->getID() << std::endl;
Index: code/branches/FICN/src/network/GameStateClient.cc
===================================================================
--- code/branches/FICN/src/network/GameStateClient.cc	(revision 619)
+++ code/branches/FICN/src/network/GameStateClient.cc	(revision 620)
@@ -39,9 +39,9 @@
 }
 
-bool GameStateClient::pushGameState(GameStateCompressed compstate){
-  if(compstate.diffed)
-    return loadSnapshot(decode(reference, compstate));
+bool GameStateClient::pushGameState(GameStateCompressed *compstate){
+  if(compstate->diffed)
+    return loadSnapshot(decode(reference, *compstate));
   else
-    return loadSnapshot(decode(compstate));
+    return loadSnapshot(decode(*compstate));
 }
 
@@ -65,4 +65,5 @@
 {
   unsigned char *data=state.data;
+  std::cout << "loadSnapshot: loading gs: " << state.id << std::endl;
   // get the start of the Synchronisable list
   orxonox::Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();
@@ -71,9 +72,9 @@
   while(data < state.data+state.size){
     // prepare the syncData struct
-    sync.length = *(int *)data;
+    sync.length = (int)*data;
     data+=sizeof(int);
-    sync.objectID = *(int *)data;
+    sync.objectID = (int)*data;
     data+=sizeof(int);
-    sync.classID = *(int *)data;
+    sync.classID = (int)*data;
     data+=sizeof(int);
     sync.data = data;
@@ -150,5 +151,5 @@
 
   switch ( retval ) {
-    case Z_OK: std::cout << "successfully compressed" << std::endl; break;
+    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;
Index: code/branches/FICN/src/network/GameStateClient.h
===================================================================
--- code/branches/FICN/src/network/GameStateClient.h	(revision 619)
+++ code/branches/FICN/src/network/GameStateClient.h	(revision 620)
@@ -28,5 +28,5 @@
   GameStateClient();
   ~GameStateClient();
-  bool pushGameState(GameStateCompressed compstate);
+  bool pushGameState(GameStateCompressed *compstate);
 private:
   bool loadSnapshot(GameState state);
Index: code/branches/FICN/src/network/GameStateManager.cc
===================================================================
--- code/branches/FICN/src/network/GameStateManager.cc	(revision 619)
+++ code/branches/FICN/src/network/GameStateManager.cc	(revision 620)
@@ -61,12 +61,15 @@
 GameStateCompressed GameStateManager::popGameState(int clientID){
   int gID = head_->findClient(clientID)->getGamestateID();
+  std::cout << "popgamestate: sending gstate id: " << gID << std::endl;
   if(gID!=GAMESTATEID_INITIAL){
     GameState *client = gameStateMap[gID];
     GameState *server = reference;
     return encode(client, server);
-  }
-  GameState *server = reference;
-  return encode(server);
-  // return an undiffed gamestate and set appropriate flags
+  } else {
+    GameState *server = reference;
+    head_->findClient(clientID)->setGamestateID(id);
+    return encode(server);
+    // return an undiffed gamestate and set appropriate flags
+  }
 }
 
@@ -101,4 +104,5 @@
   // go through all Synchronisables
   for(it = orxonox::ObjectList<Synchronisable>::start(); it != 0; ++it){
+    //std::cout << "gamestatemanager: in for loop" << std::endl;
     //get size of the synchronisable
     tempsize=it->getSize();
@@ -127,6 +131,8 @@
 
 GameStateCompressed GameStateManager::encode(GameState *a, GameState *b){
-    GameState r = diff(a,b);
-  r.diffed = true;
+  //GameState r = diff(a,b);
+  //r.diffed = true;
+  GameState r = *b;
+  r.diffed = false;
   return compress_(&r);
 }
@@ -170,5 +176,5 @@
 
 GameStateCompressed GameStateManager::compress_(GameState *a) {
-  COUT(2) << "compressing gamestate" << std::endl;
+  //COUT(2) << "compressing gamestate" << std::endl;
   int size = a->size;
   uLongf buffer = (uLongf)((a->size + 12)*1.01)+1;
@@ -181,5 +187,5 @@
   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_DATA_ERROR: std::cout << "decompress: data corrupted" << std::endl; break;
   }
 
Index: code/branches/FICN/src/network/PacketDecoder.cc
===================================================================
--- code/branches/FICN/src/network/PacketDecoder.cc	(revision 619)
+++ code/branches/FICN/src/network/PacketDecoder.cc	(revision 620)
@@ -88,8 +88,9 @@
 	*a = *(ack*)packet->data; //press pattern of ack on new data
 
-	//clean memory
-	enet_packet_destroy( packet );
-
-	printAck( a ); //debug info
+
+  processAck( a, clientId ); //debug info
+  
+  //clean memory
+  enet_packet_destroy( packet );
 }
 
@@ -143,15 +144,23 @@
 	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 ) );
+  //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
+  currentState->id = (int)*(data+sizeof(int));
 	//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*)(data+2*sizeof( int )), sizeof( int) );
+  currentState->compsize = (int)*(data+2*sizeof(int));
 	//size of uncompressed data
-	memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
+// 	memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
+  currentState->normsize = (int)*(data+3*sizeof(int));
 	//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*)(data+4*sizeof(int)), sizeof(bool));
+  currentState->diffed = (bool)*(data+4*sizeof(int));
 	//since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
 	currentState->data = (unsigned char*)(malloc( currentState->compsize ));
+  if(currentState->data==NULL)
+    std::cout << "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 );
 
@@ -160,5 +169,5 @@
   //run processGameStateCompressed
   //TODO: not yet implemented!
-  //processGamestate(currentState);
+  processGamestate(currentState);
 }
 
@@ -181,4 +190,8 @@
 }
 
+void PacketDecoder::processGamestate( GameStateCompressed *state ){
+  
+}
+
 void PacketDecoder::processClassid( classid *cid){
   printClassid(cid);
@@ -186,4 +199,8 @@
 }
 
+void PacketDecoder::processAck( ack *data, int clientID){
+  printAck(data);
+  return;
+}
 
 
Index: code/branches/FICN/src/network/PacketGenerator.cc
===================================================================
--- code/branches/FICN/src/network/PacketGenerator.cc	(revision 619)
+++ code/branches/FICN/src/network/PacketGenerator.cc	(revision 620)
@@ -98,21 +98,25 @@
 ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable )
 {
-	int* gid = new int;
-        *gid = GAMESTATE; //first assign the correct enet id
+	int gid = GAMESTATE; //first assign the correct enet id
 	int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
-	unsigned char* data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
-	memcpy( (void*)(data), (const void*)gid, sizeof( int ) ); //this is the enet id
-	memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id
-	//this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream
-	memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->compsize), sizeof(int));
+	unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
+  memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id
+  memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id
+  memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->compsize), sizeof(int));
+  memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int));
+  memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
+  /*(int)*(data) = gid;
+	(int)*(data+sizeof(int)) = states->id;
+  //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream
+  (int)*(data+2*sizeof(int)) = states->compsize;
 	//this is the uncompressed size of GameStateCompressed data
-	memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int));
+  (int)*(data+3*sizeof(int)) = states->normsize;
 	//since there is a new parameter inside GameStateCompressed, change this function to create packet
-	memcpy( (void*)(data+4*sizeof(int)), (const void*)states->diffed, sizeof(bool));
+  (bool)*(data+4*sizeof(int)) = states->diffed;*/
 	//place the GameStateCompressed data at the end of the enet datastream
 	memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
 	//create an enet packet with the generated bytestream
 	ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
-
+  //delete data;
 	return packet;
 }
Index: code/branches/FICN/src/network/PacketManager.h
===================================================================
--- code/branches/FICN/src/network/PacketManager.h	(revision 619)
+++ code/branches/FICN/src/network/PacketManager.h	(revision 620)
@@ -66,5 +66,6 @@
   //process data
   //two functions are note yet implemented!
-  //virtual void processGamestate(GameState *state);
+  virtual void processGamestate(GameStateCompressed *state);
+  virtual void processAck( ack *data, int clientID);
   void processClassid( classid *cid);
   //virtual void processAck( ack *data);
Index: code/branches/FICN/src/network/Server.cc
===================================================================
--- code/branches/FICN/src/network/Server.cc	(revision 619)
+++ code/branches/FICN/src/network/Server.cc	(revision 620)
@@ -144,4 +144,5 @@
       std::cout << "doing gamestate" << std::endl;
       int id = temp->getID();
+      std::cout << "server, got ID: " << id << std::endl;
       GameStateCompressed *gs = &(gamestates->popGameState(id));
       std::cout << "adding gamestate" << std::endl;
@@ -157,4 +158,7 @@
   }
   
+  void Server::processAck( ack *data, int clientID){
+    clients->findClient(clientID)->setGamestateID(data->id);
+  }
   
 }
Index: code/branches/FICN/src/network/Server.h
===================================================================
--- code/branches/FICN/src/network/Server.h	(revision 619)
+++ code/branches/FICN/src/network/Server.h	(revision 620)
@@ -18,4 +18,5 @@
 #include "ConnectionManager.h"
 #include "PacketManager.h"
+#include "PacketTypes.h"
 #include "GameStateManager.h"
 #include "ClientInformation.h"
@@ -46,4 +47,5 @@
     private:
     bool sendGameState();
+    void processAck( ack *data, int clientID);
     ConnectionManager *connection;
     GameStateManager *gamestates;
