Changeset 405
- Timestamp:
- Dec 5, 2007, 4:40:46 PM (17 years ago)
- Location:
- code/branches/FICN/src/network
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/Client.cc
r401 r405 73 73 */ 74 74 bool Client::sendMouse(double x, double y){ 75 ENetEvent event;76 75 // generate packet and add it to the queue 77 76 if(!client_connection.addPacket(pck_gen.mousem(x, y))) … … 87 86 */ 88 87 bool Client::sendKeyboard(char key_code){ 89 ENetEvent event;90 88 // generate packet and add it to queue 91 89 if(!client_connection.addPacket(pck_gen.keystrike(key_code))) … … 115 113 */ 116 114 bool Client::addKeyboard(char key_code){ 117 ENetEvent event;118 115 // generate packet and add it to queue 119 116 if(client_connection.addPacket(pck_gen.keystrike(key_code))) … … 149 146 } 150 147 151 void Client::processGamestate( GameState *data){148 void Client::processGamestate( GameStateCompressed *data){ 152 149 gamestate.loadSnapshot( *data ); 153 150 return; -
code/branches/FICN/src/network/Client.h
r400 r405 56 56 57 57 // implement data processing functions of PacketDecoder 58 void processGamestate( GameState *data);58 void processGamestate( GameStateCompressed *data); 59 59 void processClassid(classid *clid); 60 60 -
code/branches/FICN/src/network/GameStateManager.cc
r403 r405 27 27 * @return struct of type gamestate containing the size of the whole gamestate and a pointer linking to the flat list 28 28 */ 29 GameState GameStateManager::getSnapshot(int id)29 GameStateCompressed GameStateManager::getSnapshot(int id) 30 30 { 31 31 //the size of the gamestate … … 63 63 } 64 64 retval.size=totalsize; 65 return retval;65 return compress(retval); 66 66 } 67 67 … … 70 70 * @param state a GameState struct containing the size of the gamestate and a pointer linking to a flat list (returned by getSnapshot) 71 71 */ 72 bool GameStateManager::loadSnapshot(GameState 72 bool GameStateManager::loadSnapshot(GameStateCompressed compstate) 73 73 { 74 GameState state = decompress(compstate); 74 75 unsigned char *data=state.data; 75 76 // get the start of the Synchronisable list … … 125 126 } 126 127 127 GameState GameStateManager::encode(GameState a, GameState b){128 GameStateCompressed GameStateManager::encode(GameState a, GameState b){ 128 129 GameState r = diff(a,b); 129 130 return compress(r); 130 131 } 131 132 132 GameState GameStateManager::decode(GameState a, GameState x){133 GameState GameStateManager::decode(GameState a, GameStateCompressed x){ 133 134 GameState t = decompress(x); 134 135 return diff(a, t); … … 167 168 } 168 169 169 GameState GameStateManager::compress(GameState a){ 170 a. 171 return a; 170 GameStateCompressed GameStateManager::compress(GameState a){ 171 //to be implemented 172 GameStateCompressed b; 173 return b; 172 174 } 173 175 174 GameState GameStateManager::decompress(GameState a){176 GameState GameStateManager::decompress(GameStateCompressed a){ 175 177 // to be implemented !!!!!!!!!!!!!! 176 return a; 178 GameState b; 179 return b; 177 180 } 178 181 -
code/branches/FICN/src/network/GameStateManager.h
r403 r405 62 62 GameStateManager(); 63 63 ~GameStateManager(); 64 GameState getSnapshot(int id);65 bool loadSnapshot(GameState state);66 GameState encode(GameState a, GameState b);67 GameState decode(GameState a, GameState x);64 GameStateCompressed getSnapshot(int id); 65 bool loadSnapshot(GameStateCompressed state); 66 GameStateCompressed encode(GameState a, GameState b); 67 GameState decode(GameState a, GameStateCompressed x); 68 68 private: 69 69 void removeObject(orxonox::Iterator<Synchronisable> &it); 70 70 GameState diff(GameState a, GameState b); 71 GameState compress(GameState a);72 GameState decompress(GameState a);71 GameStateCompressed compress(GameState a); 72 GameState decompress(GameStateCompressed a); 73 73 }; 74 74 -
code/branches/FICN/src/network/PacketDecoder.cc
r403 r405 121 121 memcpy( (void*)&(currentState->normsize), (const void*)(data+3*sizeof( int )), sizeof( int ) ); 122 122 //since data is not allocated, because it's just a pointer, allocate it with size of gamestatedatastream 123 currentState->data = (unsigned char*)(malloc( currentState-> size ));123 currentState->data = (unsigned char*)(malloc( currentState->compsize )); 124 124 //copy the GameStateCompressed data 125 125 memcpy( (void*)(currentState->data), (const void*)(data+4*sizeof( int )), currentState->compsize ); … … 186 186 { 187 187 cout << "id of GameStateCompressed: " << data->id << endl; 188 cout << "size of GameStateCompressed: " << data-> size << endl;188 cout << "size of GameStateCompressed: " << data->compsize << endl; 189 189 } 190 190 -
code/branches/FICN/src/network/PacketGenerator.cc
r403 r405 72 72 ENetPacket* PacketGenerator::gstate( GameStateCompressed* states, int reliable ) 73 73 { 74 int* gid; *gid = GAMESTATE; //first assign the correct enet id 75 int totalLen = 3*sizeof( int ) + states->size; //calculate the total size of the datastream memory 74 int* gid = new int; 75 *gid = GAMESTATE; //first assign the correct enet id 76 int totalLen = 3*sizeof( int ) + states->compsize; //calculate the total size of the datastream memory 76 77 unsigned char* data = (unsigned char*)malloc( totalLen ); //allocate the memory for datastream 77 78 memcpy( (void*)(data), (const void*)gid, sizeof( int ) ); //this is the enet id -
code/branches/FICN/src/network/PacketManager.h
r403 r405 33 33 ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE ); 34 34 ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE ); 35 ENetPacket* gstate( GameState * states, int reliable = ENET_PACKET_FLAG_RELIABLE );35 ENetPacket* gstate( GameStateCompressed* states, int reliable = ENET_PACKET_FLAG_RELIABLE ); 36 36 ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE ); 37 37 private: … … 116 116 void printKey( keyboard* data ); 117 117 void printChat( chat* data ); 118 void printGamestate( GameState * data );118 void printGamestate( GameStateCompressed* data ); 119 119 void printClassid( classid *cid); 120 120 }; -
code/branches/FICN/src/network/Synchronisable.cc
r401 r405 131 131 return false; //there was some problem with registerVar 132 132 } 133 return true; 133 134 } 134 135
Note: See TracChangeset
for help on using the changeset viewer.