Skip to content

Commit 5f0b36b

Browse files
SmallJokerest31
authored andcommittedApr 17, 2015
10s timeout when connecting to server
1 parent d4d561f commit 5f0b36b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed
 

Diff for: ‎src/game.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,10 @@ bool Game::connectToServer(const std::string &playername,
21812181
input->clear();
21822182

21832183
FpsControl fps_control = { 0 };
2184-
f32 dtime; // in seconds
2184+
f32 dtime;
2185+
f32 wait_time = 0; // in seconds
2186+
2187+
fps_control.last_time = device->getTimer()->getTime();
21852188

21862189
while (device->run()) {
21872190

@@ -2213,6 +2216,13 @@ bool Game::connectToServer(const std::string &playername,
22132216
break;
22142217
}
22152218

2219+
wait_time += dtime;
2220+
if (wait_time > 10) {
2221+
*error_message = "Connection timed out.";
2222+
errorstream << *error_message << std::endl;
2223+
break;
2224+
}
2225+
22162226
// Update status
22172227
showOverlayMessage(wgettext("Connecting to server..."), dtime, 20);
22182228
}
@@ -2232,6 +2242,8 @@ bool Game::getServerContent(bool *aborted)
22322242
FpsControl fps_control = { 0 };
22332243
f32 dtime; // in seconds
22342244

2245+
fps_control.last_time = device->getTimer()->getTime();
2246+
22352247
while (device->run()) {
22362248

22372249
limitFps(&fps_control, &dtime);
@@ -4137,7 +4149,6 @@ inline void Game::limitFps(FpsControl *fps_timings, f32 *dtime)
41374149
// not using getRealTime is necessary for wine
41384150
device->getTimer()->tick(); // Maker sure device time is up-to-date
41394151
u32 time = device->getTimer()->getTime();
4140-
41414152
u32 last_time = fps_timings->last_time;
41424153

41434154
if (time > last_time) // Make sure time hasn't overflowed

0 commit comments

Comments
 (0)