Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2009, 6:02:25 PM (15 years ago)
Author:
scheusso
Message:

merged netp5 back to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/packet/Packet.cc

    r3097 r3214  
    3131
    3232#include <cassert>
     33#include <cstring>
    3334#include <enet/enet.h>
    34 #include <boost/bind.hpp>
    35 #include <boost/thread/recursive_mutex.hpp>
    36 
    37 #include "network/ConnectionManager.h"
    38 #include "network/ClientInformation.h"
    39 
     35#include <boost/static_assert.hpp>
     36
     37#include "util/Debug.h"
    4038#include "Acknowledgement.h"
    41 #include "DeleteObjects.h"
    4239#include "Chat.h"
    4340#include "ClassID.h"
     41#include "DeleteObjects.h"
    4442#include "FunctionCalls.h"
    4543#include "FunctionIDs.h"
     
    4745#include "Welcome.h"
    4846#include "network/Host.h"
    49 #include "core/CoreIncludes.h"
     47#include "network/ClientInformation.h"
    5048
    5149namespace orxonox{
     
    5351namespace packet{
    5452
    55 #define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE
     53// Make sure we assume the right values
     54BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable)   == static_cast<int>(ENET_PACKET_FLAG_RELIABLE));
     55BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequence) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED));
     56BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE));
     57
     58#define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate
    5659#define _PACKETID           0
    5760
    5861std::map<size_t, Packet *> Packet::packetMap_;
    59 //! Static mutex for any packetMap_ access
    60 static boost::recursive_mutex packetMap_mutex_g;
    6162
    6263Packet::Packet(){
     
    108109  }
    109110  else if (this->data_) {
    110     // This destructor was probably called as a consequence to ENet executing our callback.
     111    // This destructor was probably called as a consequence of ENet executing our callback.
    111112    // It simply serves us to be able to deallocate the packet content (data_) ourselves since
    112113    // we have created it in the first place.
     
    142143      // Assures we don't create a packet and destroy it right after in another thread
    143144      // without having a reference in the packetMap_
    144       boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);
    145145      packetMap_[(size_t)(void*)enetPacket_] = this;
    146146    }
     
    218218  // Data was created by ENet
    219219  p->bDataENetAllocated_ = true;
     220  p->enetPacket_ = packet;
    220221
    221222  return p;
     
    228229*/
    229230void Packet::deletePacket(ENetPacket *enetPacket){
    230   boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);
    231231  // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
    232232  std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket);
     
    236236  delete it->second;
    237237  packetMap_.erase(it);
    238   COUT(4) << "PacketMap size: " << packetMap_.size() << std::endl;
     238  COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;
    239239}
    240240
Note: See TracChangeset for help on using the changeset viewer.