aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2015-04-09 19:59:32 +0200
committerest31 <MTest31@outlook.com>2015-04-17 10:40:48 +0200
commit5f0b36b8b70faa36b20343342567471c8f50b7f2 (patch)
treed11a01f5bc34c23767687bd63ab8275fcc0f04bc /src
parentd4d561fbcdac0175584e4f62bc6c3bfdf83510f1 (diff)
downloadminetest-5f0b36b8b70faa36b20343342567471c8f50b7f2.tar.gz
minetest-5f0b36b8b70faa36b20343342567471c8f50b7f2.tar.bz2
minetest-5f0b36b8b70faa36b20343342567471c8f50b7f2.zip
10s timeout when connecting to server
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 6bddfe905..24ecc99d2 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -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