Changeset 11006 for code/branches/cpp11_v2/src/libraries/network/packet
- Timestamp:
- Dec 30, 2015, 11:34:25 PM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/libraries/network/packet
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/network/packet/Acknowledgement.cc
r8858 r11006 38 38 #define PACKET_FLAGS_ACK 0 39 39 #define _PACKETID 0 40 #define _ACKID _PACKETID + sizeof(packet::Type ::Value)40 #define _ACKID _PACKETID + sizeof(packet::Type) 41 41 42 42 Acknowledgement::Acknowledgement( unsigned int id, unsigned int peerID ) … … 45 45 flags_ = flags_ | PACKET_FLAGS_ACK; 46 46 data_=new uint8_t[ getSize() ]; 47 *(Type ::Value*)(data_ + _PACKETID ) = Type::Acknowledgement;47 *(Type *)(data_ + _PACKETID ) = Type::Acknowledgement; 48 48 *(uint32_t *)(data_ + _ACKID ) = id; 49 49 peerID_=peerID; -
code/branches/cpp11_v2/src/libraries/network/packet/Chat.cc
r8858 r11006 40 40 /* Some lengths */ 41 41 #define _PACKETID 0 42 #define _SOURCEID _PACKETID + sizeof(Type ::Value)42 #define _SOURCEID _PACKETID + sizeof(Type) 43 43 #define _TARGETID _SOURCEID + sizeof(uint32_t) 44 44 #define _MESSAGELENGTH _TARGETID + sizeof(uint32_t) … … 57 57 data_=new unsigned char[ getSize() ]; 58 58 59 *(Type ::Value*)(data_ + _PACKETID ) = Type::Chat;59 *(Type *)(data_ + _PACKETID ) = Type::Chat; 60 60 *(unsigned int *)(data_ + _SOURCEID ) = sourceID; 61 61 *(unsigned int *)(data_ + _TARGETID ) = targetID; -
code/branches/cpp11_v2/src/libraries/network/packet/ClassID.cc
r10919 r11006 70 70 //set the appropriate packet id 71 71 assert(this->data_); 72 *(Type ::Value*)(this->data_ + _PACKETID ) = Type::ClassID;72 *(Type *)(this->data_ + _PACKETID ) = Type::ClassID; 73 73 74 74 uint8_t *temp=data_+sizeof(uint32_t); -
code/branches/cpp11_v2/src/libraries/network/packet/DeleteObjects.cc
r8858 r11006 39 39 #define PACKET_FLAG_DELETE PacketFlag::Reliable 40 40 #define _PACKETID 0 41 #define _QUANTITY _PACKETID + sizeof(Type ::Value)41 #define _QUANTITY _PACKETID + sizeof(Type) 42 42 #define _OBJECTIDS _QUANTITY + sizeof(uint32_t) 43 43 … … 63 63 return false; 64 64 orxout(verbose, context::packets) << "sending DeleteObjects: "; 65 unsigned int size = sizeof(Type ::Value) + sizeof(uint32_t)*(number+1);65 unsigned int size = sizeof(Type) + sizeof(uint32_t)*(number+1); 66 66 data_ = new uint8_t[size]; 67 67 uint8_t *tdata = data_; 68 *reinterpret_cast<Type ::Value*>(tdata) = Type::DeleteObjects;69 tdata += sizeof(Type ::Value);68 *reinterpret_cast<Type*>(tdata) = Type::DeleteObjects; 69 tdata += sizeof(Type); 70 70 *(uint32_t *)tdata = number; 71 71 tdata += sizeof(uint32_t); -
code/branches/cpp11_v2/src/libraries/network/packet/FunctionCalls.cc
r10624 r11006 96 96 assert(this->functionCalls_.size()); 97 97 data_=new uint8_t[ currentSize_ ]; 98 *(Type ::Value*)(data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID98 *(Type *)(data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID 99 99 *(uint32_t*)(data_+sizeof(uint32_t)) = this->functionCalls_.size(); // set nrOfCalls 100 100 *(uint32_t*)(data_+2*sizeof(uint32_t)) = this->minGamestateID_; // set minGamestateID_ -
code/branches/cpp11_v2/src/libraries/network/packet/FunctionIDs.cc
r10769 r11006 71 71 //set the appropriate packet id 72 72 assert(this->data_); 73 *(Type ::Value*)(this->data_ + _PACKETID ) = Type::FunctionIDs;73 *(Type *)(this->data_ + _PACKETID ) = Type::FunctionIDs; 74 74 75 75 uint8_t *temp=data_+sizeof(uint32_t); -
code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.h
r10994 r11006 56 56 GamestateHeader(){ data_=nullptr; } 57 57 GamestateHeader(uint8_t* data) 58 { assert(data); data_ = data; *( uint32_t*)data_ = Type::Gamestate; }58 { assert(data); data_ = data; *(Type*)data_ = Type::Gamestate; } 59 59 /*GamestateHeader(uint8_t* data, GamestateHeader* h) 60 60 { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }*/ 61 61 void setData(uint8_t* data) 62 { assert(data); data_ = data; *( uint32_t*)data_ = Type::Gamestate; }62 { assert(data); data_ = data; *(Type*)data_ = Type::Gamestate; } 63 63 static inline uint32_t getSize() 64 64 { return 21; } -
code/branches/cpp11_v2/src/libraries/network/packet/Packet.cc
r10774 r11006 157 157 } 158 158 #ifndef NDEBUG 159 switch( *(Type ::Value*)(data_ + _PACKETID) )159 switch( *(Type *)(data_ + _PACKETID) ) 160 160 { 161 161 case Type::Acknowledgement: … … 191 191 // peerID = NETWORK_PEER_ID_SERVER; 192 192 Packet *p = nullptr; 193 // orxout(verbose_ultra, context::packets) << "packet type: " << *(Type ::Value*)&data[_PACKETID] << endl;194 switch( *(Type ::Value*)(data + _PACKETID) )193 // orxout(verbose_ultra, context::packets) << "packet type: " << *(Type *)&data[_PACKETID] << endl; 194 switch( *(Type *)(data + _PACKETID) ) 195 195 { 196 196 case Type::Acknowledgement: -
code/branches/cpp11_v2/src/libraries/network/packet/Packet.h
r8327 r11006 38 38 { 39 39 40 namespaceDirection40 enum class Direction 41 41 { 42 enum Value 43 { 44 Incoming, 45 Outgoing, 46 Bidirectional 47 }; 48 } 49 namespace Type 42 Incoming, 43 Outgoing, 44 Bidirectional 45 }; 46 enum class Type : uint8_t 50 47 { 51 enum Value 52 { 53 Acknowledgement, 54 Chat, 55 ClassID, 56 DeleteObjects, 57 FunctionIDs, 58 FunctionCalls, 59 Gamestate, 60 Welcome 61 }; 62 } 48 Acknowledgement, 49 Chat, 50 ClassID, 51 DeleteObjects, 52 FunctionIDs, 53 FunctionCalls, 54 Gamestate, 55 Welcome 56 }; 63 57 64 58 /** … … 98 92 unsigned int peerID_; 99 93 uint32_t requiredGamestateID_; 100 Direction ::ValuepacketDirection_;94 Direction packetDirection_; 101 95 /** Pointer to the data. Be careful when deleting it because it might 102 96 point to a location that was allocated by ENet. -
code/branches/cpp11_v2/src/libraries/network/packet/Welcome.cc
r8858 r11006 41 41 #define PACKET_FLAGS_CLASSID PacketFlag::Reliable 42 42 #define _PACKETID 0 43 #define _CLIENTID _PACKETID + sizeof(Type ::Value)43 #define _CLIENTID _PACKETID + sizeof(Type) 44 44 #define _ENDIANTEST _CLIENTID + sizeof(uint32_t) 45 45 … … 51 51 data_=new uint8_t[ getSize() ]; 52 52 assert(data_); 53 *(packet::Type ::Value*)(data_ + _PACKETID ) = packet::Type::Welcome;53 *(packet::Type *)(data_ + _PACKETID ) = packet::Type::Welcome; 54 54 *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID); 55 55 *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321; … … 70 70 71 71 unsigned int Welcome::getSize() const{ 72 return sizeof(packet::Type ::Value) + 2*sizeof(uint32_t);72 return sizeof(packet::Type) + 2*sizeof(uint32_t); 73 73 } 74 74
Note: See TracChangeset
for help on using the changeset viewer.