Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

networkstuff bluber fubber

File:
1 edited

Legend:

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

    r624 r632  
    9898ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable )
    9999{
    100         int gid = GAMESTATE; //first assign the correct enet id
    101         int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
    102         unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
     100  //std::cout << "packetgenerator" << std::endl;
     101  //std::cout << "states->normsize " << states->normsize << std::endl;
     102  //std::cout << "states->compsize " << states->compsize << std::endl;
     103  int gid = GAMESTATE; //first assign the correct enet id
     104  int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory
     105  //std::cout << "totalLen " << totalLen << std::endl;
     106  unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream
    103107  memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id
    104108  memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id
     
    107111  memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->diffed), sizeof(bool));
    108112  /*(int)*(data) = gid;
    109         (int)*(data+sizeof(int)) = states->id;
     113  (int)*(data+sizeof(int)) = states->id;
    110114  //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream
    111115  (int)*(data+2*sizeof(int)) = states->compsize;
    112         //this is the uncompressed size of GameStateCompressed data
     116  //this is the uncompressed size of GameStateCompressed data
    113117  (int)*(data+3*sizeof(int)) = states->normsize;
    114         //since there is a new parameter inside GameStateCompressed, change this function to create packet
     118  //since there is a new parameter inside GameStateCompressed, change this function to create packet
    115119  (bool)*(data+4*sizeof(int)) = states->diffed;*/
    116         //place the GameStateCompressed data at the end of the enet datastream
    117         memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
    118         //create an enet packet with the generated bytestream
    119         ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
     120  //place the GameStateCompressed data at the end of the enet datastream
     121  memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize );
     122  //create an enet packet with the generated bytestream
     123  ENetPacket *packet = enet_packet_create( data , totalLen, reliable );
    120124  //delete data;
    121         return packet;
     125  return packet;
    122126}
    123127
Note: See TracChangeset for help on using the changeset viewer.