Changeset 632 for code/branches/FICN/src/network/PacketDecoder.cc
- Timestamp:
- Dec 19, 2007, 12:28:42 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/PacketDecoder.cc
r624 r632 52 52 cout << "clientId: " << client << endl; //control cout, not important, just debugging info 53 53 int id = (int)*packet->data; //the first 4 bytes are always the enet packet id 54 std::cout << "packet id: " << id << std::endl; 55 std::cout << "packet size inside packetdecoder: " << packet->dataLength << std::endl; 54 56 switch( id ) { 55 57 case ACK: … … 145 147 unsigned char* data = (unsigned char*)packet->data; 146 148 //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int ) 147 //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );148 currentState->id = (int)*(data+sizeof(int));149 std::cout << "id: " << currentState->id << std::endl;149 //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) ); 150 currentState->id = (int)*(data+sizeof(int)); 151 std::cout << "id: " << currentState->id << std::endl; 150 152 //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th 151 153 //position of the data stream, data+2*sizeof( int ) 152 //memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );153 currentState->compsize = (int)*(data+2*sizeof(int));154 std::cout << "compsize: " << currentState->compsize << std::endl;154 memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) ); 155 //currentState->compsize = (int)*(data+2*sizeof(int)); 156 std::cout << "compsize: " << currentState->compsize << std::endl; 155 157 //size of uncompressed data 156 //memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );157 currentState->normsize = (int)*(data+3*sizeof(int));158 std::cout << "normsize. " << currentState->normsize << std::endl;158 memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) ); 159 //currentState->normsize = (int)*(data+3*sizeof(int)); 160 std::cout << "normsize. " << currentState->normsize << std::endl; 159 161 //since the packetgenerator was changed, due to a new parameter, change this function too 160 //memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));161 currentState->diffed = (bool)*(data+4*sizeof(int));162 std::cout << "diffed: " << currentState->diffed << std::endl;162 memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool)); 163 //currentState->diffed = (bool)*(data+4*sizeof(int)); 164 std::cout << "diffed: " << currentState->diffed << std::endl; 163 165 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 164 166 currentState->data = (unsigned char*)(malloc( currentState->compsize )); 165 if(currentState->data==NULL)166 std::cout << "memory leak" << std::endl;167 if(currentState->data==NULL) 168 std::cout << "memory leak" << std::endl; 167 169 //copy the GameStateCompressed data 168 //std::cout << "packet size (enet): " << packet->dataLength << std::endl;169 //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;170 //std::cout << "packet size (enet): " << packet->dataLength << std::endl; 171 //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl; 170 172 memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize ); 171 173 172 174 //clean memory 173 175 enet_packet_destroy( packet ); 174 //run processGameStateCompressed175 //TODO: not yet implemented!176 processGamestate(currentState);176 //run processGameStateCompressed 177 //TODO: not yet implemented! 178 processGamestate(currentState); 177 179 } 178 180
Note: See TracChangeset
for help on using the changeset viewer.