Skip to content

Commit

Permalink
Fix error if setting menu_last_game is not a valid game
Browse files Browse the repository at this point in the history
  • Loading branch information
nOOb3167 authored and rubenwardy committed Dec 22, 2017
1 parent 42e37de commit 036585b
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions builtin/mainmenu/dlg_create_world.lua
Expand Up @@ -33,18 +33,21 @@ local function create_world_formspec(dialogdata)
end
end

local gamepath = core.get_game(gameidx).path
local gameconfig = Settings(gamepath.."/game.conf")

local disallowed_mapgens = (gameconfig:get("disallowed_mapgens") or ""):split()
for key, value in pairs(disallowed_mapgens) do
disallowed_mapgens[key] = value:trim()
end
local game_by_gameidx = core.get_game(gameidx)
if game_by_gameidx ~= nil then
local gamepath = game_by_gameidx.path
local gameconfig = Settings(gamepath.."/game.conf")

local disallowed_mapgens = (gameconfig:get("disallowed_mapgens") or ""):split()
for key, value in pairs(disallowed_mapgens) do
disallowed_mapgens[key] = value:trim()
end

if disallowed_mapgens then
for i = #mapgens, 1, -1 do
if table.indexof(disallowed_mapgens, mapgens[i]) > 0 then
table.remove(mapgens, i)
if disallowed_mapgens then
for i = #mapgens, 1, -1 do
if table.indexof(disallowed_mapgens, mapgens[i]) > 0 then
table.remove(mapgens, i)
end
end
end
end
Expand Down

0 comments on commit 036585b

Please sign in to comment.