forked from Mirrorlandia_minetest/minetest
Fix empty port assertion error in 'Join Game' menu
Pressing "Register" when the port field was empty led to an assertion error inside `create_register_dialog`, it was simply checking the port was a number.
This commit is contained in:
parent
2bed338ef7
commit
b1c8a7d055
@ -346,12 +346,14 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
return true
|
||||
end
|
||||
|
||||
if (fields.btn_mp_login or fields.key_enter)
|
||||
and fields.te_address ~= "" and fields.te_port then
|
||||
local host_filled = (fields.te_address ~= "") and fields.te_port:match("^%s*[1-9][0-9]*%s*$")
|
||||
local te_port_number = tonumber(fields.te_port)
|
||||
|
||||
if (fields.btn_mp_login or fields.key_enter) and host_filled then
|
||||
gamedata.playername = fields.te_name
|
||||
gamedata.password = fields.te_pwd
|
||||
gamedata.address = fields.te_address
|
||||
gamedata.port = tonumber(fields.te_port)
|
||||
gamedata.port = te_port_number
|
||||
|
||||
local enable_split_login_register = core.settings:get_bool("enable_split_login_register")
|
||||
gamedata.allow_login_or_register = enable_split_login_register and "login" or "any"
|
||||
@ -391,10 +393,10 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.btn_mp_register and fields.te_address ~= "" and fields.te_port then
|
||||
if fields.btn_mp_register and host_filled then
|
||||
local idx = core.get_table_index("servers")
|
||||
local server = idx and tabdata.lookup[idx]
|
||||
if server and (server.address ~= fields.te_address or server.port ~= tonumber(fields.te_port)) then
|
||||
if server and (server.address ~= fields.te_address or server.port ~= te_port_number) then
|
||||
server = nil
|
||||
end
|
||||
|
||||
@ -403,7 +405,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
return true
|
||||
end
|
||||
|
||||
local dlg = create_register_dialog(fields.te_address, tonumber(fields.te_port), server)
|
||||
local dlg = create_register_dialog(fields.te_address, te_port_number, server)
|
||||
dlg:set_parent(tabview)
|
||||
tabview:hide()
|
||||
dlg:show()
|
||||
|
Loading…
Reference in New Issue
Block a user