Changeset 1177 for code/branches/network3/src/network/PacketDecoder.cc
- Timestamp:
- Apr 24, 2008, 4:47:30 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/network/PacketDecoder.cc
r1168 r1177 161 161 unsigned char* data = (unsigned char *)(packet->data); 162 162 //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int ) 163 //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );164 //currentState->id = *((int *)packet->data+sizeof(int));165 163 memcpy( (void*)&(currentState->id), (const void*)(packet->data+1*sizeof( int )), sizeof( int) ); 166 164 COUT(5) << "PacketDecoder: received gs id: " << currentState->id << std::endl; 167 // std::cout << "id: " << currentState->id << std::endl;168 165 //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th 169 166 //position of the data stream, data+2*sizeof( int ) 170 167 memcpy( (void*)&(currentState->compsize), (const void*)(packet->data+2*sizeof( int )), sizeof( int) ); 171 //currentState->compsize = (int)*(data+2*sizeof(int));172 // std::cout << "compsize: " << currentState->compsize << std::endl;173 168 //size of uncompressed data 174 169 memcpy( (void*)&(currentState->normsize), (const void*)(packet->data+3*sizeof( int )), sizeof( int ) ); 175 170 memcpy( (void*)&(currentState->base_id), (const void*)(packet->data+4*sizeof( int )), sizeof( int ) ); 176 //currentState->normsize = (int)*(data+3*sizeof(int));177 // std::cout << "normsize. " << currentState->normsize << std::endl;178 171 //since the packetgenerator was changed, due to a new parameter, change this function too 179 172 memcpy( (void*)&(currentState->diffed), (const void*)(packet->data+5*sizeof(int)), sizeof(bool)); 180 //currentState->diffed = (bool)*(data+4*sizeof(int));181 // std::cout << "diffed: " << currentState->diffed << std::endl;182 173 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 183 174 if(currentState->compsize==0) … … 187 178 COUT(2) << "PacketDecoder: Gamestatepacket-decoder: memory leak" << std::endl; 188 179 //copy the GameStateCompressed data 189 //std::cout << "packet size (enet): " << packet->dataLength << std::endl; 190 //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl; 191 memcpy( (void*)(currentState->data), (const void*)(packet->data+4*sizeof( int ) + sizeof(bool)), currentState->compsize ); 180 memcpy( (void*)(currentState->data), (const void*)(packet->data+5*sizeof( int ) + sizeof(bool)), currentState->compsize ); 192 181 193 182 //clean memory
Note: See TracChangeset
for help on using the changeset viewer.