Changeset 8327 for code/trunk/src/libraries/network/packet
- Timestamp:
- Apr 25, 2011, 8:22:36 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/network6 (added) merged: 7823-7825,7875,7878,7881-7882,7898,7900,7931,8315
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/packet/Gamestate.cc
r7844 r8327 107 107 uint32_t size = calcGamestateSize(id, mode); 108 108 109 COUT( 4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;109 COUT(5) << "G.ST.Man: producing gamestate with id: " << id << std::endl; 110 110 if(size==0) 111 111 return false; … … 158 158 //start write gamestate header 159 159 header_.setDataSize( currentsize ); 160 header_.setCompSize( 0 ); 160 161 header_.setID( id ); 161 162 header_.setBaseID( GAMESTATEID_INITIAL ); -
code/trunk/src/libraries/network/packet/Packet.cc
r7801 r8327 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(); -
code/trunk/src/libraries/network/packet/Packet.h
r7801 r8327 32 32 #include <map> 33 33 34 namespace orxonox { 34 namespace orxonox 35 { 35 36 36 namespace packet{ 37 namespace packet 38 { 37 39 38 namespace Direction{ 39 enum Value{ 40 namespace Direction 41 { 42 enum Value 43 { 40 44 Incoming, 41 45 Outgoing, … … 43 47 }; 44 48 } 45 namespace Type{ 46 enum Value{ 49 namespace Type 50 { 51 enum Value 52 { 47 53 Acknowledgement, 48 54 Chat, … … 59 65 @author Oliver Scheuss <scheusso [at] ee.ethz.ch> 60 66 */ 61 class _NetworkExport Packet{ 67 class _NetworkExport Packet 68 { 62 69 public: 63 70 Packet(const Packet &p); 64 71 virtual ~Packet(); 65 static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);66 static void deletePacket(ENetPacket *packet);72 static Packet* createPacket(ENetPacket* packet, uint32_t peerID); 73 static void deletePacket(ENetPacket* packet); 67 74 68 virtual unsigned char *getData(){ return data_; };75 virtual unsigned char* getData(){ return data_; }; 69 76 virtual unsigned int getSize() const =0; 70 77 virtual bool process(orxonox::Host* host)=0;
Note: See TracChangeset
for help on using the changeset viewer.