- Timestamp:
- Oct 10, 2018, 3:06:55 PM (6 years ago)
- Location:
- code/branches/mergeFS18
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/mergeFS18
- Property svn:mergeinfo changed
/code/branches/Masterserver_FS18 (added) merged: 11816,11829,11842,11856,11858,11880,11889,11905,11907,11910,11929-11930,11937,11962-11963,11973,11983,11990
- Property svn:mergeinfo changed
-
code/branches/mergeFS18/src/libraries/network/packet/Chat.cc
r11071 r12027 38 38 #define PACKET_FLAGS_CHAT PacketFlag::Reliable 39 39 40 /* Some lengths */40 /* Some lengths / offsets */ 41 41 #define _PACKETID 0 42 42 #define _SOURCEID _PACKETID + sizeof(Type) … … 49 49 { 50 50 /* Add chat flag to packet flags */ 51 flags_ = flags_ |PACKET_FLAGS_CHAT;51 this->flags_ |= PACKET_FLAGS_CHAT; 52 52 53 53 /* set message length to length of input string + 1 */ 54 messageLength_ = message.length()+1;54 this->messageLength_ = message.length() + 1; 55 55 56 56 /* allocate memory for the data */ 57 data_=new unsigned char[ getSize() ];57 this->data_ = new unsigned char[ getSize() ]; 58 58 59 59 *(Type *)(data_ + _PACKETID ) = Type::Chat; 60 60 *(unsigned int *)(data_ + _SOURCEID ) = sourceID; 61 61 *(unsigned int *)(data_ + _TARGETID ) = targetID; 62 *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;62 *(unsigned int *)(data_ + _MESSAGELENGTH ) = this->messageLength_; 63 63 64 64 /* cast the hell out of the message string, and copy it into the 65 65 * data buffer. 66 66 */ 67 memcpy( data_+_MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())),messageLength_ );67 memcpy( this->data_ + _MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), this->messageLength_ ); 68 68 } 69 69 … … 71 71 : Packet(data, clientID) 72 72 { 73 messageLength_ = *(uint32_t *)(data + _MESSAGELENGTH );73 this->messageLength_ = *(uint32_t *)(data + _MESSAGELENGTH ); 74 74 } 75 75 … … 79 79 80 80 unsigned int Chat::getSize() const{ 81 return _MESSAGE + messageLength_;81 return _MESSAGE + this->messageLength_; 82 82 } 83 83 84 84 bool Chat::process(orxonox::Host* host){ 85 host->doReceiveChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_SOURCEID), *(uint32_t *)(data_+_TARGETID)); 85 host->doReceiveChat(std::string((const char*)this->data_ + _MESSAGE), 86 *(uint32_t *)(this->data_+_SOURCEID), 87 *(uint32_t *)(this->data_+_TARGETID)); 86 88 delete this; 87 89 return true; 88 90 } 89 91 90 unsigned char *Chat::getMessage() {91 return data_ + _MESSAGE;92 unsigned char *Chat::getMessage() { 93 return this->data_ + _MESSAGE; 92 94 } 93 95
Note: See TracChangeset
for help on using the changeset viewer.