Auto-reconnect to multicraft servers

This commit is contained in:
stujones11 2019-05-19 21:29:41 +01:00 committed by Maksim
parent 05f58b3a04
commit 294b28d530
2 changed files with 16 additions and 0 deletions

View File

@ -82,6 +82,13 @@ function ui.update()
-- handle errors
if gamedata ~= nil and gamedata.reconnect_requested then
if core.settings:get_bool("auto_connect") == true then
gamedata.reconnect_requested = false
gamedata.errormessage = nil
gamedata.do_reconnect = true
core.start()
return
end
formspec = wordwrap_quickhack(gamedata.errormessage or "")
formspec = "size[12,5]" ..
"label[0.5,0;" .. fgettext("The server has requested a reconnect:") ..

View File

@ -340,6 +340,15 @@ local function main_button_handler(tabview, fields, name, tabdata)
gamedata.serverdescription = ""
end
local auto_connect = false
for _, server in pairs(serverlist) do
if server.server_id and server.address == gamedata.address then
auto_connect = true
break
end
end
core.settings:set_bool("auto_connect", auto_connect)
core.settings:set("address", fields.te_address)
core.settings:set("remote_port", fields.te_port)