diff --git a/source/main.cpp b/source/main.cpp index f06fedb826..1e2579cb9d 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -79,6 +79,7 @@ that of Atlas depending on commandline parameters. #include "rlinterface/RLInterface.h" #include "scriptinterface/ScriptContext.h" #include "scriptinterface/ScriptEngine.h" +#include "scriptinterface/ScriptInterface.h" #include "scriptinterface/JSON.h" #include "simulation2/Simulation2.h" #include "simulation2/system/TurnManager.h" @@ -665,6 +666,9 @@ static void RunGameOrAtlas(int argc, const char* argv[]) installer.Install(modPath, g_ScriptContext, true); installedMods = installer.GetInstalledMods(); + + ScriptInterface modInterface("Engine", "Mod", g_ScriptContext); + g_Mods.UpdateAvailableMods(modInterface); } if (isNonVisual) diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index f52a66c22c..ea5da72855 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -866,6 +866,7 @@ bool Init(const CmdLineArgs& args, int flags) if (flags & INIT_MODS) { ScriptInterface modInterface("Engine", "Mod", g_ScriptContext); + g_Mods.UpdateAvailableMods(modInterface); std::vector mods; if (args.Has("mod")) mods = args.GetMultiple("mod"); diff --git a/source/ps/Mod.cpp b/source/ps/Mod.cpp index 69d6415e67..2c5942c0d1 100644 --- a/source/ps/Mod.cpp +++ b/source/ps/Mod.cpp @@ -156,8 +156,6 @@ bool Mod::EnableMods(const ScriptInterface& scriptInterface, const std::vector& GetIncompatibleMods() const; const std::vector& GetAvailableMods() const; + /** + * Fetches available mods and stores some metadata about them. + * This may open the zipped mod archives, depending on the situation, + * and/or try to write files to the user mod folder, + * which can be quite slow, so should be run rarely. + * TODO: if this did not need the scriptInterface to parse JSON, + * we could run it in different contexts and possibly cleaner. + */ + void UpdateAvailableMods(const ScriptInterface& scriptInterface); + /** * Enables specified mods (& mods required by the engine). * @param addPublic - if true, enable the public mod. @@ -83,15 +93,6 @@ public: */ static bool AreModsPlayCompatible(const std::vector& modsA, const std::vector& modsB); private: - /** - * Fetches available mods and stores some metadata about them. - * This may open the zipped mod archives, depending on the situation, - * and/or try to write files to the user mod folder, - * which can be quite slow, so should be run rarely. - * TODO: if this did not need the scriptInterface to parse JSON, - * we could run it in different contexts and possibly cleaner. - */ - void UpdateAvailableMods(const ScriptInterface& scriptInterface); /** * Checks a list of @a mods and returns the incompatible mods, if any.