Changeset 11071 for code/trunk/src/libraries/network/packet/Packet.cc
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (8 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/packet/Packet.cc
r8858 r11071 34 34 #define WIN32_LEAN_AND_MEAN 35 35 #include <enet/enet.h> 36 #include <boost/static_assert.hpp>37 36 #include <boost/thread/mutex.hpp> 38 37 … … 54 53 55 54 // 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));55 static_assert(static_cast<int>(PacketFlag::Reliable) == static_cast<int>(ENET_PACKET_FLAG_RELIABLE), "check enum"); 56 static_assert(static_cast<int>(PacketFlag::Unsequenced) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED), "check enum"); 57 static_assert(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE), "check enum"); 59 58 60 59 #define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate … … 69 68 packetDirection_ = Direction::Outgoing; 70 69 peerID_=0; 71 data_= 0;72 enetPacket_= 0;70 data_=nullptr; 71 enetPacket_=nullptr; 73 72 bDataENetAllocated_ = false; 74 73 } … … 80 79 peerID_=peerID; 81 80 data_=data; 82 enetPacket_= 0;81 enetPacket_=nullptr; 83 82 bDataENetAllocated_ = false; 84 83 } … … 95 94 memcpy(data_, p.data_, p.getSize()); 96 95 }else 97 data_= 0;96 data_=nullptr; 98 97 bDataENetAllocated_ = p.bDataENetAllocated_; 99 98 } … … 122 121 // Destroy the ENetPacket if necessary. 123 122 // Note: For the case ENet used the callback to destroy the packet, we have already set 124 // enetPacket_ to NULLto avoid destroying it again.123 // enetPacket_ to nullptr to avoid destroying it again. 125 124 if (this->enetPacket_) 126 125 { … … 158 157 } 159 158 #ifndef NDEBUG 160 switch( *(Type ::Value*)(data_ + _PACKETID) )159 switch( *(Type *)(data_ + _PACKETID) ) 161 160 { 162 161 case Type::Acknowledgement: … … 175 174 #endif 176 175 // ENetPacket *temp = enetPacket_; 177 // enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet176 // enetPacket_ = nullptr; // otherwise we have a double free because enet already handles the deallocation of the packet 178 177 if( this->flags_ & PacketFlag::Reliable ) 179 178 host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT); … … 191 190 // if( peerID==static_cast<unsigned int>(-2)) 192 191 // 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) ) 196 195 { 197 196 case Type::Acknowledgement: … … 251 250 assert(it != packetMap_.end()); 252 251 // Make sure we don't delete it again in the destructor 253 it->second->enetPacket_ = 0;252 it->second->enetPacket_ = nullptr; 254 253 delete it->second; 255 254 packetMap_.erase(it);
Note: See TracChangeset
for help on using the changeset viewer.