10s timeout when connecting to server

stable-0.4
SmallJoker 2015-04-09 19:59:32 +02:00 committed by est31
parent d4d561fbcd
commit 5f0b36b8b7
1 changed files with 13 additions and 2 deletions

View File

@ -2181,7 +2181,10 @@ bool Game::connectToServer(const std::string &playername,
input->clear();
FpsControl fps_control = { 0 };
f32 dtime; // in seconds
f32 dtime;
f32 wait_time = 0; // in seconds
fps_control.last_time = device->getTimer()->getTime();
while (device->run()) {
@ -2213,6 +2216,13 @@ bool Game::connectToServer(const std::string &playername,
break;
}
wait_time += dtime;
if (wait_time > 10) {
*error_message = "Connection timed out.";
errorstream << *error_message << std::endl;
break;
}
// Update status
showOverlayMessage(wgettext("Connecting to server..."), dtime, 20);
}
@ -2232,6 +2242,8 @@ bool Game::getServerContent(bool *aborted)
FpsControl fps_control = { 0 };
f32 dtime; // in seconds
fps_control.last_time = device->getTimer()->getTime();
while (device->run()) {
limitFps(&fps_control, &dtime);
@ -4137,7 +4149,6 @@ inline void Game::limitFps(FpsControl *fps_timings, f32 *dtime)
// not using getRealTime is necessary for wine
device->getTimer()->tick(); // Maker sure device time is up-to-date
u32 time = device->getTimer()->getTime();
u32 last_time = fps_timings->last_time;
if (time > last_time) // Make sure time hasn't overflowed