Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2007, 12:28:42 AM (18 years ago)
Author:
dumenim
Message:

networkstuff bluber fubber

File:
1 edited

Legend:

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

    r624 r632  
    5252        cout << "clientId: " << client << endl; //control cout, not important, just debugging info
    5353        int id = (int)*packet->data; //the first 4 bytes are always the enet packet id
     54        std::cout << "packet id: " << id << std::endl;
     55        std::cout << "packet size inside packetdecoder: " << packet->dataLength << std::endl;
    5456        switch( id ) {
    5557        case ACK:
     
    145147        unsigned char* data = (unsigned char*)packet->data;
    146148        //copy the GameStateCompressed id into the struct, which is located at second place data+sizeof( int )
    147   //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
    148   currentState->id = (int)*(data+sizeof(int));
    149   std::cout << "id: " << currentState->id << std::endl;
     149        //memcpy( (void*)&(currentState->id), (const void*)(data+sizeof( int )), sizeof( int ) );
     150        currentState->id = (int)*(data+sizeof(int));
     151         std::cout << "id: " << currentState->id << std::endl;
    150152        //copy the size of the GameStateCompressed compressed data into the new GameStateCompressed struct, located at 3th
    151153        //position of the data stream, data+2*sizeof( int )
    152 //      memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
    153   currentState->compsize = (int)*(data+2*sizeof(int));
    154   std::cout << "compsize: " << currentState->compsize << std::endl;
     154        memcpy( (void*)&(currentState->compsize), (const void*)(data+2*sizeof( int )), sizeof( int) );
     155        //currentState->compsize = (int)*(data+2*sizeof(int));
     156        std::cout << "compsize: " << currentState->compsize << std::endl;
    155157        //size of uncompressed data
    156 //      memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
    157   currentState->normsize = (int)*(data+3*sizeof(int));
    158   std::cout << "normsize. " << currentState->normsize << std::endl;
     158        memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
     159        //currentState->normsize = (int)*(data+3*sizeof(int));
     160        std::cout << "normsize. " << currentState->normsize << std::endl;
    159161        //since the packetgenerator was changed, due to a new parameter, change this function too
    160 //      memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
    161   currentState->diffed = (bool)*(data+4*sizeof(int));
    162   std::cout << "diffed: " << currentState->diffed << std::endl;
     162        memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
     163        //currentState->diffed = (bool)*(data+4*sizeof(int));
     164        std::cout << "diffed: " << currentState->diffed << std::endl;
    163165        //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    164166        currentState->data = (unsigned char*)(malloc( currentState->compsize ));
    165   if(currentState->data==NULL)
    166     std::cout << "memory leak" << std::endl;
     167        if(currentState->data==NULL)
     168                std::cout << "memory leak" << std::endl;
    167169        //copy the GameStateCompressed data
    168   //std::cout << "packet size (enet): " << packet->dataLength << std::endl;
    169   //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;
     170        //std::cout << "packet size (enet): " << packet->dataLength << std::endl;
     171        //std::cout << "totallen: " << 4*sizeof(int)+sizeof(bool)+currentState->compsize << std::endl;
    170172        memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
    171173
    172174        //clean memory
    173175        enet_packet_destroy( packet );
    174   //run processGameStateCompressed
    175   //TODO: not yet implemented!
    176   processGamestate(currentState);
     176        //run processGameStateCompressed
     177        //TODO: not yet implemented!
     178        processGamestate(currentState);
    177179}
    178180
Note: See TracChangeset for help on using the changeset viewer.