Index: code/branches/merger/CMakeLists.txt
===================================================================
--- code/branches/merger/CMakeLists.txt	(revision 323)
+++ code/branches/merger/CMakeLists.txt	(revision 332)
@@ -32,6 +32,6 @@
   # if on tardis change compiler
   IF (IS_TARDIS)
-  MESSAGE("System is a TARDIS: Setting Compiler to g++-3.4.3")
-  SET(CMAKE_CXX_COMPILER "g++-3.4.3")
+  MESSAGE("System is a TARDIS: Setting Compiler to g++-4.1.1")
+  SET(CMAKE_CXX_COMPILER "g++-4.1.1")
 # reset eNet serach path
   SET(Boost_INCLUDE_DIR "/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/include/boost-1_34_1")
@@ -42,4 +42,7 @@
 #This sets where to look for "Find*.cmake" files
 SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+# SET(BOOST_LIBDIR /usr/pack/boost-1.33.1-mo/i686-debian-linux3.1/lib/)
+# SET(BOOST_INCDIR /usr/pack/boost-1.33.1-mo/i686-debian-linux3.1/include/)
+
 #Performs the search and sets the variables
 FIND_PACKAGE(OGRE)
@@ -52,6 +55,8 @@
 #Sets the search paths for the linking
 LINK_DIRECTORIES(${OGRE_LIB_DIR} ${OIS_LIB_DIR} ${CEGUI_LIB_DIR} ${CEGUI_OGRE_LIB_DIR} ${ENet_LIBRARY} ${Boost_LIBRARY_DIRS} core objects loader network weapon classHierarchy)
