aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorElias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com>2021-03-01 12:13:47 +0100
committersfan5 <sfan5@live.de>2021-04-05 16:01:10 +0200
commit67be50b706b0d1364b42ff1fd3d461d0794cd268 (patch)
tree658868e69c48af21f63df8cd3c0a71b6f42dc7a1 /builtin
parentcd840b7c9d1f228bab94c5f58b5df235d6c0a180 (diff)
downloadminetest-67be50b706b0d1364b42ff1fd3d461d0794cd268.tar.gz
minetest-67be50b706b0d1364b42ff1fd3d461d0794cd268.tar.bz2
minetest-67be50b706b0d1364b42ff1fd3d461d0794cd268.zip
Make pkgmgr handle modpacks containing modpacks properly
fixes #10550
Diffstat (limited to 'builtin')
-rw-r--r--builtin/mainmenu/pkgmgr.lua39
1 files changed, 17 insertions, 22 deletions
diff --git a/builtin/mainmenu/pkgmgr.lua b/builtin/mainmenu/pkgmgr.lua
index 4aa05d838..787936e31 100644
--- a/builtin/mainmenu/pkgmgr.lua
+++ b/builtin/mainmenu/pkgmgr.lua
@@ -413,18 +413,7 @@ function pkgmgr.is_modpack_entirely_enabled(data, name)
end
---------- toggles or en/disables a mod or modpack and its dependencies --------
-function pkgmgr.enable_mod(this, toset)
- local list = this.data.list:get_list()
- local mod = list[this.data.selected_mod]
-
- -- Game mods can't be enabled or disabled
- if mod.is_game_content then
- return
- end
-
- local toggled_mods = {}
-
- local enabled_mods = {}
+local function toggle_mod_or_modpack(list, toggled_mods, enabled_mods, toset, mod)
if not mod.is_modpack then
-- Toggle or en/disable the mod
if toset == nil then
@@ -443,19 +432,25 @@ function pkgmgr.enable_mod(this, toset)
-- interleaved unsupported
for i = 1, #list do
if list[i].modpack == mod.name then
- if toset == nil then
- toset = not list[i].enabled
- end
- if list[i].enabled ~= toset then
- list[i].enabled = toset
- toggled_mods[#toggled_mods+1] = list[i].name
- end
- if toset then
- enabled_mods[list[i].name] = true
- end
+ toggle_mod_or_modpack(list, toggled_mods, enabled_mods, toset, list[i])
end
end
end
+end
+
+function pkgmgr.enable_mod(this, toset)
+ local list = this.data.list:get_list()
+ local mod = list[this.data.selected_mod]
+
+ -- Game mods can't be enabled or disabled
+ if mod.is_game_content then
+ return
+ end
+
+ local toggled_mods = {}
+ local enabled_mods = {}
+ toggle_mod_or_modpack(list, toggled_mods, enabled_mods, toset, mod)
+
if not toset then
-- Mod(s) were disabled, so no dependencies need to be enabled
table.sort(toggled_mods)