Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 7, 2007, 8:38:47 PM (16 years ago)
Author:
scheusso
Message:

adapted PacketBuffer to work with ENetPacket *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/PacketBuffer.cc

    r174 r188  
    1313}
    1414
    15 bool PacketBuffer::push(PacketEnvelope pck){
     15bool PacketBuffer::push(ENetPacket *pck){
    1616  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
     17//   if(closed)
     18//     return false;
    1719  // also works if fifo is null (queue empty)
    1820  // just to be sure last is really the last element
    19   while(last!=NULL && last->next!=NULL)
    20     last=last->next;
     21  /*if(last!=NULL)
     22    while(last->next!=NULL)
     23      last=last->next;*/
    2124  // first element?
    2225  if(first==NULL){
     
    2528    last->next=NULL;
    2629    // change this!!!!!!!
    27     last->packet = new PacketEnvelope;
    28     last->packet->data = pck.data;
    29     last->packet->length = pck.length;
    30   } else {
     30    last->packet = pck;
     31    } else {
    3132    //insert a new element at the bottom
    3233    last->next = new QueueItem;
     
    3536    last->next=NULL;
    3637    // save the packet to the new element
    37     // change this!!!!!!!!
    38     last->packet = new PacketEnvelope;
    39     last->packet->data = pck.data;
    40     last->packet->length = pck.length;
     38    last->packet = pck;
    4139  }
    4240  return true;
    4341}
    4442
    45 PacketEnvelope PacketBuffer::pop(){
     43ENetPacket *PacketBuffer::pop(){
    4644  boost::mutex::scoped_lock lock(networkPacketBufferMutex);
    47   if(first!=NULL){
     45  if(first!=NULL /*&& !closed*/){
    4846    QueueItem *temp = first;
    4947    // get packet
    50     PacketEnvelope *p = first->packet;
     48    ENetPacket *pck=first->packet;
    5149    // remove first element
    5250    first = first->next;
    5351    delete temp;
    54     return *p;
     52    return pck;
    5553  } else{
    56     PacketEnvelope p = {0,0};
    57     return p;
     54    return NULL;
    5855  }
    5956}
Note: See TracChangeset for help on using the changeset viewer.