- Timestamp:
- Dec 28, 2010, 4:46:42 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network6/src/libraries/network/packet/Packet.cc
r7801 r7823 47 47 #include "Welcome.h" 48 48 #include "network/Host.h" 49 #include "network/ClientInformation.h"49 // #include "network/ClientInformation.h" 50 50 51 51 namespace orxonox{ … … 85 85 86 86 87 Packet::Packet(const Packet &p){ 87 Packet::Packet(const Packet &p) 88 { 88 89 enetPacket_=p.enetPacket_; 89 90 flags_=p.flags_; … … 104 105 That also means destroying the ENetPacket if one exists. There 105 106 */ 106 Packet::~Packet(){ 107 Packet::~Packet() 108 { 107 109 // Deallocate data_ memory if necessary. 108 if (this->bDataENetAllocated_){ 110 if (this->bDataENetAllocated_) 111 { 109 112 // In this case ENet allocated data_ and will destroy it. 110 113 } 111 else if (this->data_) { 114 else if (this->data_) 115 { 112 116 // This destructor was probably called as a consequence of ENet executing our callback. 113 117 // It simply serves us to be able to deallocate the packet content (data_) ourselves since … … 119 123 // Note: For the case ENet used the callback to destroy the packet, we have already set 120 124 // enetPacket_ to NULL to avoid destroying it again. 121 if (this->enetPacket_){ 125 if (this->enetPacket_) 126 { 122 127 // enetPacket_->data gets destroyed too by ENet if it was allocated by it. 123 128 enet_packet_destroy(enetPacket_); … … 125 130 } 126 131 127 bool Packet::send(orxonox::Host* host){ 128 if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ){ 132 bool Packet::send(orxonox::Host* host) 133 { 134 if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ) 135 { 129 136 assert(0); 130 137 return false; 131 138 } 132 if(!enetPacket_){ 139 if(!enetPacket_) 140 { 133 141 if(!data_){ 134 142 assert(0); … … 175 183 } 176 184 177 Packet *Packet::createPacket(ENetPacket *packet, ENetPeer *peer){ 185 Packet *Packet::createPacket(ENetPacket* packet, uint32_t peerID) 186 { 178 187 uint8_t *data = packet->data; 179 assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());180 unsigned int peerID = ClientInformation::findClient(&peer->address)->getID();188 // assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer()); 189 // unsigned int peerID = ClientInformation::findClient(&peer->address)->getID(); 181 190 // HACK 182 if( peerID==static_cast<unsigned int>(-2))183 peerID = NETWORK_PEER_ID_SERVER;191 // if( peerID==static_cast<unsigned int>(-2)) 192 // peerID = NETWORK_PEER_ID_SERVER; 184 193 Packet *p = 0; 185 194 // COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl; … … 235 244 data we allocated ourselves. 236 245 */ 237 void Packet::deletePacket(ENetPacket *enetPacket){ 246 void Packet::deletePacket(ENetPacket *enetPacket) 247 { 238 248 // Get our Packet from a global map with all Packets created in the send() method of Packet. 239 249 Packet::packetMapMutex_.lock();
Note: See TracChangeset
for help on using the changeset viewer.