Changeset 632 for code/branches/FICN/src/network/PacketGenerator.cc
- Timestamp:
- Dec 19, 2007, 12:28:42 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/PacketGenerator.cc
r624 r632 98 98 ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable ) 99 99 { 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 103 107 memcpy( (void*)(data), (const void*)&gid, sizeof( int ) ); //this is the enet id 104 108 memcpy( (void*)(data+sizeof(int)), (const void*)&(states->id), sizeof(int) ); //the GameStateCompressed id … … 107 111 memcpy( (void*)(data+4*sizeof(int)), (const void*)&(states->diffed), sizeof(bool)); 108 112 /*(int)*(data) = gid; 109 113 (int)*(data+sizeof(int)) = states->id; 110 114 //this is the compressed size of the GameStateCompressed data, place at 3th position of the enet datastream 111 115 (int)*(data+2*sizeof(int)) = states->compsize; 112 116 //this is the uncompressed size of GameStateCompressed data 113 117 (int)*(data+3*sizeof(int)) = states->normsize; 114 118 //since there is a new parameter inside GameStateCompressed, change this function to create packet 115 119 (bool)*(data+4*sizeof(int)) = states->diffed;*/ 116 117 118 119 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 ); 120 124 //delete data; 121 125 return packet; 122 126 } 123 127
Note: See TracChangeset
for help on using the changeset viewer.