Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

world.mt: Only accept true/false/nil values #8055

Merged
merged 3 commits into from Jan 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/mainmenu/dlg_config_world.lua
Expand Up @@ -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. " ..
Expand Down
7 changes: 5 additions & 2 deletions builtin/mainmenu/pkgmgr.lua
Expand Up @@ -366,7 +366,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
Expand Down Expand Up @@ -566,7 +569,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
Expand Down
3 changes: 2 additions & 1 deletion src/content/mods.cpp
Expand Up @@ -270,7 +270,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));
}

Expand Down