diff options
author | Rémy Raes <raes.remy@gmail.com> | 2024-07-30 00:40:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-30 00:40:59 +0200 |
commit | 65516328610c136db00b644d06bdcf98912ddf70 (patch) | |
tree | 6996a716dbc392850acd525f4a9acf960325f36d /primedev/mods/autodownload/moddownloader.cpp | |
parent | c4055830dd03ab3df11071bdf1f1f6410c79e055 (diff) | |
download | NorthstarLauncher-65516328610c136db00b644d06bdcf98912ddf70.tar.gz NorthstarLauncher-65516328610c136db00b644d06bdcf98912ddf70.zip |
Only fetch MAD manifesto on server join (#751)
Previously, the verified mods manifesto was fetched on game start without checking if the verified mod feature is enabled Squirrel-side; with this, the manifesto is only fetched when the user wants to download a mod (meaning they enabled the feature beforehand).
Diffstat (limited to 'primedev/mods/autodownload/moddownloader.cpp')
-rw-r--r-- | primedev/mods/autodownload/moddownloader.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/primedev/mods/autodownload/moddownloader.cpp b/primedev/mods/autodownload/moddownloader.cpp index feaa08ea..8e533dec 100644 --- a/primedev/mods/autodownload/moddownloader.cpp +++ b/primedev/mods/autodownload/moddownloader.cpp @@ -55,6 +55,8 @@ size_t WriteToString(void* ptr, size_t size, size_t count, void* stream) void ModDownloader::FetchModsListFromAPI() { + modState.state = MANIFESTO_FETCHING; + std::thread requestThread( [this]() { @@ -63,6 +65,9 @@ void ModDownloader::FetchModsListFromAPI() rapidjson::Document verifiedModsJson; std::string url = modsListUrl; + // Empty verified mods manifesto + verifiedMods = {}; + curl_global_init(CURL_GLOBAL_ALL); easyhandle = curl_easy_init(); std::string readBuffer; @@ -75,7 +80,12 @@ void ModDownloader::FetchModsListFromAPI() curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, &readBuffer); curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, WriteToString); result = curl_easy_perform(easyhandle); - ScopeGuard cleanup([&] { curl_easy_cleanup(easyhandle); }); + ScopeGuard cleanup( + [&] + { + curl_easy_cleanup(easyhandle); + modState.state = DOWNLOADING; + }); if (result == CURLcode::CURLE_OK) { @@ -614,7 +624,12 @@ void ModDownloader::DownloadMod(std::string modName, std::string modVersion) ON_DLL_LOAD_RELIESON("engine.dll", ModDownloader, (ConCommand), (CModule module)) { g_pModDownloader = new ModDownloader(); +} + +ADD_SQFUNC("void", NSFetchVerifiedModsManifesto, "", "", ScriptContext::SERVER | ScriptContext::CLIENT | ScriptContext::UI) +{ g_pModDownloader->FetchModsListFromAPI(); + return SQRESULT_NULL; } ADD_SQFUNC( |