Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2007, 4:23:52 PM (17 years ago)
Author:
dumenim
Message:

compressed gamestates

File:
1 edited

Legend:

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

    r401 r403  
    110110void PacketDecoder::gstate( ENetPacket* packet )
    111111{
    112         GameState* currentState = new GameState;
     112        GameStateCompressed* currentState = new GameStateCompressed;
    113113        //since it's not alowed to use void* for pointer arithmetic
    114114        unsigned char* data = (unsigned char*)packet->data;
    115         //copy the gamestate id 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 )
    116116        memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
    117         //copy the size of the gamestate data into the new gamestate struct, located at 3th
     117        //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
    118118        //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 ) );
    120122        //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    121123        currentState->data = (unsigned char*)(malloc( currentState->size ));
    122         //copy the gamestate data
    123         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 );
    124126 
    125127        //clean memory
    126128        enet_packet_destroy( packet );
    127   //run processGamestate
     129  //run processGameStateCompressed
    128130  //TODO: not yet implemented!
    129131  //processGamestate(currentState);
     
    181183}
    182184
    183 void PacketDecoder::printGamestate( GameState* data )
     185void PacketDecoder::printGamestate( GameStateCompressed* data )
    184186{
    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;
    187189}
    188190
Note: See TracChangeset for help on using the changeset viewer.