Changeset 437 for code/branches/FICN/src/network
- Timestamp:
- Dec 9, 2007, 1:46:03 PM (17 years ago)
- Location:
- code/branches/FICN/src/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/PacketDecoder.cc
r415 r437 44 44 return true; 45 45 break; 46 47 48 49 46 case CLASSID: 47 clid(packet); 48 return true; 49 break; 50 50 } 51 51 return false; … … 120 120 //size of uncompressed data 121 121 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)); 122 124 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 123 125 currentState->data = (unsigned char*)(malloc( currentState->compsize )); 124 126 //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 ); 126 128 127 129 //clean memory -
code/branches/FICN/src/network/PacketGenerator.cc
r415 r437 22 22 ENetPacket* PacketGenerator::acknowledgement( int state, int reliable ) 23 23 { 24 24 std::cout << "generating new acknowledgement" << std::endl; 25 25 ack* ackreq = new ack; 26 26 ackreq->id = ACK; … … 73 73 int* gid = new int; 74 74 *gid = GAMESTATE; //first assign the correct enet id 75 int totalLen = 3*sizeof( int) + states->compsize; //calculate the total size of the datastream memory75 int totalLen = 4*sizeof( int ) + sizeof(bool) + states->compsize; //calculate the total size of the datastream memory 76 76 unsigned char* data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream 77 77 memcpy( (void*)(data), (const void*)gid, sizeof( int ) ); //this is the enet id … … 81 81 //this is the uncompressed size of GameStateCompressed data 82 82 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)); 83 85 //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 ); 85 87 //create an enet packet with the generated bytestream 86 88 ENetPacket *packet = enet_packet_create( data , totalLen, reliable ); -
code/branches/FICN/src/network/PacketManager.h
r422 r437 27 27 ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE ); 28 28 ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE ); 29 30 31 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 ); 32 32 private: 33 33 };
Note: See TracChangeset
for help on using the changeset viewer.