Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 18, 2007, 5:51:47 PM (16 years ago)
Author:
scheusso
Message:

gamestatehandling, error correction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/PacketDecoder.cc

    r531 r620  
    8888        *a = *(ack*)packet->data; //press pattern of ack on new data
    8989
    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 );
    9495}
    9596
     
    143144        unsigned char* data = (unsigned char*)packet->data;
    144145        //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));
    146148        //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
    147149        //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));
    149152        //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));
    151155        //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));
    153158        //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    154159        currentState->data = (unsigned char*)(malloc( currentState->compsize ));
     160  if(currentState->data==NULL)
     161    std::cout << "memory leak" << std::endl;
    155162        //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;
    156165        memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
    157166
     
    160169  //run processGameStateCompressed
    161170  //TODO: not yet implemented!
    162   //processGamestate(currentState);
     171  processGamestate(currentState);
    163172}
    164173
     
    181190}
    182191
     192void PacketDecoder::processGamestate( GameStateCompressed *state ){
     193 
     194}
     195
    183196void PacketDecoder::processClassid( classid *cid){
    184197  printClassid(cid);
     
    186199}
    187200
     201void PacketDecoder::processAck( ack *data, int clientID){
     202  printAck(data);
     203  return;
     204}
    188205
    189206
Note: See TracChangeset for help on using the changeset viewer.