Fix mods configuration stacking and mergin per mod

Previously, the engine only loaded the last mod’s `config/mod.cfg` file,
causing earlier mods' configuration settings to be ignored. This broke
the expectation of stackable mod behavior and affected features relying
on custom config, such as font overrides.

This commit updates the mod mounting and configuration process to:

- Mount each mod's files before attempting to load its config.
- Reload each mod's `config/modname.cfg` via `g_ConfigDB.Reload(CFG_MOD)`
  after mounting.
- Merge configuration keys into the CFG_MOD namespace:
  - If a key exists, its value is updated.
  - If not, the key is added.

This behavior now aligns with the VFS override system, where later mods
take precedence but earlier mods still contribute.

Also adds `_test.mods` for validation.

Fixes edge cases for mod authors who rely on consistent and layered
configuration overrides.

Related: #6383, #1810
Fixes: #8060
This commit is contained in:
trompetin17
2025-06-14 19:38:13 -05:00
parent 7ccda26f34
commit 8e255af185
8 changed files with 86 additions and 2 deletions
+8
View File
@@ -151,6 +151,14 @@ void MountMods(const Paths& paths, const std::vector<CStr>& mods)
g_VFS->Mount(L"", modPath / modName / "", baseFlags, priority);
else
g_VFS->Mount(L"", modUserPath / modName / "", userFlags, priority);
// If mod have a config/<modName>.cfg, load the configuration.
VfsPath modConfigPath{fmt::format("config/{}.cfg", mods[i].c_str())};
if (!VfsFileExists(modConfigPath))
continue;
g_ConfigDB.SetConfigFile(CFG_MOD, modConfigPath);
g_ConfigDB.Reload(CFG_MOD);
}
// Mount the user mod last. In dev copy, mount it with a low priority. Otherwise, make it writable.