1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Optional reconnect functionality

Enable the server to request the client to reconnect.

This can be done with the now extended minetest.request_shutdown([reason], [reconnect]) setting.
This commit is contained in:
est31 2015-07-17 16:40:41 +02:00
parent 1e0e85f82e
commit 3b50b2766a
25 changed files with 232 additions and 109 deletions

View file

@ -168,8 +168,9 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
ChatBackend chat_backend;
// If an error occurs, this is set to something by menu().
// It is then displayed before the menu shows on the next call to menu()
// It is then displayed before the menu shows on the next call to menu()
std::string error_message;
bool reconnect_requested = false;
bool first_loop = true;
@ -197,7 +198,8 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
*/
guiroot = guienv->addStaticText(L"", core::rect<s32>(0, 0, 10000, 10000));
bool game_has_run = launch_game(error_message, game_params, cmd_args);
bool game_has_run = launch_game(error_message, reconnect_requested,
game_params, cmd_args);
// If skip_main_menu, we only want to startup once
if (skip_main_menu && !first_loop)
@ -233,6 +235,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
receiver->m_touchscreengui = new TouchScreenGUI(device, receiver);
g_touchscreengui = receiver->m_touchscreengui;
#endif
the_game(
kill,
random_input,
@ -245,6 +248,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
current_port,
error_message,
chat_backend,
&reconnect_requested,
gamespec,
simple_singleplayer_mode
);
@ -325,14 +329,16 @@ bool ClientLauncher::init_engine(int log_level)
}
bool ClientLauncher::launch_game(std::string &error_message,
GameParams &game_params, const Settings &cmd_args)
bool reconnect_requested, GameParams &game_params,
const Settings &cmd_args)
{
// Initialize menu data
MainMenuData menudata;
menudata.address = address;
menudata.name = playername;
menudata.port = itos(game_params.socket_port);
menudata.errormessage = error_message;
menudata.address = address;
menudata.name = playername;
menudata.port = itos(game_params.socket_port);
menudata.script_data.errormessage = error_message;
menudata.script_data.reconnect_requested = reconnect_requested;
error_message.clear();
@ -379,11 +385,11 @@ bool ClientLauncher::launch_game(std::string &error_message,
}
}
if (!menudata.errormessage.empty()) {
if (!menudata.script_data.errormessage.empty()) {
/* The calling function will pass this back into this function upon the
* next iteration (if any) causing it to be displayed by the GUI
*/
error_message = menudata.errormessage;
error_message = menudata.script_data.errormessage;
return false;
}