Index: code/branches/FICN/src/network/Client.cc
===================================================================
--- code/branches/FICN/src/network/Client.cc	(revision 412)
+++ code/branches/FICN/src/network/Client.cc	(revision 413)
@@ -22,6 +22,4 @@
     // set server address to localhost
     isConnected=false;
-    pck_gen = PacketGenerator();
-    gamestate = GameStateManager();
   }
 
@@ -33,6 +31,4 @@
   Client::Client(std::string address, int port) : client_connection(port, address){
     isConnected=false;
-    pck_gen = PacketGenerator();
-    gamestate = GameStateManager();
   }
 
@@ -44,6 +40,4 @@
   Client::Client(const char *address, int port) : client_connection(port, address){
     isConnected=false;
-    pck_gen = PacketGenerator();
-    gamestate = GameStateManager();
   }
 
@@ -147,5 +141,5 @@
   
   void Client::processGamestate( GameStateCompressed *data){
-    gamestate.loadSnapshot( *data );
+    gamestate.pushGameState(*data);
     return;
   }
@@ -153,5 +147,8 @@
   void Client::processClassid(classid *clid){
     orxonox::Identifier *id;
-    orxonox::ID(std::string(clid->message))->setNetworkID(clid->classid);
+    id=orxonox::ID(std::string(clid->message));
+    if(id!=NULL)
+      id->setNetworkID(clid->classid);
+    return;
   }
   
Index: code/branches/FICN/src/network/Client.h
===================================================================
--- code/branches/FICN/src/network/Client.h	(revision 412)
+++ code/branches/FICN/src/network/Client.h	(revision 413)
@@ -18,5 +18,5 @@
 #include "ClientConnection.h"
 #include "PacketManager.h"
-#include "GameStateManager.h"
+#include "GameStateClient.h"
 #include "orxonox/core/IdentifierIncludes.h"
 
@@ -52,5 +52,5 @@
   ClientConnection client_connection;
   PacketGenerator pck_gen;
-  GameStateManager gamestate;
+  GameStateClient gamestate;
   bool isConnected;
   
Index: code/branches/FICN/src/network/GameStateManager.cc
===================================================================
--- code/branches/FICN/src/network/GameStateManager.cc	(revision 412)
+++ code/branches/FICN/src/network/GameStateManager.cc	(revision 413)
@@ -16,4 +16,5 @@
 GameStateManager::GameStateManager()
 {
+  id=0;
 }
 
@@ -22,4 +23,17 @@
 }
 
+void GameStateManager::update(){
+  reference = getSnapshot(id++);
+  return;
+}
+
+GameStateCompressed GameStateManager::popGameState(int clientID){
+  GameState *client = clientGameState[clientID];  
+  GameState *server = &reference;
+  return encode(client, server);
+}
+
+
+
 /**
  * This function goes through the whole list of synchronisables and 
@@ -27,5 +41,5 @@
  * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list
  */
-GameStateCompressed GameStateManager::getSnapshot(int id)
+GameState GameStateManager::getSnapshot(int id)
 {
   //the size of the gamestate
@@ -63,93 +77,31 @@
   }
   retval.size=totalsize;
-  return compress(retval);
+  return retval;
 }
 
-/**
- * This function loads a Snapshort of the gamestate into the universe
- * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot)
- */
-bool GameStateManager::loadSnapshot(GameStateCompressed compstate)
-{
-  GameState state = decompress(compstate);
-  unsigned char *data=state.data;
-  // 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){
-    // prepare the syncData struct
-    sync.length = *(int *)data;
-    data+=sizeof(int);
-    sync.objectID = *(int *)data;
-    data+=sizeof(int);
-    sync.classID = *(int *)data;
-    data+=sizeof(int);
-    sync.data = data;
-    data+=sync.length;
-    
-    if(it->objectID!=sync.objectID){
-      // bad luck ;)
-      // delete the synchronisable (obviously seems to be deleted on the server)
-      while(it != 0 && it->objectID!=sync.objectID){
-        removeObject(it);
-      }
-      if(it==0){  // add the new object
-        // =================== factory command to add object
-        // can we be sure the object really was added?
-        it=orxonox::ObjectList<Synchronisable>::end();
-        it->objectID=sync.objectID;
-        it->classID=sync.classID;
-      }
-    } else {
-      // we have our object
-      if(! it->updateData(sync))
-        std::cout << "We couldn't update objectID: " \
-          << sync.objectID << "; classID: " << sync.classID << std::endl;
-    }
-    
-  }
-  
-  return true;
+
+
+GameStateCompressed GameStateManager::encode(GameState *a, GameState *b){
+  GameState r = diff(a,b);
+  return compress_(r);
 }
 
-/**
- * This function removes a Synchronisable out of the universe
- * @param it iterator of the list pointing to the object
- * @return iterator pointing to the next object in the list
- */
-void GameStateManager::removeObject(orxonox::Iterator<Synchronisable> &it){
-  orxonox::Iterator<Synchronisable> temp=it;
-  ++it;
-  delete  *temp;
-//   return it;
-}
 
