diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-01-13 16:22:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-13 16:22:32 +0100 |
commit | ed1415f78d7820c44e9a219b578b9fbcdce0cc65 (patch) | |
tree | a15d23478bd18df7c9ecf1cf568c2920a6cfe8eb | |
parent | a51909bb64811694773b6dd3abd791d3d78d85e6 (diff) | |
download | minetest-ed1415f78d7820c44e9a219b578b9fbcdce0cc65.tar.gz minetest-ed1415f78d7820c44e9a219b578b9fbcdce0cc65.tar.bz2 minetest-ed1415f78d7820c44e9a219b578b9fbcdce0cc65.zip |
world.mt: Only accept true/false/nil values (#8055)
This patch will make distinguishable mods in modpacks possible in the future
`nil` checks are required to provide backwards-compatibility for fresh configured worlds
-rw-r--r-- | builtin/mainmenu/dlg_config_world.lua | 2 | ||||
-rw-r--r-- | builtin/mainmenu/pkgmgr.lua | 7 | ||||
-rw-r--r-- | src/content/mods.cpp | 3 |
3 files changed, 8 insertions, 4 deletions
diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua index 1a1107c24..3e766aa78 100644 --- a/builtin/mainmenu/dlg_config_world.lua +++ b/builtin/mainmenu/dlg_config_world.lua @@ -138,7 +138,7 @@ local function handle_buttons(this, fields) not mod.is_game_content then if modname_valid(mod.name) then worldfile:set("load_mod_" .. mod.name, - tostring(mod.enabled)) + mod.enabled and "true" or "false") elseif mod.enabled then gamedata.errormessage = fgettext_ne("Failed to enable mo" .. "d \"$1\" as it contains disallowed characters. " .. diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua index cea373c9f..171ba54ea 100644 --- a/builtin/mainmenu/pkgmgr.lua +++ b/builtin/mainmenu/pkgmgr.lua @@ -391,7 +391,10 @@ function pkgmgr.get_worldconfig(worldpath) if key == "gameid" then worldconfig.id = value elseif key:sub(0, 9) == "load_mod_" then - worldconfig.global_mods[key] = core.is_yes(value) + -- Compatibility: Check against "nil" which was erroneously used + -- as value for fresh configured worlds + worldconfig.global_mods[key] = value ~= "false" and value ~= "nil" + and value else worldconfig[key] = value end @@ -595,7 +598,7 @@ function pkgmgr.preparemodlist(data) end end if element ~= nil then - element.enabled = core.is_yes(value) + element.enabled = value ~= "false" and value ~= "nil" and value else core.log("info", "Mod: " .. key .. " " .. dump(value) .. " but not found") end diff --git a/src/content/mods.cpp b/src/content/mods.cpp index 3cb168e19..676666f78 100644 --- a/src/content/mods.cpp +++ b/src/content/mods.cpp @@ -274,7 +274,8 @@ void ModConfiguration::addModsFromConfig( conf.readConfigFile(settings_path.c_str()); std::vector<std::string> names = conf.getNames(); for (const std::string &name : names) { - if (name.compare(0, 9, "load_mod_") == 0 && conf.getBool(name)) + if (name.compare(0, 9, "load_mod_") == 0 && conf.get(name) != "false" && + conf.get(name) != "nil") load_mod_names.insert(name.substr(9)); } |