From f4df4e0fc09471e5d7b700ce2c3649382e223dca Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:57:59 +0200 Subject: [PATCH] Show actual to-install package count + WIP callback fix Progress callback gets called too often eating CPU, work in progress fix added but not yet utilized. --- r5dev/sdklauncher/sdklauncher_utils.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/r5dev/sdklauncher/sdklauncher_utils.cpp b/r5dev/sdklauncher/sdklauncher_utils.cpp index a2399629..fb860781 100644 --- a/r5dev/sdklauncher/sdklauncher_utils.cpp +++ b/r5dev/sdklauncher/sdklauncher_utils.cpp @@ -10,6 +10,10 @@ bool g_bPartialInstall = false; //bool g_bExperimentalBuilds = false; float g_flUpdateCheckRate = 64; +double s_flLastProgressUpdate = 0.0; + +#define PROGRESS_CALLBACK_UPDATE_DELTA 0.1 + // !TODO: perhaps this should be a core utility shared across // the entire SDK to allow processes to restart them selfs. void SDKLauncher_Restart() @@ -342,6 +346,14 @@ int SDKLauncher_ProgressCallback(CURLProgress* progessData, double dltotal, return -1; } + // This gets called often, prevent this callback from eating all CPU. + //const double curTime = Plat_FloatTime(); + //if ((curTime - s_flLastProgressUpdate) < PROGRESS_CALLBACK_UPDATE_DELTA) + //{ + // return 0; + //} + //s_flLastProgressUpdate = curTime; + double downloaded; curl_easy_getinfo(progessData->curl, CURLINFO_SIZE_DOWNLOAD, &downloaded); @@ -543,7 +555,7 @@ bool SDKLauncher_DownloadDepotList(nlohmann::json& manifest, CUtlVectorSetText(Format("Downloading package %i of %i...", i, depotListArray.size()).c_str()); + pProgress->SetText(Format("Downloading package %i of %i...", i, depotList.Count()).c_str()); SDKLauncher_DownloadAsset(downloadLink.c_str(), pPath, fileName.c_str(), fileSize, "wb+", pProgress); // Check if its a zip file, as these are