Index: /code/branches/network/src/network/PacketDecoder.cc
===================================================================
--- /code/branches/network/src/network/PacketDecoder.cc	(revision 312)
+++ /code/branches/network/src/network/PacketDecoder.cc	(revision 313)
@@ -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:
@@ -53,6 +53,6 @@
 {
 	ack* a = new ack;
-	*a = *(ack*)packet->data;
-	printAck( a );
+	*a = *(ack*)packet->data; //press pattern of ack on new data
+	printAck( a ); //debug info
 }
 
@@ -60,6 +60,7 @@
 {
 	mouse* mouseMove = new mouse;
-	*mouseMove = *(mouse*)packet->data;
-	printMouse( mouseMove );
+	//copy data of packet->data to new struct
+	*mouseMove = *(mouse*)packet->data; 
+	printMouse( mouseMove ); //debug info
 }
 
@@ -67,6 +68,6 @@
 {
 	keyboard* key = new keyboard;
-	*key = *(keyboard*)packet->data;
-	printKey( key );
+	*key = *(keyboard*)packet->data; //see above
+	printKey( key ); //debug info
 }
 
@@ -74,9 +75,13 @@
 {
 	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 );
+	printChat( chatting ); //debug info
 }
 
@@ -84,7 +89,15 @@
 {
 	GameState* currentState = new GameState;
+	//since it's not alowed to use void* for pointer arithmetic
 	unsigned char* data = (unsigned char*)packet->data;
-	memcpy( (void*)&(currentState->size), (const void*)(data+sizeof( int )), sizeof(int) );
-	memcpy( (void*)(currentState->data), (const void*)(data+2*sizeof( int )), currentState->size );
+	//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 );
 }
 
@@ -117,4 +130,5 @@
 void PacketDecoder::printGamestate( GameState* data )
 {
+	cout << "id of gamestate:   " << data->id << endl;
 	cout << "size of gamestate: " << data->size << endl;
 }
Index: /code/branches/network/src/network/PacketGenerator.cc
===================================================================
--- /code/branches/network/src/network/PacketGenerator.cc	(revision 312)
+++ /code/branches/network/src/network/PacketGenerator.cc	(revision 313)
@@ -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
@@ -71,9 +72,14 @@
 ENetPacket* PacketGenerator::gstate( GameState* states, int reliable )
 {
-	int* gid; *gid = GAMESTATE;
-	int totalLen = sizeof( int ) + states->size;
-	unsigned char* data = (unsigned char*)malloc( totalLen );
-	memcpy( (void*)(data), (const void*)gid, sizeof( int ) );
-	memcpy( (void*)(data+sizeof( int )), (const void*)states->data, states->size );
+	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 );
 	
Index: /code/branches/network/src/network/PacketManager.h
===================================================================
--- /code/branches/network/src/network/PacketManager.h	(revision 312)
+++ /code/branches/network/src/network/PacketManager.h	(revision 313)
@@ -19,5 +19,5 @@
  * class to generate packets
  * 
- * Autor: Dumeni Manatschal
+ * @autor: Dumeni Manatschal
  * 
 */ 
@@ -54,5 +54,5 @@
  * class used to decode incoming packets
  * 
- * Autor: Dumeni Manatschal
+ * @autor: Dumeni Manatschal
  * 
 */
