Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (8 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/network/packet/Packet.cc

    r8858 r11071  
    3434#define WIN32_LEAN_AND_MEAN
    3535#include <enet/enet.h>
    36 #include <boost/static_assert.hpp>
    3736#include <boost/thread/mutex.hpp>
    3837
     
    5453
    5554// Make sure we assume the right values
    56 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable)    == static_cast<int>(ENET_PACKET_FLAG_RELIABLE));
    57 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequenced) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED));
    58 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate)  == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE));
     55static_assert(static_cast<int>(PacketFlag::Reliable)    == static_cast<int>(ENET_PACKET_FLAG_RELIABLE),    "check enum");
     56static_assert(static_cast<int>(PacketFlag::Unsequenced) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED), "check enum");
     57static_assert(static_cast<int>(PacketFlag::NoAllocate)  == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE), "check enum");
    5958
    6059#define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate
     
    6968  packetDirection_ = Direction::Outgoing;
    7069  peerID_=0;
    71   data_=0;
    72   enetPacket_=0;
     70  data_=nullptr;
     71  enetPacket_=nullptr;
    7372  bDataENetAllocated_ = false;
    7473}
     
    8079  peerID_=peerID;
    8180  data_=data;
    82   enetPacket_=0;
     81  enetPacket_=nullptr;
    8382  bDataENetAllocated_ = false;
    8483}
     
    9594    memcpy(data_, p.data_, p.getSize());
    9695  }else
    97     data_=0;
     96    data_=nullptr;
    9897  bDataENetAllocated_ = p.bDataENetAllocated_;
    9998}
     
    122121  // Destroy the ENetPacket if necessary.
    123122  // Note: For the case ENet used the callback to destroy the packet, we have already set
    124   // enetPacket_ to NULL to avoid destroying it again.
     123  // enetPacket_ to nullptr to avoid destroying it again.
    125124  if (this->enetPacket_)
    126125  {
     
    158157  }
    159158#ifndef NDEBUG
    160   switch( *(Type::Value *)(data_ + _PACKETID) )
     159  switch( *(Type *)(data_ + _PACKETID) )
    161160  {
    162161    case Type::Acknowledgement:
     
    175174#endif
    176175//  ENetPacket *temp = enetPacket_;
    177 //  enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
     176//  enetPacket_ = nullptr; // otherwise we have a double free because enet already handles the deallocation of the packet
    178177  if( this->flags_ & PacketFlag::Reliable )
    179178    host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT);
     
    191190//   if( peerID==static_cast<unsigned int>(-2))
    192191//     peerID = NETWORK_PEER_ID_SERVER;
    193   Packet *p = 0;
    194 //   orxout(verbose_ultra, context::packets) << "packet type: " << *(Type::Value *)&data[_PACKETID] << endl;
    195   switch( *(Type::Value *)(data + _PACKETID) )
     192  Packet *p = nullptr;
     193//   orxout(verbose_ultra, context::packets) << "packet type: " << *(Type *)&data[_PACKETID] << endl;
     194  switch( *(Type *)(data + _PACKETID) )
    196195  {
    197196    case Type::Acknowledgement:
     
    251250  assert(it != packetMap_.end());
    252251  // Make sure we don't delete it again in the destructor
    253   it->second->enetPacket_ = 0;
     252  it->second->enetPacket_ = nullptr;
    254253  delete it->second;
    255254  packetMap_.erase(it);
Note: See TracChangeset for help on using the changeset viewer.