+
 #Sets the search path for include files
 INCLUDE_DIRECTORIES(${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${CEGUI_INCLUDE_DIR} ${CEGUI_OGRE_INCLUDE_DIR} ${ENet_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
+
 
 #add main source dir
Index: code/branches/merger/src/network/CMakeLists.txt
===================================================================
--- code/branches/merger/src/network/CMakeLists.txt	(revision 323)
+++ code/branches/merger/src/network/CMakeLists.txt	(revision 332)
@@ -1,5 +1,7 @@
 PROJECT(Orxonox)
 
-SET(SRC_FILES Client.cc ConnectionManager.cc PacketBuffer.cc PacketGenerator.cc Synchronisable.cc dummyclient2.cc ClientConnection.cc GameStateManager.cc PacketDecoder.cc Server.cc dummyclient.cc dummyserver.cc)
+SET(SRC_FILES Client.cc ConnectionManager.cc PacketBuffer.cc PacketGenerator.cc Synchronisable.cc ClientConnection.cc GameStateManager.cc PacketDecoder.cc Server.cc)
 
-ADD_LIBRARY(network ${SRC_FILES})
+INCLUDE_DIRECTORIES(..)
+
+ADD_LIBRARY(network ${SRC_FILES} ${ENet_LIBRARY})
Index: code/branches/merger/src/network/GameStateManager.cc
===================================================================
--- code/branches/merger/src/network/GameStateManager.cc	(revision 323)
+++ code/branches/merger/src/network/GameStateManager.cc	(revision 332)
@@ -22,11 +22,106 @@
 }
 
-GameState GameStateManager::getSnapshot(){
+/**
+ * This function goes through the whole list of synchronisables and 
+ * saves all the synchronisables to a flat "list".
+ * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list
+ */
+GameState GameStateManager::getSnapshot(int id)
+{
+  //the size of the gamestate
+  int totalsize=0;
+  //the size of one specific synchronisable
+  int tempsize=0;
+  // get the start of the Synchronisable list
+  orxonox::Iterator<Synchronisable> it;
+  // struct for return value of Synchronisable::getData()
+  syncData sync;
+  
+  GameState retval; //return value
+  retval.id=id;
+  // reserve a little memory and increase it later on
+  retval.data = (unsigned char*)malloc(1);
+  
+  // offset of memory functions
+  int offset=0;
+  // go through all Synchronisables
+  for(it = orxonox::ObjectList<Synchronisable>::start(); it != 0; ++it){
+    //get size of the synchronisable
+    tempsize=it->getSize();
+    // add place for data and 3 ints (length,classid,objectid)
+    totalsize+=tempsize+3*sizeof(int);
+    // allocate additional space
+    retval.data = (unsigned char *)realloc((void *)retval.data, totalsize);
+    
+    // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
+    sync=it->getData(retval.data+offset+3*sizeof(int));
+    *(retval.data+offset)=sync.length;
+    *(retval.data+offset+sizeof(int))=sync.objectID;
+    *(retval.data+offset+2*sizeof(int))=sync.classID;
+    // increase data pointer
+    offset+=tempsize+3*sizeof(int);
+  }
+  retval.size=totalsize;
+  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(GameState state)
+{
+  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
+        
+      }
+    } else {
+      // we have our object
+      if(! it->updateData(sync))
+        std::cout << "We couldn't update objectID: " \
+          << sync.objectID << "; classID: " << sync.classID << std::endl;
+    }
+    
+  }
+  
   
 }
 
-bool GameStateManager::loadSnapshot(GameState state){
-  
+/**
+ * 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
+ */
+// orxonox::Iterator<Synchronisable> removeObject(orxonox::Iterator<Synchronisable> it){
+void removeObject(orxonox::Iterator<Synchronisable> &it){
+  orxonox::Iterator<Synchronisable> temp=it;
+  ++it;
+  delete  *temp;
+//   return it;
 }
 
+
 }
+
+
Index: code/branches/merger/src/network/GameStateManager.h
===================================================================
--- code/branches/merger/src/network/GameStateManager.h	(revision 323)
+++ code/branches/merger/src/network/GameStateManager.h	(revision 332)
@@ -13,4 +13,8 @@
 #define NETWORK_GAMESTATEMANAGER_H
 
+#include "Synchronisable.h"
+#include "orxonox/core/IdentifierIncludes.h"
+#include "orxonox/core/Iterator.h"
+
 namespace network {
 
@@ -20,5 +24,6 @@
  * data: pointer to the data allocated in the memory
  */
-struct GameState{
+  struct GameState{
+  int id;
   int size;
   unsigned char *data;
@@ -36,8 +41,9 @@
   GameStateManager();
   ~GameStateManager();
-  GameState getSnapshot();
+  GameState getSnapshot(int id);
   bool loadSnapshot(GameState state);
 private:
-  
+  bool removeObject(orxonox::Iterator<Synchronisable> it);
+
 };
 
Index: code/branches/merger/src/network/PacketDecoder.cc
===================================================================
--- code/branches/merger/src/network/PacketDecoder.cc	(revision 323)
+++ code/branches/merger/src/network/PacketDecoder.cc	(revision 332)
@@ -1,9 +1,9 @@
 /*
  * Class contains functions to determine and decode incomming packages
+ * ->don't read this without the class PacketGenerator, since they belong together
  * 
  * Autor: Dumeni Manatschal
  * 
 */
-
 
 #include "enet/enet.h"
@@ -21,6 +21,6 @@
 {
 	int client = clientId;
-	cout << "clientId: " << client << endl;
-	int id = (int)*packet->data;
+	cout << "clientId: " << client << endl; //control cout, not important, just debugging info
+	int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
 	switch( id ) {
 	case ACK:
@@ -40,4 +40,8 @@
 		return true;
 		break;
+	case GAMESTATE:
+		gstate( packet );
+		return true;
+		break;
 	}
 	return false;
@@ -49,6 +53,10 @@
 {
 	ack* a = new ack;
-	*a = *(ack*)packet->data;
-	printAck( a );
+	*a = *(ack*)packet->data; //press pattern of ack on new data
+	
+	//clean memory
+	enet_packet_destroy( packet );
+	
+	printAck( a ); //debug info
 }
 
@@ -56,6 +64,11 @@
 {
 	mouse* mouseMove = new mouse;
-	*mouseMove = *(mouse*)packet->data;
-	printMouse( mouseMove );
+	//copy data of packet->data to new struct
+	*mouseMove = *(mouse*)packet->data; 
+	
+	//clean memory
+	enet_packet_destroy( packet );
+	
+	printMouse( mouseMove ); //debug info
 }
 
@@ -63,6 +76,11 @@
 {
 	keyboard* key = new keyboard;
-	*key = *(keyboard*)packet->data;
-	printKey( key );
+	*key = *(keyboard*)packet->data; //see above
+	
+	//clean memory
+	enet_packet_destroy( packet );
+	
+	printKey( key ); //debug info
+
 }
 
@@ -70,9 +88,37 @@
 {
 	chat* chatting = new chat;
-	chatting->id = (int)*packet->data;
-	char* reserve = new char[packet->dataLength-4];
-	memcpy( &reserve[0], packet->data+sizeof(int), packet->dataLength-4 );
+	chatting->id = (int)*packet->data; //first copy id into new struct
+	//since the chat message is a char*, allocate the memory needed
+	char* reserve = new char[packet->dataLength-4]; 
+	//copy the transmitted bytestream into the new generated char*,
+	//note the lenght of the message is represented as "packet->dataLength-sizeof( int )" 
+	memcpy( &reserve[0], packet->data+sizeof(int), packet->dataLength-sizeof(int) );
+	//put pointer of chatting struct to the begining of the new generated char*
 	chatting->message = reserve;
-	printChat( chatting );
+	
+	//clean memory
+	enet_packet_destroy( packet );
+	
+	printChat( chatting ); //debug info
+	
+}
+
+void PacketDecoder::gstate( ENetPacket* packet )
+{
+	GameState* currentState = new GameState;
+	//since it's not alowed to use void* for pointer arithmetic
+	unsigned char* data = (unsigned char*)packet->data;
+	//copy the gamestate id into the struct, which is located at second place data+sizeof( int )
+	memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
+	//copy the size of the gamestate data into the new gamestate struct, located at 3th
+	//position of the data stream, data+2*sizeof( int )
+	memcpy( (void*)&(currentState->size), (const void*)(data+2*sizeof( int )), 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->size ));
+	//copy the gamestate data
+	memcpy( (void*)(currentState->data), (const void*)(data+3*sizeof( int )), currentState->size );
+	
+	//clean memory
+	enet_packet_destroy( packet );
 }
 
@@ -100,5 +146,10 @@
 {
 	cout << "data id: " << data->id << endl;
-	cout << "blablabla" << endl;
 	cout << "data:    " << data->message << endl;
 }
+
+void PacketDecoder::printGamestate( GameState* data )
+{
+	cout << "id of gamestate:   " << data->id << endl;
+	cout << "size of gamestate: " << data->size << endl;
+}
Index: code/branches/merger/src/network/PacketGenerator.cc
===================================================================
--- code/branches/merger/src/network/PacketGenerator.cc	(revision 323)
+++ code/branches/merger/src/network/PacketGenerator.cc	(revision 332)
@@ -1,4 +1,5 @@
 /*
  *Class generates packets that can be send by enet
+ * ->don't read this without the class PacketDecoder, since they belong together
  * 
  * Autor: Dumeni Manatschal
@@ -68,2 +69,19 @@
 }
 
+/*### gamestate packet */
+ENetPacket* PacketGenerator::gstate( GameState* states, int reliable )
+{
+	int* gid; *gid = GAMESTATE; //first assign the correct enet id
+	int totalLen = 3*sizeof( int ) + states->size; //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 gamestate id
+	//this is the size of the gamestate data, place at 3th position of the enet datastream
+	memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->size), sizeof(int)); 
+	//place the gamestate data at the end of the enet datastream
+	memcpy( (void*)(data+3*sizeof( int )), (const void*)states->data, states->size );
+	//create an enet packet with the generated bytestream
+	ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
+	
+	return packet;
+}
Index: code/branches/merger/src/network/PacketManager.h
===================================================================
--- code/branches/merger/src/network/PacketManager.h	(revision 323)
+++ code/branches/merger/src/network/PacketManager.h	(revision 332)
@@ -3,4 +3,5 @@
 
 #include <enet/enet.h>
+#include <network/GameStateManager.h>
 
 //enum netowk generaly used to set the type ID of a packet
@@ -11,5 +12,6 @@
 	MOUSE,
 	KEYBOARD,
-	CHAT
+	CHAT,
+	GAMESTATE
 };
 
