mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-14 09:55:02 +00:00
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:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user