Skip to content

Commit ed1415f

Browse files
authoredJan 13, 2019
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
1 parent a51909b commit ed1415f

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed
 

‎builtin/mainmenu/dlg_config_world.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ local function handle_buttons(this, fields)
138138
not mod.is_game_content then
139139
if modname_valid(mod.name) then
140140
worldfile:set("load_mod_" .. mod.name,
141-
tostring(mod.enabled))
141+
mod.enabled and "true" or "false")
142142
elseif mod.enabled then
143143
gamedata.errormessage = fgettext_ne("Failed to enable mo" ..
144144
"d \"$1\" as it contains disallowed characters. " ..

‎builtin/mainmenu/pkgmgr.lua

+5-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,10 @@ function pkgmgr.get_worldconfig(worldpath)
391391
if key == "gameid" then
392392
worldconfig.id = value
393393
elseif key:sub(0, 9) == "load_mod_" then
394-
worldconfig.global_mods[key] = core.is_yes(value)
394+
-- Compatibility: Check against "nil" which was erroneously used
395+
-- as value for fresh configured worlds
396+
worldconfig.global_mods[key] = value ~= "false" and value ~= "nil"
397+
and value
395398
else
396399
worldconfig[key] = value
397400
end
@@ -595,7 +598,7 @@ function pkgmgr.preparemodlist(data)
595598
end
596599
end
597600
if element ~= nil then
598-
element.enabled = core.is_yes(value)
601+
element.enabled = value ~= "false" and value ~= "nil" and value
599602
else
600603
core.log("info", "Mod: " .. key .. " " .. dump(value) .. " but not found")
601604
end

‎src/content/mods.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ void ModConfiguration::addModsFromConfig(
274274
conf.readConfigFile(settings_path.c_str());
275275
std::vector<std::string> names = conf.getNames();
276276
for (const std::string &name : names) {
277-
if (name.compare(0, 9, "load_mod_") == 0 && conf.getBool(name))
277+
if (name.compare(0, 9, "load_mod_") == 0 && conf.get(name) != "false" &&
278+
conf.get(name) != "nil")
278279
load_mod_names.insert(name.substr(9));
279280
}
280281

0 commit comments

Comments
 (0)
Please sign in to comment.