Changeset 1432 for code/branches/network/src/network/PacketDecoder.cc
- Timestamp:
- May 26, 2008, 10:06:36 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/PacketDecoder.cc
r1360 r1432 127 127 bool PacketDecoder::command( ENetPacket* packet, int clientId ){ 128 128 int length = *(int*)((unsigned char *)packet->data+sizeof(int)); 129 if(length<=0) 130 return false; 129 131 void *data = (void *)new unsigned char[length]; 130 132 memcpy(data, (void *)(packet->data+2*sizeof(int)), length); … … 158 160 { 159 161 chat* chatting = new chat; 162 if(packet->dataLength==4) 163 return; 160 164 chatting->id = (int)*packet->data; //first copy id into new struct 161 165 //since the chat message is a char*, allocate the memory needed … … 204 208 COUT(2) << "PacketDecoder: compsize is 0" << std::endl; 205 209 // currentState->data = (unsigned char*)(malloc( currentState->compsize )); 210 if(currentState->compsize==0) 211 return; 206 212 currentState->data = new unsigned char[currentState->compsize]; 207 213 if(currentState->data==NULL) … … 221 227 cid->id = ((classid *)(packet->data))->id; 222 228 cid->clid = ((classid *)(packet->data))->clid; 229 if(cid->length==0) 230 return; 223 231 // cid->message = (const char *)malloc(cid->length); 224 232 cid->message = new char[cid->length];
Note: See TracChangeset
for help on using the changeset viewer.