Changeset 6577 for code/branches/chat/src/libraries/network/packet
- Timestamp:
- Mar 21, 2010, 11:22:04 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/chat/src/libraries/network/packet/Chat.cc
r6417 r6577 37 37 38 38 #define PACKET_FLAGS_CHAT PacketFlag::Reliable 39 40 /* Some lengths */ 39 41 #define _PACKETID 0 40 42 const int _PLAYERID = _PACKETID + sizeof(Type::Value); … … 45 47 : Packet() 46 48 { 49 /* Add chat flag to packet flags */ 47 50 flags_ = flags_ | PACKET_FLAGS_CHAT; 51 52 /* set message length to length of input string + 1 */ 48 53 messageLength_ = message.length()+1; 54 55 /* allocate memory for the data */ 49 56 data_=new unsigned char[ getSize() ]; 57 50 58 *(Type::Value *)(data_ + _PACKETID ) = Type::Chat; 51 59 *(unsigned int *)(data_ + _PLAYERID ) = playerID; 52 60 *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_; 61 62 /* cast the hell out of the message string, and copy it into the 63 * data buffer. 64 */ 53 65 memcpy( data_+_MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), messageLength_ ); 54 66 }
Note: See TracChangeset
for help on using the changeset viewer.