Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 437 for code/branches


Ignore:
Timestamp:
Dec 9, 2007, 1:46:03 PM (17 years ago)
Author:
dumenim
Message:

changed PacketGenerator/Decoder with diffed

Location:
code/branches/FICN/src/network
Files:
3 edited

Legend:

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

    r415 r437  
    4444                return true;
    4545                break;
    46           case CLASSID:
    47                 clid(packet);
    48                 return true;
    49                 break;
     46    case CLASSID:
     47        clid(packet);
     48        return true;
     49        break;
    5050        }
    5151        return false;
     
    120120        //size of uncompressed data
    121121        memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) );
     122        //since the packetgenerator was changed, due to a new parameter, change this function too
     123        memcpy( (void*)&(currentState->diffed), (const void*)(data+4*sizeof(int)), sizeof(bool));
    122124        //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream
    123125        currentState->data = (unsigned char*)(malloc( currentState->compsize ));
    124126        //copy the GameStateCompressed data
    125         memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int )), currentState->compsize );
     127        memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int ) + sizeof(bool)), currentState->compsize );
    126128 
    127129        //clean memory
  • code/branches/FICN/src/network/PacketGenerator.cc

    r415 r437  
    2222ENetPacket* PacketGenerator::acknowledgement( int state, int reliable )
    2323{
    24         std::cout << "generating new acknowledgement" << std::endl;
     24    std::cout << "generating new acknowledgement" << std::endl;
    2525        ack* ackreq = new ack;
    2626        ackreq->id = ACK;
     
    7373        int* gid = new int;
    7474        *gid = GAMESTATE; //first assign the correct enet id
    75         int totalLen = 3*sizeof( int ) + states->compsize; //calculate the total size of the datastream memory
     75        int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
    7676        unsigned char* data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
    7777        memcpy( (void*)(data), (const void*)gid, sizeof( int ) ); //this is the enet id
     
    8181        //this is the uncompressed size of GameStateCompressed data
    8282        memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int));
     83        //since there is a new parameter inside GameStateCompressed, change this function to create packet
     84        memcpy( (void*)(data+4*sizeof(int)), (const void*)states->diffed, sizeof(bool));
    8385        //place the GameStateCompressed data at the end of the enet datastream
    84         memcpy( (void*)(data+4*sizeof( int )), (const void*)states->data, states->compsize );
     86        memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
    8587        //create an enet packet with the generated bytestream
    8688        ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
  • code/branches/FICN/src/network/PacketManager.h

    r422 r437  
    2727        ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
    2828        ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
    29         ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
    30         ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
    31         ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
     29    ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
     30    ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
     31    ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
    3232private:
    3333};
Note: See TracChangeset for help on using the changeset viewer.