From 294b28d530f30d662d97077d2dd9eb2ea69c812b Mon Sep 17 00:00:00 2001 From: stujones11 Date: Sun, 19 May 2019 21:29:41 +0100 Subject: [PATCH] Auto-reconnect to multicraft servers --- builtin/fstk/ui.lua | 7 +++++++ builtin/mainmenu/tab_online.lua | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/builtin/fstk/ui.lua b/builtin/fstk/ui.lua index 2a5e84fba..71b9427de 100644 --- a/builtin/fstk/ui.lua +++ b/builtin/fstk/ui.lua @@ -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:") .. diff --git a/builtin/mainmenu/tab_online.lua b/builtin/mainmenu/tab_online.lua index 54b567490..dd6c19dbb 100644 --- a/builtin/mainmenu/tab_online.lua +++ b/builtin/mainmenu/tab_online.lua @@ -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)