-GameStateCompressed GameStateManager::encode(GameState a, GameState b){
-  GameState r = diff(a,b);
-  return compress(r);
-}
-
-GameState GameStateManager::decode(GameState a, GameStateCompressed x){
-  GameState t = decompress(x);
-  return diff(a, t);
-}
-
-GameState GameStateManager::diff(GameState a, GameState b){
-  unsigned char *ap = a.data, *bp = b.data;
+GameState GameStateManager::diff(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);
@@ -164,9 +116,9 @@
   }
   // should be finished now
-  GameState r = {b.id, dest_length, dp};
+  GameState r = {b->id, dest_length, dp};
   return r;
 }
 
-GameStateCompressed GameStateManager::compress(GameState a) {
+GameStateCompressed GameStateManager::compress_(GameState a) {
   int size = a.size;
   uLongf buffer = (uLongf)((a.size + 12)*1.01)+1;
@@ -176,11 +128,11 @@
   
   switch ( retval ) {
-  case Z_OK: cout << "successfully compressed" << endl; break;
-  case Z_MEM_ERROR: cout << "not enough memory available" << endl; break;
-  case Z_BUF_ERROR: cout << "not enough memory available in the buffer" << endl; break;
-  case Z_DATA_ERROR: cout << "data corrupted" << endl; break;
+  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 << "data corrupted" << std::endl; break;
   }
   
-  GameStateCompressed compressedGamestate = new GameStateCompressed;
+  GameStateCompressed compressedGamestate;
   compressedGamestate.compsize = buffer;
   compressedGamestate.normsize = size;
@@ -191,25 +143,5 @@
 }
 
-GameState GameStateManager::decompress(GameStateCompressed a){
-  int normsize = a.normsize;
-  int compsize = a.compsize;
-  unsigned char* dest = (unsigned char*)malloc( normsize );
-  int retval;
-  retval = uncompress( dest, &normsize, a.data, compsize );
-  
-  switch ( retval ) {
-  case Z_OK: cout << "successfully compressed" << endl; break;
-  case Z_MEM_ERROR: cout << "not enough memory available" << endl; break;
-  case Z_BUF_ERROR: cout << "not enough memory available in the buffer" << endl; break;
-  case Z_DATA_ERROR: cout << "data corrupted" << endl; break;
-  }
-  
-  GameState gamestate = new GameState;
-  gamestate.id = a.id;
-  gamestate.size = normsize;
-  gamestate.data = dest;
-  
-  return gamestate;
-}
+
 
 }
Index: code/branches/FICN/src/network/GameStateManager.h
===================================================================
--- code/branches/FICN/src/network/GameStateManager.h	(revision 412)
+++ code/branches/FICN/src/network/GameStateManager.h	(revision 413)
@@ -13,7 +13,12 @@
 #define NETWORK_GAMESTATEMANAGER_H
 
+#include <vector>
+
+#include "zlib.h"
+
 #include "Synchronisable.h"
 #include "orxonox/core/IdentifierIncludes.h"
 #include "orxonox/core/Iterator.h"
+#include "PacketManager.h"
 
 namespace network {
@@ -62,13 +67,15 @@
   GameStateManager();
   ~GameStateManager();
-  GameStateCompressed getSnapshot(int id);
-  bool loadSnapshot(GameStateCompressed state);
-  GameStateCompressed encode(GameState a, GameState b);
-  GameState decode(GameState a, GameStateCompressed x);
+  void update();
+  GameStateCompressed popGameState(int clientID);
 private:
-  void removeObject(orxonox::Iterator<Synchronisable> &it);
-  GameState diff(GameState a, GameState b);
-  GameStateCompressed compress(GameState a);
-  GameState decompress(GameStateCompressed a);
+  GameState getSnapshot(int id);
+  GameStateCompressed encode(GameState *a, GameState *b);
+  GameState diff(GameState *a, GameState *b);
+  GameStateCompressed compress_(GameState a);
+  
+  std::vector<GameState *> clientGameState;
+  GameState reference;
+  int id;
 };
 
Index: code/branches/FICN/src/network/PacketManager.h
===================================================================
--- code/branches/FICN/src/network/PacketManager.h	(revision 412)
+++ code/branches/FICN/src/network/PacketManager.h	(revision 413)
@@ -7,6 +7,6 @@
 
 //enum netowk generaly used to set the type ID of a packet
-namespace network
-{
+namespace network{
+  
 enum packet_id {
 	ACK,
@@ -32,6 +32,6 @@
 	ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
 	ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
-	ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
-	ENetPacket* gstate( GameStateCompressed* states, int reliable = ENET_PACKET_FLAG_RELIABLE );
+        ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
+        ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
         ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
 private:
@@ -116,5 +116,5 @@
 	void printKey( keyboard* data );
 	void printChat( chat* data );
-	void printGamestate( GameStateCompressed* data );
+	void printGamestate( GameStateCompressed *data );
     void printClassid( classid *cid);
 };
Index: code/branches/FICN/src/network/Server.h
===================================================================
--- code/branches/FICN/src/network/Server.h	(revision 412)
+++ code/branches/FICN/src/network/Server.h	(revision 413)
@@ -18,4 +18,5 @@
 #include "ConnectionManager.h"
 #include "PacketManager.h"
+#include "GameStateManager.h"
 #include "enet/enet.h"
 
