Changeset 1248 for code/branches/network3/src/network/Client.cc
- Timestamp:
- May 8, 2008, 11:53:58 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network3/src/network/Client.cc
r1246 r1248 84 84 // set server address to localhost 85 85 isConnected=false; 86 test_once=false;86 isSynched_=false; 87 87 } 88 88 … … 94 94 Client::Client(std::string address, int port) : client_connection(port, address){ 95 95 isConnected=false; 96 test_once=false;96 isSynched_=false; 97 97 } 98 98 … … 104 104 Client::Client(const char *address, int port) : client_connection(port, address){ 105 105 isConnected=false; 106 test_once=false;106 isSynched_=false; 107 107 } 108 108 … … 229 229 */ 230 230 void Client::tick(float time){ 231 if(client_connection.isConnected() ){231 if(client_connection.isConnected() && isSynched_){ 232 232 COUT(4) << "popping partial gamestate: " << std::endl; 233 233 GameStateCompressed *gs = gamestate.popPartialGameState(); … … 246 246 packet = client_connection.getPacket(); 247 247 COUT(5) << "tick packet size " << packet->dataLength << std::endl; 248 if(!test_once){ 249 elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server) 250 } 248 elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server) 251 249 } 252 250 if(!client_connection.sendPackets()) … … 256 254 257 255 void Client::processGamestate( GameStateCompressed *data, int clientID){ 258 if(!test_once){ 259 int id = data->id; 260 COUT(5) << "received gamestate id: " << data->id << std::endl; 261 if(gamestate.pushGameState(data)){ 262 client_connection.addPacket(pck_gen.acknowledgement(id)); 256 int id = data->id; 257 COUT(5) << "received gamestate id: " << data->id << std::endl; 258 if(gamestate.pushGameState(data)){ 259 if(!isSynched_) 260 isSynched_=true; 261 client_connection.addPacket(pck_gen.acknowledgement(id)); 263 262 // we do this at the end of a tick 264 // if(!client_connection.sendPackets()) 265 // COUT(2) << "Could not send acknowledgment" << std::endl; 266 } 267 // test_once=true; 263 if(!client_connection.sendPackets()) 264 COUT(2) << "Could not send acknowledgment" << std::endl; 268 265 } 269 266 } … … 275 272 id->setNetworkID(clid->clid); 276 273 COUT(4) << "Client: received and set network id: " << clid->clid << "; classname: " << clid->message << std::endl; 274 delete clid; 277 275 return; 278 276 } … … 280 278 void Client::processChat( chat *data){ 281 279 COUT(0) << "Server: " << data->message << std::endl; 280 delete[] data->message; 281 delete data; 282 282 } 283 283 … … 286 286 clientID_ = w->clientID; 287 287 shipID_ = w->shipID; 288 delete w; 288 289 return true; 289 290 }
Note: See TracChangeset
for help on using the changeset viewer.