Fix incompatible mods start: show both incompatible and enabled mods;

As noted by Angen in a26535d023, refs 3bcf360107
When starting with incompatible mods, the non-incompatible mods were no
longer shown. This fixes that.
I think the code looks cleaner from this new control flow that
explicitly only mounts "mod".

Tested by: Angen
Differential Revision: https://code.wildfiregames.com/D3996
This was SVN commit r25510.
This commit is contained in:
wraitii
2021-05-22 07:33:49 +00:00
parent 3548feb16a
commit 8f8e29c092
4 changed files with 7 additions and 18 deletions
+2 -1
View File
@@ -118,7 +118,8 @@ function getMod(folder)
function loadEnabledMods()
{
if (g_HasIncompatibleMods)
g_ModsEnabled = Engine.GetIncompatibleMods().filter(folder => folder != "mod");
g_ModsEnabled = Engine.GetEnabledMods().concat(Engine.GetIncompatibleMods())
.filter(folder => folder != "mod");
else
g_ModsEnabled = Engine.GetEnabledMods().filter(folder => !!g_Mods[folder]);
g_ModsDisabled = Object.keys(g_Mods).filter(folder => g_ModsEnabled.indexOf(folder) == -1);
+5 -4
View File
@@ -893,12 +893,13 @@ bool Init(const CmdLineArgs& args, int flags)
LOGERROR("Trying to start with incompatible mods: %s.", boost::algorithm::join(g_Mods.GetIncompatibleMods(), ", "));
return false;
}
// Disable all mods but "mod", we want to use the JS fallback code.
// TODO: it'd be nicer if the control flow was more obvious here.
g_Mods.SwitchToModSelector(modInterface);
}
}
MountMods(Paths(args), g_Mods.GetEnabledMods());
// If there are incompatible mods, switch to the mod selector so players can resolve the problem.
if (g_Mods.GetIncompatibleMods().empty())
MountMods(Paths(args), g_Mods.GetEnabledMods());
else
MountMods(Paths(args), { "mod" });
// Special command-line mode to dump the entity schemas instead of running the game.
// (This must be done after loading VFS etc, but should be done before wasting time
-6
View File
@@ -159,12 +159,6 @@ const std::vector<CStr>& Mod::GetIncompatibleMods() const
return m_IncompatibleMods;
}
void Mod::SwitchToModSelector(const ScriptInterface& scriptInterface)
{
m_ModsLoaded = { "mod" };
CacheEnabledModVersions(scriptInterface);
}
bool Mod::EnableMods(const ScriptInterface& scriptInterface, const std::vector<CStr>& mods, const bool addPublic)
{
m_IncompatibleMods.clear();
-7
View File
@@ -36,13 +36,6 @@ public:
const std::vector<CStr>& GetEnabledMods() const;
const std::vector<CStr>& GetIncompatibleMods() const;
/**
* Enables the mod selector only, leaving incompatible mods as-is.
* This is used, in combination with the JS code, to show the user
* a clear interface in case of incompatible mods.
*/
void SwitchToModSelector(const ScriptInterface& scriptInterface);
/**
* Enables specified mods (& mods required by the engine).
* @param addPublic - if true, enable the public mod.