Skip to content

Commit

Permalink
10s timeout when connecting to server
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker authored and est31 committed Apr 17, 2015
1 parent d4d561f commit 5f0b36b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/game.cpp
Expand Up @@ -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()) {

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down

10 comments on commit 5f0b36b

@HybridDog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l wanted to play minetest in singleplayer mode but l got the connection timed out message.
l use many mods:

ac, ambience, antiguest, as_transport, asphalt, asphaltstairs, beds, boats, bobblocks, bones, bookmarks, bucket, builtin_item, bushes_classic, caca, cannons, carts, chain_transfer, clams, clean, command_tool, compressed_cobble, computer, concrete, concretestairs, conifers, connected_chests, connected_textures, constructionarea, creative, crops, darkage, default, delineator, diamonds, digilines, digilines_inventory, digilines_lcd, digilines_lightsensor, digilines_rtc, dogblocks, doors, dye, emergencyphone, eridium, explore_map, extinguisher, extrablocks, extranodes, fancy_elevator, farming, farming_plus, fire, firearms, fireworks, flowers, flowers_plus, fraktaltest, function_delayer, give_initial_stuff, glow, gosirea, grass, greenscreens, gt1111, habitat, hand, heads, hnoise, home_builder, hydro, influencia, intllib, inventory_plus, item_drop, itemframes, jdc_lamps, jdukebox, jukebox, jungletree, labels, lantern, laser, lavacooling, locked_sign, ltool, luacmd, lunit, manholes, mapp, maze, mese_fence, mesecar, mesecons, mesecons_alias, mesecons_blinkyplant, mesecons_button, mesecons_commandblock, mesecons_delayer, mesecons_detector, mesecons_doors, mesecons_extrawires, mesecons_gates, mesecons_hydroturbine, mesecons_insulated, mesecons_lamp, mesecons_lightstone, mesecons_luacontroller, mesecons_materials, mesecons_microcontroller, mesecons_movestones, mesecons_mvps, mesecons_noteblock, mesecons_pistons, mesecons_powerplant, mesecons_pressureplates, mesecons_random, mesecons_receiver, mesecons_solarpanel, mesecons_stickyblocks, mesecons_switch, mesecons_teleporter, mesecons_torch, mesecons_walllever, mgtest, mining_plus, misstairs, mo, modmenu, money, more_chests, moreblocks, morecobblenodes, morefences, moreladders, moreores, moretechnictools, moretrees, moss, mudbrick, multitest, music, my_castle_doors, my_door_wood, my_fancy_doors, my_hidden_doors, my_misc_doors, mydeck, nether, noairblocks, nodebox_creator, nuke, nyanland, outgame_intervention, painting, panola, pathogen, pathv6alt, pipeworks, plants_lib, plasmalamp, poisonivy, portal, potions, projects, quartz, quests, radio, realclocks, replacer, riesenpilz, roadsigns, roadworks, rotten_papyrus, ruins, rulesaccept, screwdriver, seacobble, seaglass, seagravel, sealamps, seaplants, seastone, seastonebrick, seawrecks, sethome, shadows, shears, shooter, simple_machines, simple_robots, skins, small_paths, snow, special, special_picks, stairs, stairsshine, stay_inside, steel, steelsupport, streetlamps, streetsawards, streetsconcrete, streetshotfix, streetsmod, streetspoles, sumpf, superpick, tbm, technic, technic_chests, technic_extras, technic_worldgen, teleporters, tetris, titanium, tnt, trafficlight, trash_can, trashcan, travelnet, treecapitator, ufos, unified_inventory, urban, usesdirt, vector_extras, vessels, vines, vulkane, weather, weirdores, whiteshell, wool, workers, worldedit, worldedit_commands, worldedit_extras, worldedit_gui, worldedit_infinity, worldedit_limited, worldedit_shortcommands, wrench, wz2100, xpanes and zcg

@est31
Copy link
Contributor

@est31 est31 commented on 5f0b36b Apr 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps this should be disabled for singleplayer.

@nerzhul
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have playername here. We can compare it to disable the timeout. Can you provide this patch @est31, i'm absent today.

@ShadowNinja
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nerzhul: Or use is_local_server or equivalent...

@est31
Copy link
Contributor

@est31 est31 commented on 5f0b36b Apr 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed in f1a41e4 using the same check as Game::init does for actually creating a server.

@C1ffisme
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HybridDog

You have a mod called wz2100?

Warzone 2100?

Anyway, yeah. Good for fixing this. Sorry for butting my head in, but I had to give my 2 cents.

You use a lot of mods, HybridDog.

@HybridDog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a mod called wz2100?

Warzone 2100?

Yes, it currently only adds a nexus link item (with the sounds) which can be used to steal others chests.
l thought about adding working tanks, trucks and towers but l lost interest.

You use a lot of mods, HybridDog.

yes, l know almost every one of them

@C1ffisme
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.

Sorry about the un-related comment. I just saw it and HAD to speak up.

Maybe you should start your mod up again. You can make some kind of turret for towers, trucks can use specified schematics, and tanks can be 3 entities (Body, weapon and transport)

@HybridDog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but entities are so laggy

@C1ffisme
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. True.

Okay, before we annoy everybody with this conversation, why not post the mod up on github and make an issue for this discussion. I can imagine everybody is seeing our smalltalk conversation.

Sorry other github users.

Please sign in to comment.