@@ -17,5 +19,5 @@
  * class to generate packets
  * 
- * Autor: Dumeni Manatschal
+ * @autor: Dumeni Manatschal
  * 
 */ 
@@ -29,4 +31,5 @@
 	ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
 	ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
+	ENetPacket* gstate( GameState* states, int reliable = ENET_PACKET_FLAG_RELIABLE );
 private:
 	//used to set the bytes in the right order
@@ -51,5 +54,5 @@
  * class used to decode incoming packets
  * 
- * Autor: Dumeni Manatschal
+ * @autor: Dumeni Manatschal
  * 
 */
@@ -87,4 +90,5 @@
 	void keystrike( ENetPacket* packet );
 	void chatMessage( ENetPacket* packet );
+	void gstate( ENetPacket* packet );
 	
 	//print functions
@@ -93,5 +97,5 @@
 	void printKey( keyboard* data );
 	void printChat( chat* data );
-	void printPeer( ENetPeer* peer );
+	void printGamestate( GameState* data );
 };
 }
Index: code/branches/merger/src/network/Synchronisable.h
===================================================================
--- code/branches/merger/src/network/Synchronisable.h	(revision 323)
+++ code/branches/merger/src/network/Synchronisable.h	(revision 332)
@@ -14,4 +14,7 @@
 
 #include <list>
+#include <iostream>
+
+#include "orxonox/core/IdentifierIncludes.h"
 
 namespace network {
@@ -20,6 +23,6 @@
 struct syncData{
   int length;
+  int objectID;
   int classID;
-  int objectID;
   unsigned char *data;
 };
@@ -40,5 +43,5 @@
   Synchronisable();
 
-  ~Synchronisable();
+  virtual ~Synchronisable();
   int objectID;
   int classID;
@@ -52,4 +55,6 @@
 
 private:
+/*  bool removeObject(Iterator<Synchronisable> it);*/
+  
   std::list<SYNCVAR> syncList;
   int datasize;
Index: code/branches/merger/src/orxonox/core/Iterator.h
===================================================================
--- code/branches/merger/src/orxonox/core/Iterator.h	(revision 323)
+++ code/branches/merger/src/orxonox/core/Iterator.h	(revision 332)
@@ -1,4 +1,4 @@
-#ifndef _Iterator_H__
-#define _Iterator_H__
+#ifndef _Iterator_H2__
+#define _Iterator_H2__
 
 namespace orxonox
