diff options
author | Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com> | 2018-01-13 18:07:16 +0700 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-01-13 12:07:16 +0100 |
commit | 792752997c5ae2aaa4f54d0a2e2af2a96d7d1e9f (patch) | |
tree | 568b578dd8cd5d0e579a4debc560d088c880d5e7 /src/game.cpp | |
parent | fad263dec9e1fa7ae0886f768e22d8ee74e8553b (diff) | |
download | minetest-792752997c5ae2aaa4f54d0a2e2af2a96d7d1e9f.tar.gz minetest-792752997c5ae2aaa4f54d0a2e2af2a96d7d1e9f.tar.bz2 minetest-792752997c5ae2aaa4f54d0a2e2af2a96d7d1e9f.zip |
Add confirmation on new player registration (#6849)
* Attempt to add registration confirmation
Using SRP auth mechanism, if server sent AUTH_MECHANISM_FIRST_SRP that means the player isn't exist.
Also tell player about the server and chosen username.
Local game has localhost as IP address of the server.
Add RenderingEngine::draw_menu_scene() to draw GUI and clouds background.
aborted -> connection_aborted
* Rewrite information message text
Client::promptConfirmRegister() -> Client::promptConfirmRegistration()
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/src/game.cpp b/src/game.cpp index 1ab360d3c..32ec6b73e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -41,6 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "filesys.h" #include "gettext.h" #include "gui/guiChatConsole.h" +#include "gui/guiConfirmRegistration.h" #include "gui/guiFormSpecMenu.h" #include "gui/guiKeyChangeMenu.h" #include "gui/guiPasswordChange.h" @@ -1302,6 +1303,7 @@ private: EventManager *eventmgr = nullptr; QuicktuneShortcutter *quicktune = nullptr; + bool registration_confirmation_shown = false; std::unique_ptr<GameUI> m_game_ui; GUIChatConsole *gui_chat_console = nullptr; // Free using ->Drop() @@ -1900,10 +1902,10 @@ bool Game::initGui() bool Game::connectToServer(const std::string &playername, const std::string &password, std::string *address, u16 port, - bool *connect_ok, bool *aborted) + bool *connect_ok, bool *connection_aborted) { *connect_ok = false; // Let's not be overly optimistic - *aborted = false; + *connection_aborted = false; bool local_server_mode = false; showOverlayMessage("Resolving address...", 0, 15); @@ -1946,6 +1948,8 @@ bool Game::connectToServer(const std::string &playername, if (!client) return false; + client->m_simple_singleplayer_mode = simple_singleplayer_mode; + infostream << "Connecting to server at "; connect_address.print(&infostream); infostream << std::endl; @@ -1985,6 +1989,9 @@ bool Game::connectToServer(const std::string &playername, } // Break conditions + if (*connection_aborted) + break; + if (client->accessDenied()) { *error_message = "Access denied. Reason: " + client->accessDeniedReason(); @@ -1994,21 +2001,32 @@ bool Game::connectToServer(const std::string &playername, } if (wasKeyDown(KeyType::ESC) || input->wasKeyDown(CancelKey)) { - *aborted = true; + *connection_aborted = true; infostream << "Connect aborted [Escape]" << std::endl; break; } - wait_time += dtime; - // Only time out if we aren't waiting for the server we started - if (!address->empty() && wait_time > 10) { - *error_message = "Connection timed out."; - errorstream << *error_message << std::endl; - break; - } + if (client->m_is_registration_confirmation_state) { + if (registration_confirmation_shown) { + // Keep drawing the GUI + RenderingEngine::draw_menu_scene(guienv, dtime, true); + } else { + registration_confirmation_shown = true; + (new GUIConfirmRegistration(guienv, guienv->getRootGUIElement(), -1, + &g_menumgr, client, playername, password, *address, connection_aborted))->drop(); + } + } else { + wait_time += dtime; + // Only time out if we aren't waiting for the server we started + if (!address->empty() && wait_time > 10) { + *error_message = "Connection timed out."; + errorstream << *error_message << std::endl; + break; + } - // Update status - showOverlayMessage("Connecting to server...", dtime, 20); + // Update status + showOverlayMessage("Connecting to server...", dtime, 20); + } } } catch (con::PeerNotFoundException &e) { // TODO: Should something be done here? At least an info/error |