From: Perttu Ahola Date: Sat, 10 Mar 2012 21:28:51 +0000 (+0200) Subject: Tune "Connecting to server" and "Waiting content" screens X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=2de8f915f877e3b6779576c19e523c854966c7cd;p=zefram%2Fminetest%2Fminetest_engine.git Tune "Connecting to server" and "Waiting content" screens --- diff --git a/src/game.cpp b/src/game.cpp index 616d0586..1c5b065b 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -709,7 +709,7 @@ void the_game( server->start(port); } - { // Client scope + do{ // Client scope (breakable do-while(0)) /* Create client @@ -738,10 +738,9 @@ void the_game( catch(ResolveError &e) { errorstream<<"Couldn't resolve address"<remove(); - return; + // Break out of client scope + break; } /* @@ -757,11 +756,12 @@ void the_game( Wait for server to accept connection */ bool could_connect = false; + bool connect_aborted = false; try{ float frametime = 0.033; - const float timeout = 10.0; float time_counter = 0.0; - for(;;) + input->clear(); + while(device->run()) { // Update client and server client.step(frametime); @@ -774,16 +774,21 @@ void the_game( break; } // Break conditions - if(client.accessDenied()) + if(client.accessDenied()){ + error_message = L"Access denied. Reason: " + +client.accessDeniedReason(); break; - if(time_counter >= timeout) + } + if(input->wasKeyDown(EscapeKey)){ + connect_aborted = true; break; + } // Display status std::wostringstream ss; - ss<remove(); - return; + if(!could_connect){ + if(error_message == L"" && !connect_aborted) + error_message = L"Connection failed"; + // Break out of client scope + break; } /* Wait until content has been received */ bool got_content = false; + bool content_aborted = false; { float frametime = 0.033; - const float timeout = 30.0; float time_counter = 0.0; - for(;;) + input->clear(); + while(device->run()) { // Update client and server client.step(frametime); @@ -837,16 +833,18 @@ void the_game( break; } // Break conditions - if(!client.connectedAndInitialized()) + if(!client.connectedAndInitialized()){ + error_message = L"Client disconnected"; break; - if(time_counter >= timeout) + } + if(input->wasKeyDown(EscapeKey)){ + content_aborted = true; break; + } // Display status std::wostringstream ss; - ss<