Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 24, 2008, 4:47:30 PM (16 years ago)
Author:
scheusso
Message:

bug fixed in packetdecoder (wrong copying)

File:
1 edited

Legend:

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

    r1168 r1177  
    161161    unsigned char* data = (unsigned char *)(packet->data);
    162162    //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));
    165163    memcpy( (void*)&(currentState->id), (const void*)(packet->data+1*sizeof( int )), sizeof( int) );
    166164    COUT(5) << "PacketDecoder: received gs id: " << currentState->id << std::endl;
    167 //     std::cout << "id: " << currentState->id << std::endl;
    168165    //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
    169166    //position of the data stream, data+2*sizeof( int )
    170167    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;
    173168    //size of uncompressed data
    174169    memcpy( (void*)&(currentState->normsize), (const void*)(packet->data+3*sizeof( int )), sizeof( int ) );
    175170    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;
    178171    //since the packetgenerator was changed, due to a new parameter, change this function too
    179172    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;
    182173    //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    183174    if(currentState->compsize==0)
     
    187178      COUT(2) << "PacketDecoder: Gamestatepacket-decoder: memory leak" << std::endl;
    188179    //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 );
    192181
    193182    //clean memory
Note: See TracChangeset for help on using the changeset viewer.