Mod and mod-mounting cleanup and improvements.

- Non-visual replays now automatically try to load the replay mods. This
removes the annoyance that -mod=public usually had to be passed.
- MountMods is no longer called in InitVfs but later, making it possible
to load the game in one pass & simplifying things considerably.
- Explicitly ignore duplicates when loading mods
- Interface cleanup: failed mods and incompatible mods were redundant,
only incompatible mods is kept.
- Interface cleanup: `AreModsCompatible`becomes
`CheckForIncompatibleMods`, which becomes a private pure function,
simplifying the control flow somewhat.
- Interface cleanup: `CheckAndEnableMods` is just `EnableMods`, which
explicitly updates loaded & incompatible mods.
- `CacheEnabledModVersions` becomes private and is called on behalf of
the user, removing the need to be careful about updating that (fixes my
concern at 44ec2e324e)

Overall, the logic around mounting & enabled mods should be easier to
understand.

Differential Revision: https://code.wildfiregames.com/D3982
This was SVN commit r25474.
This commit is contained in:
wraitii
2021-05-20 14:36:42 +00:00
parent 1e297fe212
commit 3bcf360107
13 changed files with 204 additions and 199 deletions
+5 -6
View File
@@ -33,17 +33,16 @@ Mod* ModGetter(const ScriptRequest&, JS::CallArgs&)
bool SetModsAndRestartEngine(const ScriptInterface& scriptInterface, const std::vector<CStr>& mods)
{
g_Mods.ClearIncompatibleMods();
if (!g_Mods.CheckAndEnableMods(scriptInterface, mods))
if (!g_Mods.EnableMods(scriptInterface, mods, false))
return false;
RestartEngine();
return true;
}
bool HasFailedMods()
bool HasIncompatibleMods()
{
return g_Mods.GetFailedMods().size() > 0;
return g_Mods.GetIncompatibleMods().size() > 0;
}
void RegisterScriptFunctions(const ScriptRequest& rq)
@@ -51,8 +50,8 @@ void RegisterScriptFunctions(const ScriptRequest& rq)
ScriptFunction::Register<&Mod::GetEngineInfo, ModGetter>(rq, "GetEngineInfo");
ScriptFunction::Register<&Mod::GetAvailableMods, ModGetter>(rq, "GetAvailableMods");
ScriptFunction::Register<&Mod::GetEnabledMods, ModGetter>(rq, "GetEnabledMods");
ScriptFunction::Register<HasFailedMods> (rq, "HasFailedMods");
ScriptFunction::Register<&Mod::GetFailedMods, ModGetter>(rq, "GetFailedMods");
ScriptFunction::Register<HasIncompatibleMods> (rq, "HasIncompatibleMods");
ScriptFunction::Register<&Mod::GetIncompatibleMods, ModGetter>(rq, "GetIncompatibleMods");
ScriptFunction::Register<&SetModsAndRestartEngine>(rq, "SetModsAndRestartEngine");
}
}