Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only fetch MAD manifesto on server join #751

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion primedev/mods/autodownload/moddownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]()
{
Expand All @@ -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;
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
}
GeckoEidechse marked this conversation as resolved.
Show resolved Hide resolved

ADD_SQFUNC(
Expand Down
2 changes: 2 additions & 0 deletions primedev/mods/autodownload/moddownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class ModDownloader

enum ModInstallState
{
MANIFESTO_FETCHING,

// Normal installation process
DOWNLOADING,
CHECKSUMING,
Expand Down