Changeset 620 for code/branches/FICN/src/network/PacketGenerator.cc
- Timestamp:
- Dec 18, 2007, 5:51:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/PacketGenerator.cc
r514 r620 98 98 ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable ) 99 99 { 100 int* gid = new int; 101 *gid = GAMESTATE; //first assign the correct enet id 100 int gid = GAMESTATE; //first assign the correct enet id 102 101 int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory 103 unsigned char* data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream 104 memcpy( (void*)(data), (const void*)gid, sizeof( int ) ); //this is the enet id 105 memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id 106 //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream 107 memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->compsize), sizeof(int)); 102 unsigned char *data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream 103 memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id 104 memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id 105 memcpy( (void*)(data+2*sizeof(int)), (const void*)&(states->compsize), sizeof(int)); 106 memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int)); 107 memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->diffed), sizeof(bool)); 108 /*(int)*(data) = gid; 109 (int)*(data+sizeof(int)) = states->id; 110 //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream 111 (int)*(data+2*sizeof(int)) = states->compsize; 108 112 //this is the uncompressed size of GameStateCompressed data 109 memcpy( (void*)(data+3*sizeof(int)), (const void*)&(states->normsize), sizeof(int));113 (int)*(data+3*sizeof(int)) = states->normsize; 110 114 //since there is a new parameter inside GameStateCompressed, change this function to create packet 111 memcpy( (void*)(data+4*sizeof(int)), (const void*)states->diffed, sizeof(bool)); 115 (bool)*(data+4*sizeof(int)) = states->diffed;*/ 112 116 //place the GameStateCompressed data at the end of the enet datastream 113 117 memcpy( (void*)(data+4*sizeof( int ) + sizeof(bool)), (const void*)states->data, states->compsize ); 114 118 //create an enet packet with the generated bytestream 115 119 ENetPacket *packet = enet_packet_create( data , totalLen, reliable ); 116 120 //delete data; 117 121 return packet; 118 122 }
Note: See TracChangeset
for help on using the changeset viewer.