Changeset 1336 for code/branches/merge/src/network/PacketDecoder.cc
- Timestamp:
- May 20, 2008, 5:58:37 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/merge/src/network/PacketDecoder.cc
r1299 r1336 88 88 return decodeConnectRequest( packet, clientId ); 89 89 } 90 return false; 91 } 92 93 bool PacketDecoder::testAndRemoveCRC(ENetPacket *packet){ 94 uint32_t submittetcrc; 95 int dataLength = packet->dataLength; 96 // get the submittet crc code 97 memcpy(&submittetcrc, &packet->data[dataLength-sizeof(uint32_t)], sizeof(uint32_t)); 98 unsigned char *data = packet->data; 99 uint32_t crc32=calcCRC(data, packet->dataLength-sizeof(uint32_t)); 100 // now append the crc to the packet data 101 if(crc32==submittetcrc){ 102 dataLength-=sizeof(uint32_t); 103 enet_packet_resize(packet, dataLength); 104 return true; 105 } 106 COUT(3) << "gamestate crc: " << crc32 << std::endl; 107 COUT(3) << "submitted crc: " << submittetcrc << std::endl; 90 108 return false; 91 109 } … … 157 175 void PacketDecoder::gstate( ENetPacket* packet, int clientID ) 158 176 { 177 if(!testAndRemoveCRC(packet)){ 178 COUT(3) << "crc test of gamestate failed - dropping packet" << std::endl; 179 return; 180 } 159 181 GameStateCompressed* currentState = NULL; 160 182 currentState = new GameStateCompressed;
Note: See TracChangeset
for help on using the changeset viewer.