Index: code/branches/FICN/src/network/Client.cc
===================================================================
--- code/branches/FICN/src/network/Client.cc	(revision 623)
+++ code/branches/FICN/src/network/Client.cc	(revision 624)
@@ -190,4 +190,5 @@
   void Client::processGamestate( GameStateCompressed *data){
     gamestate.pushGameState(data);
+    std::cout << "received gamestate id: " << data->id << std::endl;
     client_connection.addPacket(pck_gen.acknowledgement(data->id));
     client_connection.sendPackets();
Index: code/branches/FICN/src/network/GameStateClient.cc
===================================================================
--- code/branches/FICN/src/network/GameStateClient.cc	(revision 623)
+++ code/branches/FICN/src/network/GameStateClient.cc	(revision 624)
@@ -145,5 +145,10 @@
   int normsize = a.normsize;
   int compsize = a.compsize;
-  unsigned char* dest = (unsigned char*)malloc( normsize );
+  int bufsize;
+  if(normsize < compsize)
+    bufsize = compsize;
+  else
+    bufsize = normsize;
+  unsigned char* dest = (unsigned char*)malloc( bufsize );
   int retval;
   uLongf length=normsize;
Index: code/branches/FICN/src/network/GameStateManager.cc
===================================================================
--- code/branches/FICN/src/network/GameStateManager.cc	(revision 623)
+++ code/branches/FICN/src/network/GameStateManager.cc	(revision 624)
@@ -61,12 +61,13 @@
 GameStateCompressed GameStateManager::popGameState(int clientID){
   int gID = head_->findClient(clientID)->getGamestateID();
-  std::cout << "popgamestate: sending gstate id: " << gID << std::endl;
+  std::cout << "popgamestate: sending gstate id: " << id << "diffed from: " << gID << std::endl;
   if(gID!=GAMESTATEID_INITIAL){
     GameState *client = gameStateMap[gID];
     GameState *server = reference;
+    //head_->findClient(clientID)->setGamestateID(id);
     return encode(client, server);
   } else {
     GameState *server = reference;
-    head_->findClient(clientID)->setGamestateID(id);
+    //head_->findClient(clientID)->setGamestateID(id);
     return encode(server);
     // return an undiffed gamestate and set appropriate flags
@@ -95,4 +96,5 @@
   GameState *retval=new GameState; //return value
   retval->id=id++;
+  std::cout << "producing gamestate with id: " << retval->id << std::endl;
   // reserve a little memory and increase it later on
   //COUT(2) << "mallocing" << std::endl;
@@ -193,5 +195,5 @@
   compressedGamestate.compsize = buffer;
   compressedGamestate.normsize = size;
-  compressedGamestate.id = GAMESTATE;
+  compressedGamestate.id = a->id;
   compressedGamestate.data = dest;
   compressedGamestate.diffed = a->diffed;
Index: code/branches/FICN/src/network/GameStateManager.h
===================================================================
--- code/branches/FICN/src/network/GameStateManager.h	(revision 623)
+++ code/branches/FICN/src/network/GameStateManager.h	(revision 624)
@@ -49,4 +49,5 @@
   GameStateCompressed popGameState(int clientID);
   void ackGameState(int clientID, int gamestateID);
+  int id;
 private:
   GameState *getSnapshot(int id);
@@ -60,5 +61,4 @@
   std::map<int, int> gameStateUsed; // save the number of clients, that use the specific gamestate
   GameState *reference;
-  int id;
   ClientInformation *head_;
 };
Index: code/branches/FICN/src/network/PacketDecoder.cc
===================================================================
--- code/branches/FICN/src/network/PacketDecoder.cc	(revision 623)
+++ code/branches/FICN/src/network/PacketDecoder.cc	(revision 624)
@@ -89,4 +89,5 @@
 
 
+  std::cout << "got ack id: " << a->id << std::endl;
   processAck( a, clientId ); //debug info
   
@@ -146,14 +147,18 @@
   //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
   currentState->id = (int)*(data+sizeof(int));
+  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) );
   currentState->compsize = (int)*(data+2*sizeof(int));
+  std::cout << "compsize: " << currentState->compsize << std::endl;
 	//size of uncompressed data
 // 	memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
   currentState->normsize = (int)*(data+3*sizeof(int));
+  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));
   currentState->diffed = (bool)*(data+4*sizeof(int));
+  std::cout << "diffed: " << currentState->diffed << std::endl;
 	//since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
 	currentState->data = (unsigned char*)(malloc( currentState->compsize ));
Index: code/branches/FICN/src/network/PacketGenerator.cc
===================================================================
--- code/branches/FICN/src/network/PacketGenerator.cc	(revision 623)
+++ code/branches/FICN/src/network/PacketGenerator.cc	(revision 624)
@@ -49,5 +49,5 @@
 ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
 {
-    std::cout << "generating new acknowledgement" << std::endl;
+    std::cout << "generating new acknowledgement, id: " << state << std::endl;
 	ack* ackreq = new ack;
 	ackreq->id = ACK;
Index: code/branches/FICN/src/network/Server.cc
===================================================================
--- code/branches/FICN/src/network/Server.cc	(revision 623)
+++ code/branches/FICN/src/network/Server.cc	(revision 624)
@@ -143,10 +143,11 @@
       }
       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;
-      connection->addPacket(packet_gen.gstate(gs), id);
-      std::cout << "added gamestate" << std::endl;
+      int gid = temp->getGamestateID();
+      int cid = temp->getID();
+      std::cout << "server, got acked ID: " << gid << std::endl;
+      GameStateCompressed *gs = &(gamestates->popGameState(cid));
+      //std::cout << "adding gamestate" << std::endl;
+      connection->addPacket(packet_gen.gstate(gs), cid);
+      //std::cout << "added gamestate" << std::endl;
       added=true;
       temp=temp->next();
@@ -159,5 +160,5 @@
   
   void Server::processAck( ack *data, int clientID){
-    clients->findClient(clientID)->setGamestateID(data->id);
+    clients->findClient(clientID)->setGamestateID(data->a);
   }
   
