Changeset 1245 for code/branches/network3/src/network/Client.cc
- Timestamp:
- May 7, 2008, 4:39:42 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/network/Client.cc
r1233 r1245 84 84 // set server address to localhost 85 85 isConnected=false; 86 test_once=false; 86 87 } 87 88 … … 93 94 Client::Client(std::string address, int port) : client_connection(port, address){ 94 95 isConnected=false; 96 test_once=false; 95 97 } 96 98 … … 102 104 Client::Client(const char *address, int port) : client_connection(port, address){ 103 105 isConnected=false; 106 test_once=false; 104 107 } 105 108 … … 226 229 */ 227 230 void Client::tick(float time){ 231 if(client_connection.isConnected()){ 232 COUT(4) << "popping partial gamestate: " << std::endl; 233 GameStateCompressed *gs = gamestate.popPartialGameState(); 234 if(gs){ 235 COUT(4) << "client tick: sending gs " << gs << std::endl; 236 if(client_connection.addPacket(pck_gen.gstate(gs))) 237 if(!client_connection.sendPackets()) 238 COUT(3) << "Problem sending partial gamestate" << std::endl; 239 // now delete it to save memory 240 delete [] gs->data; 241 delete gs; 242 } 243 } 228 244 ENetPacket *packet; 229 245 // stop if the packet queue is empty … … 231 247 packet = client_connection.getPacket(); 232 248 COUT(5) << "tick packet size " << packet->dataLength << std::endl; 233 elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server) 249 if(!test_once){ 250 elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server) 251 } 234 252 } 235 253 return; 236 254 } 237 255 238 void Client::processGamestate( GameStateCompressed *data){ 239 int id = data->id; 240 COUT(5) << "received gamestate id: " << data->id << std::endl; 241 if(gamestate.pushGameState(data)){ 242 client_connection.addPacket(pck_gen.acknowledgement(id)); 243 if(!client_connection.sendPackets()) 244 COUT(2) << "Could not send acknowledgment" << std::endl; 256 void Client::processGamestate( GameStateCompressed *data, int clientID){ 257 if(!test_once){ 258 int id = data->id; 259 COUT(5) << "received gamestate id: " << data->id << std::endl; 260 if(gamestate.pushGameState(data)){ 261 client_connection.addPacket(pck_gen.acknowledgement(id)); 262 if(!client_connection.sendPackets()) 263 COUT(2) << "Could not send acknowledgment" << std::endl; 264 } 265 // test_once=true; 245 266 } 246 267 } … … 263 284 clientID_ = w->clientID; 264 285 shipID_ = w->shipID; 265 286 return true; 266 287 } 267 288
Note: See TracChangeset
for help on using the changeset viewer.