Index: code/branches/network/src/network/PacketBuffer.cc
===================================================================
--- code/branches/network/src/network/PacketBuffer.cc	(revision 187)
+++ code/branches/network/src/network/PacketBuffer.cc	(revision 188)
@@ -13,10 +13,13 @@
 }
 
-bool PacketBuffer::push(PacketEnvelope pck){
+bool PacketBuffer::push(ENetPacket *pck){
   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
-  while(last!=NULL && last->next!=NULL)
-    last=last->next;
+  /*if(last!=NULL)
+    while(last->next!=NULL)
+      last=last->next;*/
   // first element?
   if(first==NULL){
@@ -25,8 +28,6 @@
     last->next=NULL;
     // change this!!!!!!!
-    last->packet = new PacketEnvelope;
-    last->packet->data = pck.data;
-    last->packet->length = pck.length;
-  } else {
+    last->packet = pck;
+    } else {
     //insert a new element at the bottom
     last->next = new QueueItem;
@@ -35,25 +36,21 @@
     last->next=NULL;
     // save the packet to the new element
-    // change this!!!!!!!!
-    last->packet = new PacketEnvelope;
-    last->packet->data = pck.data;
-    last->packet->length = pck.length;
+    last->packet = pck;
   }
   return true;
 }
 
-PacketEnvelope PacketBuffer::pop(){
+ENetPacket *PacketBuffer::pop(){
   boost::mutex::scoped_lock lock(networkPacketBufferMutex);
-  if(first!=NULL){
+  if(first!=NULL /*&& !closed*/){
     QueueItem *temp = first;
     // get packet
-    PacketEnvelope *p = first->packet;
+    ENetPacket *pck=first->packet;
     // remove first element
     first = first->next;
     delete temp;
-    return *p;
+    return pck;
   } else{
-    PacketEnvelope p = {0,0};
-    return p;
+    return NULL;
   }
 }
Index: code/branches/network/src/network/PacketBuffer.h
===================================================================
--- code/branches/network/src/network/PacketBuffer.h	(revision 187)
+++ code/branches/network/src/network/PacketBuffer.h	(revision 188)
@@ -16,4 +16,5 @@
 #include <queue>
 #include <string>
+#include <enet/enet.h>
 #include <boost/bind.hpp>
 #include <boost/thread/mutex.hpp>
@@ -31,5 +32,5 @@
 
 struct QueueItem{
-  PacketEnvelope *packet;
+  ENetPacket *packet;
   QueueItem *next;
 };
@@ -43,7 +44,7 @@
   void print();
   // pops a packet from the queue
-  PacketEnvelope pop();
+  ENetPacket *pop();
   // pushs a packet to the queue
-  bool push(PacketEnvelope pck);
+  bool push(ENetPacket *pck);
 private:
   QueueItem *first;
Index: code/branches/network/src/network/PacketBufferTestExt.cc
===================================================================
--- code/branches/network/src/network/PacketBufferTestExt.cc	(revision 187)
+++ code/branches/network/src/network/PacketBufferTestExt.cc	(revision 188)
@@ -1,7 +1,8 @@
+#include <string>
+#include <iostream>
+#include <enet/enet.h>
+#include <boost/thread/thread.hpp>
 #include "network/PacketBuffer.h"
 #include "network/PacketBuffer.cc"
-#include <boost/thread/thread.hpp>
-#include <iostream>
-#include <string>
 
 using namespace network;
@@ -9,11 +10,13 @@
 
 void write(PacketBuffer *test){
-  PacketEnvelope p;
+  ENetPacket *packet;
   if(test->isEmpty())
     std::cout << "empty buffer" << std::endl;
   for(int i=0; i<10; i++){
-    p.data=i*i;
-    std::cout << i << ": pushing " << p.data << std::endl;
-    test->push(p);
+    std::string temp = "packet ";
+    packet = enet_packet_create("packet", strlen("packet ")+1, 
+ENET_PACKET_FLAG_RELIABLE);
+    std::cout << i << ": pushing " << packet->data << std::endl;
+    test->push(packet);
     if(i==5)
       usleep(200000);
@@ -29,6 +32,5 @@
     // only pop if the queue isn't empty
     while(!test->isEmpty()){
-      int i=test->pop().data;
-      std::cout << "We popped the value " << i << std::endl;
+      std::cout << "We popped the value " << test->pop()->data << std::endl;
     }
   }
