mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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()
This commit is contained in:
parent
fad263dec9
commit
792752997c
9 changed files with 378 additions and 13 deletions
42
src/game.cpp
42
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue