mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Mainmenu: Trim whitespace from player name, address, port
This commit is contained in:
parent
251bf0ec31
commit
b99f90ed80
1 changed files with 8 additions and 4 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include "common/c_converter.h"
|
#include "common/c_converter.h"
|
||||||
#include "gui/guiOpenURL.h"
|
#include "gui/guiOpenURL.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
#include "util/string.h"
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
std::string ModApiMainMenu::getTextData(lua_State *L, const std::string &name)
|
std::string ModApiMainMenu::getTextData(lua_State *L, const std::string &name)
|
||||||
|
@ -126,10 +127,13 @@ int ModApiMainMenu::l_start(lua_State *L)
|
||||||
data->simple_singleplayer_mode = getBoolData(L,"singleplayer",valid);
|
data->simple_singleplayer_mode = getBoolData(L,"singleplayer",valid);
|
||||||
data->do_reconnect = getBoolData(L, "do_reconnect", valid);
|
data->do_reconnect = getBoolData(L, "do_reconnect", valid);
|
||||||
if (!data->do_reconnect) {
|
if (!data->do_reconnect) {
|
||||||
data->name = getTextData(L,"playername");
|
// Get rid of trailing whitespace in name (may be added by autocompletion
|
||||||
data->password = getTextData(L,"password");
|
// on Android, which would then cause SERVER_ACCESSDENIED_WRONG_CHARS_IN_NAME).
|
||||||
data->address = getTextData(L,"address");
|
data->name = trim(getTextData(L, "playername"));
|
||||||
data->port = getTextData(L,"port");
|
data->password = getTextData(L, "password");
|
||||||
|
// There's no reason for these to have leading/trailing whitespace either.
|
||||||
|
data->address = trim(getTextData(L, "address"));
|
||||||
|
data->port = trim(getTextData(L, "port"));
|
||||||
|
|
||||||
const auto val = getTextData(L, "allow_login_or_register");
|
const auto val = getTextData(L, "allow_login_or_register");
|
||||||
if (val == "login")
|
if (val == "login")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue