From 7a07731457b309d73205648eaf8b869e1c8d8c4b Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 18 Nov 2023 17:07:48 +0100 Subject: [PATCH] Don't reinstall the entire game if an update was pushed with no updated files --- r5dev/sdklauncher/base_surface.cpp | 4 ++-- r5dev/sdklauncher/sdklauncher_utils.cpp | 27 ++++++++++++++++++++----- r5dev/sdklauncher/sdklauncher_utils.h | 4 ++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/r5dev/sdklauncher/base_surface.cpp b/r5dev/sdklauncher/base_surface.cpp index f486d47a..dfe71b1e 100644 --- a/r5dev/sdklauncher/base_surface.cpp +++ b/r5dev/sdklauncher/base_surface.cpp @@ -332,7 +332,7 @@ void CBaseSurface::OnUpdateClick(Forms::Control* Sender) CUtlVector fileList; CUtlString errorMessage; - if (!SDKLauncher_BeginInstall(false, false, fileList, &errorMessage, pProgress)) + if (!SDKLauncher_BeginInstall(false, false, false, fileList, &errorMessage, pProgress)) { Forms::MessageBox::Show(Format("Failed to install game: %s\n", errorMessage.String()).c_str(), "Error", Forms::MessageBoxButtons::OK, Forms::MessageBoxIcon::Error); @@ -398,7 +398,7 @@ void CBaseSurface::OnInstallClick(Forms::Control* Sender) CUtlVector fileList; CUtlString errorMessage; - if (!SDKLauncher_BeginInstall(false, false, fileList, &errorMessage, pProgress)) + if (!SDKLauncher_BeginInstall(false, false, true, fileList, &errorMessage, pProgress)) { Forms::MessageBox::Show(Format("Failed to install game: %s\n", errorMessage.String()).c_str(), "Error", Forms::MessageBoxButtons::OK, Forms::MessageBoxIcon::Error); diff --git a/r5dev/sdklauncher/sdklauncher_utils.cpp b/r5dev/sdklauncher/sdklauncher_utils.cpp index cbe996a4..4948fc4a 100644 --- a/r5dev/sdklauncher/sdklauncher_utils.cpp +++ b/r5dev/sdklauncher/sdklauncher_utils.cpp @@ -509,9 +509,16 @@ bool SDKLauncher_BuildUpdateList(const nlohmann::json& localManifest, } //---------------------------------------------------------------------------- -// Purpose: +// Purpose: start the automatic installation procedure +// Input : bPreRelease - +// bOptionalDepots - +// bFullInstallWhenListEmpty - if true, installs all depots in the remote manifest when depot list vector is empty +// &zipList - +// *errorMessage - +// *pProgress - +// Output : true on success, false otherwise //---------------------------------------------------------------------------- -bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots, +bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots, const bool bFullInstallWhenListEmpty, CUtlVector& zipList, CUtlString* errorMessage, CProgressPanel* pProgress) { string responseMessage; @@ -541,6 +548,16 @@ bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots Assert(depotList.IsEmpty()); } + if (depotList.IsEmpty() && !bFullInstallWhenListEmpty) + { + if (!SDKLauncher_WriteLocalManifest(remoteManifest, errorMessage)) + { + return false; + } + + return true; + } + FOR_EACH_VEC(depotList, i) { const CUtlString& depotName = depotList[i]; @@ -565,9 +582,8 @@ bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots return false; } - if (!SDKLauncher_WriteLocalManifest(remoteManifest)) + if (!SDKLauncher_WriteLocalManifest(remoteManifest, errorMessage)) { - errorMessage->Set("Failed to write local manifest file (insufficient rights?)"); return false; } @@ -824,11 +840,12 @@ bool SDKLauncher_GetLocalManifest(nlohmann::json& localManifest) return true; } -bool SDKLauncher_WriteLocalManifest(const nlohmann::json& localManifest) +bool SDKLauncher_WriteLocalManifest(const nlohmann::json& localManifest, CUtlString* errorMessage) { CIOStream writer; if (!writer.Open(DEPOT_MANIFEST_FILE_PATH, CIOStream::Mode_t::WRITE)) { + errorMessage->Set("Failed to write local manifest file (insufficient rights?)"); return false; } diff --git a/r5dev/sdklauncher/sdklauncher_utils.h b/r5dev/sdklauncher/sdklauncher_utils.h index 8e700967..f05a39d3 100644 --- a/r5dev/sdklauncher/sdklauncher_utils.h +++ b/r5dev/sdklauncher/sdklauncher_utils.h @@ -11,7 +11,7 @@ bool SDKLauncher_CreateDepotDirectories(); bool SDKLauncher_ClearDepotDirectories(); bool SDKLauncher_ExtractZipFile(nlohmann::json& manifest, const CUtlString& filePath, DepotChangedList_t* changedList, CProgressPanel* pProgress); -bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots, +bool SDKLauncher_BeginInstall(const bool bPreRelease, const bool bOptionalDepots, const bool bFullInstallWhenListEmpty, CUtlVector& zipList, CUtlString* errorMessage, CProgressPanel* pProgress); bool SDKLauncher_IsManifestValid(const nlohmann::json& depotManifest); @@ -26,7 +26,7 @@ bool SDKLauncher_InstallDepotList(nlohmann::json& manifest, CUtlVector