diff options
author | est31 <MTest31@outlook.com> | 2015-07-17 16:40:41 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-07-23 07:38:13 +0200 |
commit | 3b50b2766aeb09c9fc0ad0ea07426bb2187df3d7 (patch) | |
tree | 5ae54f8dcfc2b496a4937dc8ccf524d7c99f4e23 /src/client | |
parent | 1e0e85f82e030e761c36ba5a12427bec0fb4e4f2 (diff) | |
download | minetest-3b50b2766aeb09c9fc0ad0ea07426bb2187df3d7.tar.gz minetest-3b50b2766aeb09c9fc0ad0ea07426bb2187df3d7.tar.bz2 minetest-3b50b2766aeb09c9fc0ad0ea07426bb2187df3d7.zip |
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.
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/clientlauncher.cpp | 24 | ||||
-rw-r--r-- | src/client/clientlauncher.h | 4 |
2 files changed, 17 insertions, 11 deletions
diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index 50f0690d8..bad5c384c 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -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; } diff --git a/src/client/clientlauncher.h b/src/client/clientlauncher.h index 09f8c039a..49ceefc52 100644 --- a/src/client/clientlauncher.h +++ b/src/client/clientlauncher.h @@ -92,8 +92,8 @@ protected: void init_args(GameParams &game_params, const Settings &cmd_args); bool init_engine(int log_level); - bool launch_game(std::string &error_message, GameParams &game_params, - const Settings &cmd_args); + bool launch_game(std::string &error_message, bool reconnect_requested, + GameParams &game_params, const Settings &cmd_args); void main_menu(MainMenuData *menudata); bool create_engine_device(int log_level); |