Changeset 403 for code/branches/FICN/src/network/PacketDecoder.cc
- Timestamp:
- Dec 5, 2007, 4:23:52 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/PacketDecoder.cc
r401 r403 110 110 void PacketDecoder::gstate( ENetPacket* packet ) 111 111 { 112 GameState * currentState = new GameState;112 GameStateCompressed* currentState = new GameStateCompressed; 113 113 //since it's not alowed to use void* for pointer arithmetic 114 114 unsigned char* data = (unsigned char*)packet->data; 115 //copy the gamestateid into the struct, which is located at second place data+sizeof( int )115 //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int ) 116 116 memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) ); 117 //copy the size of the gamestate data into the new gamestatestruct, located at 3th117 //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th 118 118 //position of the data stream, data+2*sizeof( int ) 119 memcpy( (void*)&(currentState->size), (const void*)(data+2*sizeof( int )), sizeof( int) ); 119 memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) ); 120 //size of uncompressed data 121 memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) ); 120 122 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 121 123 currentState->data = (unsigned char*)(malloc( currentState->size )); 122 //copy the gamestatedata123 memcpy( (void*)(currentState->data), (const void*)(data+ 3*sizeof( int )), currentState->size );124 //copy the GameStateCompressed data 125 memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int )), currentState->compsize ); 124 126 125 127 //clean memory 126 128 enet_packet_destroy( packet ); 127 //run processGame state129 //run processGameStateCompressed 128 130 //TODO: not yet implemented! 129 131 //processGamestate(currentState); … … 181 183 } 182 184 183 void PacketDecoder::printGamestate( GameState * data )185 void PacketDecoder::printGamestate( GameStateCompressed* data ) 184 186 { 185 cout << "id of gamestate: " << data->id << endl;186 cout << "size of gamestate: " << data->size << endl;187 cout << "id of GameStateCompressed: " << data->id << endl; 188 cout << "size of GameStateCompressed: " << data->size << endl; 187 189 } 188 190
Note: See TracChangeset
for help on using the changeset viewer.