Index: code/branches/network/src/network/ConnectionManager.cc
===================================================================
--- code/branches/network/src/network/ConnectionManager.cc	(revision 203)
+++ code/branches/network/src/network/ConnectionManager.cc	(revision 204)
@@ -35,7 +35,7 @@
   
   
-  ENetPacket *ConnectionManager::getPacket(){
+  ENetPacket *ConnectionManager::getPacket(ENetAddress &address){
     if(!buffer.isEmpty())
-      return buffer.pop();
+      return buffer.pop(address);
     else
         return NULL;
@@ -127,5 +127,4 @@
         break;
       case ENET_EVENT_TYPE_RECEIVE:
-        std::cout << event.packet->data << std::endl;
         processData(&event);
         break;
@@ -143,5 +142,5 @@
     // just add packet to the buffer
     // this can be extended with some preprocessing
-    return buffer.push(event->packet);
+    return buffer.push(event);
   }
   
Index: code/branches/network/src/network/ConnectionManager.h
===================================================================
--- code/branches/network/src/network/ConnectionManager.h	(revision 203)
+++ code/branches/network/src/network/ConnectionManager.h	(revision 204)
@@ -45,5 +45,5 @@
     ConnectionManager();
     ConnectionManager(int port, int address);
-    ENetPacket *getPacket(); // thread1
+    ENetPacket *getPacket(ENetAddress &address); // thread1
     // check wheter the packet queue is empty
     bool queueEmpty();
Index: code/branches/network/src/network/Makefile
===================================================================
--- code/branches/network/src/network/Makefile	(revision 203)
+++ code/branches/network/src/network/Makefile	(revision 204)
@@ -2,6 +2,6 @@
 
 # Link command:
-server: clean PacketBuffer.o ConnectionManager.o dummyserver.o
-	g++ ConnectionManager.o dummyserver.o PacketBuffer.o -o server -lenet -lboost_thread -g
+server: clean PacketBuffer.o ConnectionManager.o dummyserver.o PacketDecoder.o PacketGenerator.o
+	g++ PacketDecoder.o PacketGenerator.o ConnectionManager.o dummyserver.o PacketBuffer.o -o server -lenet -lboost_thread -g
 
 dummyserver.o:
@@ -13,8 +13,13 @@
 PacketBuffer.o: 
 	g++ -c PacketBuffer.cc -o PacketBuffer.o -g
+PacketGenerator.o:
+	g++ -c PacketGenerator.cc -o PacketGenerator.o -g
+PacketDecoder.o:
+	g++ -c PacketDecoder.cc -o PacketDecoder.o -g
+
 
 clean:
 	rm -rf *.o
 
-client:
-	g++ dummyclient.cc -o client -lenet
+client: PacketGenerator.o
+	g++ dummyclient.cc PacketGenerator.o -o client -lenet -g
Index: code/branches/network/src/network/PacketBuffer.cc
===================================================================
--- code/branches/network/src/network/PacketBuffer.cc	(revision 203)
+++ code/branches/network/src/network/PacketBuffer.cc	(revision 204)
@@ -21,13 +21,8 @@
   
 
-bool PacketBuffer::push(ENetPacket *pck){
+bool PacketBuffer::push(ENetEvent *ev){
   boost::mutex::scoped_lock lock(networkPacketBufferMutex);
 //   if(closed)
 //     return false;
-  // also works if fifo is null (queue empty)
-  // just to be sure last is really the last element
-  /*if(last!=NULL)
-    while(last->next!=NULL)
-      last=last->next;*/
   // first element?
   if(first==NULL){
@@ -36,5 +31,6 @@
     last->next=NULL;
     // change this!!!!!!!
-    last->packet = pck;
+    last->packet = ev->packet;
+    last->address = ev->peer->address;
     } else {
     //insert a new element at the bottom
@@ -44,5 +40,6 @@
     last->next=NULL;
     // save the packet to the new element
-    last->packet = pck;
+    last->packet = ev->packet;
+    last->address = ev->peer->address;
   }
   return true;
@@ -64,4 +61,20 @@
 }
 
+ENetPacket *PacketBuffer::pop(ENetAddress &address){
+  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
+  if(first!=NULL /*&& !closed*/){
+    QueueItem *temp = first;
+    // get packet
+    ENetPacket *pck=first->packet;
+    address = first->address;
+    // remove first element
+    first = first->next;
+    delete temp;
+    return pck;
+  } else{
+    return NULL;
+  }
+}
+
 bool PacketBuffer::isEmpty(){
   return (first==NULL);
@@ -71,5 +84,5 @@
   QueueItem *temp=first;
   while(temp!=NULL){
-    std::cout << temp->packet->data << std::endl;
+//    std::cout << temp->packet->data << std::endl;
     temp=temp->next;
   }
Index: code/branches/network/src/network/PacketBuffer.h
===================================================================
--- code/branches/network/src/network/PacketBuffer.h	(revision 203)
+++ code/branches/network/src/network/PacketBuffer.h	(revision 204)
@@ -31,4 +31,5 @@
 struct QueueItem{
   ENetPacket *packet;
+  ENetAddress address;
   QueueItem *next;
 };
@@ -43,6 +44,7 @@
   // pops a packet from the queue
   ENetPacket *pop();
+  ENetPacket *pop(ENetAddress &address);
   // pushs a packet to the queue
-  bool push(ENetPacket *pck);
+  bool push(ENetEvent *ev);
   
 private:
Index: code/branches/network/src/network/dummyclient.cc
===================================================================
--- code/branches/network/src/network/dummyclient.cc	(revision 203)
+++ code/branches/network/src/network/dummyclient.cc	(revision 204)
@@ -6,4 +6,5 @@
 #include <iostream>
 #include <enet/enet.h>
+#include "network/PacketManager.h"
 
 using namespace std;
@@ -14,4 +15,5 @@
   ENetEvent event;
   ENetPeer *peer;
+  network::PacketGenerator pck;
 
   enet_initialize();
@@ -44,8 +46,8 @@
   for(int i=0; i<10; i++){
         // weihnachtsmann bringt packete
-    ENetPacket *packet = enet_packet_create ("packet1234", strlen("packet1234") + 1, ENET_PACKET_FLAG_RELIABLE);
+    //ENetPacket *packet = enet_packet_create ("packet1234", strlen("packet1234") + 1, ENET_PACKET_FLAG_RELIABLE);
         // extend the packet and append the string foo to it
         // send packet to peer on channel id 0
-    enet_peer_send(peer, 1, packet);
+    enet_peer_send(peer, 1, pck.chatMessage("test"));
         // keep the timeout very small for low delay
     if(enet_host_service(client, &event, 1)==0){
Index: code/branches/network/src/network/dummyserver.cc
===================================================================
--- code/branches/network/src/network/dummyserver.cc	(revision 203)
+++ code/branches/network/src/network/dummyserver.cc	(revision 204)
@@ -8,4 +8,5 @@
 #include "enet/enet.h"
 #include "network/ConnectionManager.h"
+#include "network/PacketManager.h"
 
 using namespace network;
@@ -15,10 +16,15 @@
   bool quit=false;
   ENetPacket *packet;
+  ENetEvent event;
   server.createListener();
+  
+  PacketDecoder dec;
+  
   while(!quit){
     if(server.queueEmpty())
       usleep(100);
     else{
-      packet=server.getPacket();
+      ENetAddress addr;
+      packet=server.getPacket(addr);
       if(packet==NULL){
         // there was some error
@@ -26,6 +32,8 @@
         quit=true;
       }
-      else
-        std::cout << "We received: " << packet->data << std::endl;
+      else{
+        //std::cout << "We received: " << packet->data << std::endl;
+        dec.elaborate(packet, 1);
+      }
     }
   }
