Changeset 620 for code/branches/FICN/src/network/PacketDecoder.cc
- Timestamp:
- Dec 18, 2007, 5:51:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/PacketDecoder.cc
r531 r620 88 88 *a = *(ack*)packet->data; //press pattern of ack on new data 89 89 90 //clean memory 91 enet_packet_destroy( packet ); 92 93 printAck( a ); //debug info 90 91 processAck( a, clientId ); //debug info 92 93 //clean memory 94 enet_packet_destroy( packet ); 94 95 } 95 96 … … 143 144 unsigned char* data = (unsigned char*)packet->data; 144 145 //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int ) 145 memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) ); 146 //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) ); 147 currentState->id = (int)*(data+sizeof(int)); 146 148 //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th 147 149 //position of the data stream, data+2*sizeof( int ) 148 memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) ); 150 // memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) ); 151 currentState->compsize = (int)*(data+2*sizeof(int)); 149 152 //size of uncompressed data 150 memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) ); 153 // memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) ); 154 currentState->normsize = (int)*(data+3*sizeof(int)); 151 155 //since the packetgenerator was changed, due to a new parameter, change this function too 152 memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool)); 156 // memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool)); 157 currentState->diffed = (bool)*(data+4*sizeof(int)); 153 158 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 154 159 currentState->data = (unsigned char*)(malloc( currentState->compsize )); 160 if(currentState->data==NULL) 161 std::cout << "memory leak" << std::endl; 155 162 //copy the GameStateCompressed data 163 //std::cout << "packet size (enet): " << packet->dataLength << std::endl; 164 //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl; 156 165 memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize ); 157 166 … … 160 169 //run processGameStateCompressed 161 170 //TODO: not yet implemented! 162 //processGamestate(currentState);171 processGamestate(currentState); 163 172 } 164 173 … … 181 190 } 182 191 192 void PacketDecoder::processGamestate( GameStateCompressed *state ){ 193 194 } 195 183 196 void PacketDecoder::processClassid( classid *cid){ 184 197 printClassid(cid); … … 186 199 } 187 200 201 void PacketDecoder::processAck( ack *data, int clientID){ 202 printAck(data); 203 return; 204 } 188 205 189 206
Note: See TracChangeset
for help on using the changeset viewer.