summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2021-05-16 00:24:06 -0400
committerGravatar Morph2021-05-16 04:13:57 -0400
commita170aa16b6d609b5e92b41a64711a2899e457135 (patch)
tree596ef9793d37514343f23f73662327a00a4d002e /src
parentMerge pull request #6293 from v1993/master (diff)
downloadyuzu-a170aa16b6d609b5e92b41a64711a2899e457135.tar.gz
yuzu-a170aa16b6d609b5e92b41a64711a2899e457135.tar.xz
yuzu-a170aa16b6d609b5e92b41a64711a2899e457135.zip
main: Prevent installing base titles into NAND
Many users have been installing their base titles into NAND instead of adding them into the games list. This prevents users from installing any base titles and warns the user about the action.
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/registered_cache.cpp7
-rw-r--r--src/core/file_sys/registered_cache.h1
-rw-r--r--src/yuzu/main.cpp22
-rw-r--r--src/yuzu/main.h1
4 files changed, 28 insertions, 3 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index 1fb66874e..b0cb65952 100644
--- a/src/core/file_sys/registered_cache.cpp
+++ b/src/core/file_sys/registered_cache.cpp
@@ -12,6 +12,7 @@
12#include "common/logging/log.h" 12#include "common/logging/log.h"
13#include "core/crypto/key_manager.h" 13#include "core/crypto/key_manager.h"
14#include "core/file_sys/card_image.h" 14#include "core/file_sys/card_image.h"
15#include "core/file_sys/common_funcs.h"
15#include "core/file_sys/content_archive.h" 16#include "core/file_sys/content_archive.h"
16#include "core/file_sys/nca_metadata.h" 17#include "core/file_sys/nca_metadata.h"
17#include "core/file_sys/registered_cache.h" 18#include "core/file_sys/registered_cache.h"
@@ -592,6 +593,12 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex
592 const CNMT cnmt(cnmt_file); 593 const CNMT cnmt(cnmt_file);
593 594
594 const auto title_id = cnmt.GetTitleID(); 595 const auto title_id = cnmt.GetTitleID();
596 const auto version = cnmt.GetTitleVersion();
597
598 if (title_id == GetBaseTitleID(title_id) && version == 0) {
599 return InstallResult::ErrorBaseInstall;
600 }
601
595 const auto result = RemoveExistingEntry(title_id); 602 const auto result = RemoveExistingEntry(title_id);
596 603
597 // Install Metadata File 604 // Install Metadata File
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h
index b31630014..d042aef90 100644
--- a/src/core/file_sys/registered_cache.h
+++ b/src/core/file_sys/registered_cache.h
@@ -38,6 +38,7 @@ enum class InstallResult {
38 ErrorAlreadyExists, 38 ErrorAlreadyExists,
39 ErrorCopyFailed, 39 ErrorCopyFailed,
40 ErrorMetaFailed, 40 ErrorMetaFailed,
41 ErrorBaseInstall,
41}; 42};
42 43
43struct ContentProviderEntry { 44struct ContentProviderEntry {
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 30bb1aac7..2c8649793 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -2101,6 +2101,7 @@ void GMainWindow::OnMenuInstallToNAND() {
2101 QStringList new_files{}; // Newly installed files that do not yet exist in the NAND 2101 QStringList new_files{}; // Newly installed files that do not yet exist in the NAND
2102 QStringList overwritten_files{}; // Files that overwrote those existing in the NAND 2102 QStringList overwritten_files{}; // Files that overwrote those existing in the NAND
2103 QStringList failed_files{}; // Files that failed to install due to errors 2103 QStringList failed_files{}; // Files that failed to install due to errors
2104 bool detected_base_install{}; // Whether a base game was attempted to be installed
2104 2105
2105 ui.action_Install_File_NAND->setEnabled(false); 2106 ui.action_Install_File_NAND->setEnabled(false);
2106 2107
@@ -2126,6 +2127,7 @@ void GMainWindow::OnMenuInstallToNAND() {
2126 2127
2127 while (!future.isFinished()) { 2128 while (!future.isFinished()) {
2128 QCoreApplication::processEvents(); 2129 QCoreApplication::processEvents();
2130 std::this_thread::sleep_for(std::chrono::milliseconds(1));
2129 } 2131 }
2130 2132
2131 result = future.result(); 2133 result = future.result();
@@ -2146,6 +2148,10 @@ void GMainWindow::OnMenuInstallToNAND() {
2146 case InstallResult::Failure: 2148 case InstallResult::Failure:
2147 failed_files.append(QFileInfo(file).fileName()); 2149 failed_files.append(QFileInfo(file).fileName());
2148 break; 2150 break;
2151 case InstallResult::BaseInstallAttempted:
2152 failed_files.append(QFileInfo(file).fileName());
2153 detected_base_install = true;
2154 break;
2149 } 2155 }
2150 2156
2151 --remaining; 2157 --remaining;
@@ -2153,6 +2159,13 @@ void GMainWindow::OnMenuInstallToNAND() {
2153 2159
2154 install_progress->close(); 2160 install_progress->close();
2155 2161
2162 if (detected_base_install) {
2163 QMessageBox::warning(
2164 this, tr("Install Results"),
2165 tr("To avoid possible conflicts, we discourage users from installing base games to the "
2166 "NAND.\nPlease, only use this feature to install updates and DLC."));
2167 }
2168
2156 const QString install_results = 2169 const QString install_results =
2157 (new_files.isEmpty() ? QString{} 2170 (new_files.isEmpty() ? QString{}
2158 : tr("%n file(s) were newly installed\n", "", new_files.size())) + 2171 : tr("%n file(s) were newly installed\n", "", new_files.size())) +
@@ -2214,11 +2227,14 @@ InstallResult GMainWindow::InstallNSPXCI(const QString& filename) {
2214 const auto res = 2227 const auto res =
2215 Core::System::GetInstance().GetFileSystemController().GetUserNANDContents()->InstallEntry( 2228 Core::System::GetInstance().GetFileSystemController().GetUserNANDContents()->InstallEntry(
2216 *nsp, true, qt_raw_copy); 2229 *nsp, true, qt_raw_copy);
2217 if (res == FileSys::InstallResult::Success) { 2230 switch (res) {
2231 case FileSys::InstallResult::Success:
2218 return InstallResult::Success; 2232 return InstallResult::Success;
2219 } else if (res == FileSys::InstallResult::OverwriteExisting) { 2233 case FileSys::InstallResult::OverwriteExisting:
2220 return InstallResult::Overwrite; 2234 return InstallResult::Overwrite;
2221 } else { 2235 case FileSys::InstallResult::ErrorBaseInstall:
2236 return InstallResult::BaseInstallAttempted;
2237 default:
2222 return InstallResult::Failure; 2238 return InstallResult::Failure;
2223 } 2239 }
2224} 2240}
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 98a608fce..b3a5033ce 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -76,6 +76,7 @@ enum class InstallResult {
76 Success, 76 Success,
77 Overwrite, 77 Overwrite,
78 Failure, 78 Failure,
79 BaseInstallAttempted,
79}; 80};
80 81
81enum class ReinitializeKeyBehavior { 82enum class ReinitializeKeyBehavior {