Skip to content

Commit 3833396

Browse files
committedApr 11, 2020
Fix delayed error message in start game tab
1 parent af2e6a6 commit 3833396

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed
 

Diff for: ‎builtin/mainmenu/tab_local.lua

+24-29
Original file line numberDiff line numberDiff line change
@@ -207,40 +207,35 @@ local function main_button_handler(this, fields, name, tabdata)
207207
local selected = core.get_textlist_index("sp_worlds")
208208
gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
209209

210-
if core.settings:get_bool("enable_server") then
211-
if selected ~= nil and gamedata.selected_world ~= 0 then
212-
gamedata.playername = fields["te_playername"]
213-
gamedata.password = fields["te_passwd"]
214-
gamedata.port = fields["te_serverport"]
215-
gamedata.address = ""
216-
217-
core.settings:set("port",gamedata.port)
218-
if fields["te_serveraddr"] ~= nil then
219-
core.settings:set("bind_address",fields["te_serveraddr"])
220-
end
210+
if selected == nil or gamedata.selected_world == 0 then
211+
gamedata.errormessage =
212+
fgettext("No world created or selected!")
213+
return true
214+
end
221215

222-
--update last game
223-
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
224-
if world then
225-
local game = pkgmgr.find_by_gameid(world.gameid)
226-
core.settings:set("menu_last_game", game.id)
227-
end
216+
-- Update last game
217+
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
218+
if world then
219+
local game = pkgmgr.find_by_gameid(world.gameid)
220+
core.settings:set("menu_last_game", game.id)
221+
end
228222

229-
core.start()
230-
else
231-
gamedata.errormessage =
232-
fgettext("No world created or selected!")
223+
if core.settings:get_bool("enable_server") then
224+
gamedata.playername = fields["te_playername"]
225+
gamedata.password = fields["te_passwd"]
226+
gamedata.port = fields["te_serverport"]
227+
gamedata.address = ""
228+
229+
core.settings:set("port",gamedata.port)
230+
if fields["te_serveraddr"] ~= nil then
231+
core.settings:set("bind_address",fields["te_serveraddr"])
233232
end
234233
else
235-
if selected ~= nil and gamedata.selected_world ~= 0 then
236-
gamedata.singleplayer = true
237-
core.start()
238-
else
239-
gamedata.errormessage =
240-
fgettext("No world created or selected!")
241-
end
242-
return true
234+
gamedata.singleplayer = true
243235
end
236+
237+
core.start()
238+
return true
244239
end
245240

246241
if fields["world_create"] ~= nil then

0 commit comments

Comments
 (0)
Please sign in to comment.