fix crash on play/start with empty world list make enter button work in create world dialog

This commit is contained in:
sapier 2013-07-08 21:02:42 +02:00 committed by Nils Dagsson Moskopp
parent 65702a45bb
commit c82ccfcf2d
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 10 additions and 1 deletions

View File

@ -332,6 +332,10 @@ function menu.filtered_index_to_plain(filtered_index)
local temp_idx = 0 local temp_idx = 0
if menu.worldlist == nil then
return -1
end
for i=1,#menu.worldlist,1 do for i=1,#menu.worldlist,1 do
if menu.worldlist[i].gameid == current_game.id then if menu.worldlist[i].gameid == current_game.id then
temp_idx = temp_idx +1 temp_idx = temp_idx +1
@ -418,6 +422,10 @@ function menu.update_last_game(world_idx)
if gamedata.selected_world <= #menu.worldlist then if gamedata.selected_world <= #menu.worldlist then
local world = menu.worldlist[gamedata.selected_world] local world = menu.worldlist[gamedata.selected_world]
if world == nil then
return
end
for i=1,#gamemgr.games,1 do for i=1,#gamemgr.games,1 do
if gamemgr.games[i].id == world.gameid then if gamemgr.games[i].id == world.gameid then
menu.last_game = i menu.last_game = i
@ -574,7 +582,8 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
function tabbuilder.handle_create_world_buttons(fields) function tabbuilder.handle_create_world_buttons(fields)
if fields["world_create_confirm"] then if fields["world_create_confirm"] or
fields["key_enter"] then
local worldname = fields["te_world_name"] local worldname = fields["te_world_name"]
local gameindex = engine.get_textlist_index("games") local gameindex = engine.get_textlist_index("games")