summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar t8952024-01-24 12:34:50 -0500
committerGravatar t8952024-01-25 12:53:49 -0500
commit97ca160b08537314ca6ba953a382aebda3da06b9 (patch)
tree53282078af75ecba5ad87c5bcd3ea1cdb14f0249
parentfrontend_common: Remove key rederivation and keep key check (diff)
downloadyuzu-97ca160b08537314ca6ba953a382aebda3da06b9.tar.gz
yuzu-97ca160b08537314ca6ba953a382aebda3da06b9.tar.xz
yuzu-97ca160b08537314ca6ba953a382aebda3da06b9.zip
frontend_common: Consistently use references
Was swapping between references and pointers for no reason. Just unify them here since each of these utility functions will need their parameters to be alive.
-rw-r--r--src/android/app/src/main/jni/native.cpp15
-rw-r--r--src/frontend_common/content_manager.h56
-rw-r--r--src/yuzu/main.cpp11
3 files changed, 41 insertions, 41 deletions
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp
index 963f57380..4c3644cc5 100644
--- a/src/android/app/src/main/jni/native.cpp
+++ b/src/android/app/src/main/jni/native.cpp
@@ -463,8 +463,8 @@ int Java_org_yuzu_yuzu_1emu_NativeLibrary_installFileToNand(JNIEnv* env, jobject
463 }; 463 };
464 464
465 return static_cast<int>( 465 return static_cast<int>(
466 ContentManager::InstallNSP(&EmulationSession::GetInstance().System(), 466 ContentManager::InstallNSP(EmulationSession::GetInstance().System(),
467 EmulationSession::GetInstance().System().GetFilesystem().get(), 467 *EmulationSession::GetInstance().System().GetFilesystem(),
468 GetJString(env, j_file), callback)); 468 GetJString(env, j_file), callback));
469} 469}
470 470
@@ -819,7 +819,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_removeUpdate(JNIEnv* env, jobject job
819void Java_org_yuzu_yuzu_1emu_NativeLibrary_removeDLC(JNIEnv* env, jobject jobj, 819void Java_org_yuzu_yuzu_1emu_NativeLibrary_removeDLC(JNIEnv* env, jobject jobj,
820 jstring jprogramId) { 820 jstring jprogramId) {
821 auto program_id = EmulationSession::GetProgramId(env, jprogramId); 821 auto program_id = EmulationSession::GetProgramId(env, jprogramId);
822 ContentManager::RemoveAllDLC(&EmulationSession::GetInstance().System(), program_id); 822 ContentManager::RemoveAllDLC(EmulationSession::GetInstance().System(), program_id);
823} 823}
824 824
825void Java_org_yuzu_yuzu_1emu_NativeLibrary_removeMod(JNIEnv* env, jobject jobj, jstring jprogramId, 825void Java_org_yuzu_yuzu_1emu_NativeLibrary_removeMod(JNIEnv* env, jobject jobj, jstring jprogramId,
@@ -829,8 +829,9 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_removeMod(JNIEnv* env, jobject jobj,
829 program_id, GetJString(env, jname)); 829 program_id, GetJString(env, jname));
830} 830}
831 831
832jobject Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyInstalledContents(JNIEnv* env, jobject jobj, 832jobjectArray Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyInstalledContents(JNIEnv* env,
833 jobject jcallback) { 833 jobject jobj,
834 jobject jcallback) {
834 auto jlambdaClass = env->GetObjectClass(jcallback); 835 auto jlambdaClass = env->GetObjectClass(jcallback);
835 auto jlambdaInvokeMethod = env->GetMethodID( 836 auto jlambdaInvokeMethod = env->GetMethodID(
836 jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); 837 jlambdaClass, "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
@@ -842,7 +843,7 @@ jobject Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyInstalledContents(JNIEnv* en
842 843
843 auto& session = EmulationSession::GetInstance(); 844 auto& session = EmulationSession::GetInstance();
844 std::vector<std::string> result = ContentManager::VerifyInstalledContents( 845 std::vector<std::string> result = ContentManager::VerifyInstalledContents(
845 &session.System(), session.GetContentProvider(), callback); 846 session.System(), *session.GetContentProvider(), callback);
846 jobjectArray jresult = 847 jobjectArray jresult =
847 env->NewObjectArray(result.size(), IDCache::GetStringClass(), ToJString(env, "")); 848 env->NewObjectArray(result.size(), IDCache::GetStringClass(), ToJString(env, ""));
848 for (size_t i = 0; i < result.size(); ++i) { 849 for (size_t i = 0; i < result.size(); ++i) {
@@ -863,7 +864,7 @@ jint Java_org_yuzu_yuzu_1emu_NativeLibrary_verifyGameContents(JNIEnv* env, jobje
863 }; 864 };
864 auto& session = EmulationSession::GetInstance(); 865 auto& session = EmulationSession::GetInstance();
865 return static_cast<jint>( 866 return static_cast<jint>(
866 ContentManager::VerifyGameContents(&session.System(), GetJString(env, jpath), callback)); 867 ContentManager::VerifyGameContents(session.System(), GetJString(env, jpath), callback));
867} 868}
868 869
869jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getSavePath(JNIEnv* env, jobject jobj, 870jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getSavePath(JNIEnv* env, jobject jobj,
diff --git a/src/frontend_common/content_manager.h b/src/frontend_common/content_manager.h
index fb92a1695..1cbaa73f7 100644
--- a/src/frontend_common/content_manager.h
+++ b/src/frontend_common/content_manager.h
@@ -47,14 +47,14 @@ inline bool RemoveDLC(const Service::FileSystem::FileSystemController& fs_contro
47 47
48/** 48/**
49 * \brief Removes all DLC for a game 49 * \brief Removes all DLC for a game
50 * \param system Raw pointer to the system instance 50 * \param system Reference to the system instance
51 * \param program_id Program ID for the game that will have all of its DLC removed 51 * \param program_id Program ID for the game that will have all of its DLC removed
52 * \return Number of DLC removed 52 * \return Number of DLC removed
53 */ 53 */
54inline size_t RemoveAllDLC(Core::System* system, const u64 program_id) { 54inline size_t RemoveAllDLC(Core::System& system, const u64 program_id) {
55 size_t count{}; 55 size_t count{};
56 const auto& fs_controller = system->GetFileSystemController(); 56 const auto& fs_controller = system.GetFileSystemController();
57 const auto dlc_entries = system->GetContentProvider().ListEntriesFilter( 57 const auto dlc_entries = system.GetContentProvider().ListEntriesFilter(
58 FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); 58 FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
59 std::vector<u64> program_dlc_entries; 59 std::vector<u64> program_dlc_entries;
60 60
@@ -124,15 +124,15 @@ inline bool RemoveMod(const Service::FileSystem::FileSystemController& fs_contro
124 124
125/** 125/**
126 * \brief Installs an NSP 126 * \brief Installs an NSP
127 * \param system Raw pointer to the system instance 127 * \param system Reference to the system instance
128 * \param vfs Raw pointer to the VfsFilesystem instance in Core::System 128 * \param vfs Reference to the VfsFilesystem instance in Core::System
129 * \param filename Path to the NSP file 129 * \param filename Path to the NSP file
130 * \param callback Callback to report the progress of the installation. The first size_t 130 * \param callback Callback to report the progress of the installation. The first size_t
131 * parameter is the total size of the virtual file and the second is the current progress. If you 131 * parameter is the total size of the virtual file and the second is the current progress. If you
132 * return true to the callback, it will cancel the installation as soon as possible. 132 * return true to the callback, it will cancel the installation as soon as possible.
133 * \return [InstallResult] representing how the installation finished 133 * \return [InstallResult] representing how the installation finished
134 */ 134 */
135inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vfs, 135inline InstallResult InstallNSP(Core::System& system, FileSys::VfsFilesystem& vfs,
136 const std::string& filename, 136 const std::string& filename,
137 const std::function<bool(size_t, size_t)>& callback) { 137 const std::function<bool(size_t, size_t)>& callback) {
138 const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, 138 const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest,
@@ -159,7 +159,7 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf
159 }; 159 };
160 160
161 std::shared_ptr<FileSys::NSP> nsp; 161 std::shared_ptr<FileSys::NSP> nsp;
162 FileSys::VirtualFile file = vfs->OpenFile(filename, FileSys::Mode::Read); 162 FileSys::VirtualFile file = vfs.OpenFile(filename, FileSys::Mode::Read);
163 if (boost::to_lower_copy(file->GetName()).ends_with(std::string("nsp"))) { 163 if (boost::to_lower_copy(file->GetName()).ends_with(std::string("nsp"))) {
164 nsp = std::make_shared<FileSys::NSP>(file); 164 nsp = std::make_shared<FileSys::NSP>(file);
165 if (nsp->IsExtractedType()) { 165 if (nsp->IsExtractedType()) {
@@ -173,7 +173,7 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf
173 return InstallResult::Failure; 173 return InstallResult::Failure;
174 } 174 }
175 const auto res = 175 const auto res =
176 system->GetFileSystemController().GetUserNANDContents()->InstallEntry(*nsp, true, copy); 176 system.GetFileSystemController().GetUserNANDContents()->InstallEntry(*nsp, true, copy);
177 switch (res) { 177 switch (res) {
178 case FileSys::InstallResult::Success: 178 case FileSys::InstallResult::Success:
179 return InstallResult::Success; 179 return InstallResult::Success;
@@ -188,17 +188,17 @@ inline InstallResult InstallNSP(Core::System* system, FileSys::VfsFilesystem* vf
188 188
189/** 189/**
190 * \brief Installs an NCA 190 * \brief Installs an NCA
191 * \param vfs Raw pointer to the VfsFilesystem instance in Core::System 191 * \param vfs Reference to the VfsFilesystem instance in Core::System
192 * \param filename Path to the NCA file 192 * \param filename Path to the NCA file
193 * \param registered_cache Raw pointer to the registered cache that the NCA will be installed to 193 * \param registered_cache Reference to the registered cache that the NCA will be installed to
194 * \param title_type Type of NCA package to install 194 * \param title_type Type of NCA package to install
195 * \param callback Callback to report the progress of the installation. The first size_t 195 * \param callback Callback to report the progress of the installation. The first size_t
196 * parameter is the total size of the virtual file and the second is the current progress. If you 196 * parameter is the total size of the virtual file and the second is the current progress. If you
197 * return true to the callback, it will cancel the installation as soon as possible. 197 * return true to the callback, it will cancel the installation as soon as possible.
198 * \return [InstallResult] representing how the installation finished 198 * \return [InstallResult] representing how the installation finished
199 */ 199 */
200inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string& filename, 200inline InstallResult InstallNCA(FileSys::VfsFilesystem& vfs, const std::string& filename,
201 FileSys::RegisteredCache* registered_cache, 201 FileSys::RegisteredCache& registered_cache,
202 const FileSys::TitleType title_type, 202 const FileSys::TitleType title_type,
203 const std::function<bool(size_t, size_t)>& callback) { 203 const std::function<bool(size_t, size_t)>& callback) {
204 const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest, 204 const auto copy = [callback](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest,
@@ -224,7 +224,7 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string&
224 return true; 224 return true;
225 }; 225 };
226 226
227 const auto nca = std::make_shared<FileSys::NCA>(vfs->OpenFile(filename, FileSys::Mode::Read)); 227 const auto nca = std::make_shared<FileSys::NCA>(vfs.OpenFile(filename, FileSys::Mode::Read));
228 const auto id = nca->GetStatus(); 228 const auto id = nca->GetStatus();
229 229
230 // Game updates necessary are missing base RomFS 230 // Game updates necessary are missing base RomFS
@@ -233,7 +233,7 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string&
233 return InstallResult::Failure; 233 return InstallResult::Failure;
234 } 234 }
235 235
236 const auto res = registered_cache->InstallEntry(*nca, title_type, true, copy); 236 const auto res = registered_cache.InstallEntry(*nca, title_type, true, copy);
237 if (res == FileSys::InstallResult::Success) { 237 if (res == FileSys::InstallResult::Success) {
238 return InstallResult::Success; 238 return InstallResult::Success;
239 } else if (res == FileSys::InstallResult::OverwriteExisting) { 239 } else if (res == FileSys::InstallResult::OverwriteExisting) {
@@ -245,19 +245,19 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem* vfs, const std::string&
245 245
246/** 246/**
247 * \brief Verifies the installed contents for a given ManualContentProvider 247 * \brief Verifies the installed contents for a given ManualContentProvider
248 * \param system Raw pointer to the system instance 248 * \param system Reference to the system instance
249 * \param provider Raw pointer to the content provider that's tracking indexed games 249 * \param provider Reference to the content provider that's tracking indexed games
250 * \param callback Callback to report the progress of the installation. The first size_t 250 * \param callback Callback to report the progress of the installation. The first size_t
251 * parameter is the total size of the installed contents and the second is the current progress. If 251 * parameter is the total size of the installed contents and the second is the current progress. If
252 * you return true to the callback, it will cancel the installation as soon as possible. 252 * you return true to the callback, it will cancel the installation as soon as possible.
253 * \return A list of entries that failed to install. Returns an empty vector if successful. 253 * \return A list of entries that failed to install. Returns an empty vector if successful.
254 */ 254 */
255inline std::vector<std::string> VerifyInstalledContents( 255inline std::vector<std::string> VerifyInstalledContents(
256 Core::System* system, FileSys::ManualContentProvider* provider, 256 Core::System& system, FileSys::ManualContentProvider& provider,
257 const std::function<bool(size_t, size_t)>& callback) { 257 const std::function<bool(size_t, size_t)>& callback) {
258 // Get content registries. 258 // Get content registries.
259 auto bis_contents = system->GetFileSystemController().GetSystemNANDContents(); 259 auto bis_contents = system.GetFileSystemController().GetSystemNANDContents();
260 auto user_contents = system->GetFileSystemController().GetUserNANDContents(); 260 auto user_contents = system.GetFileSystemController().GetUserNANDContents();
261 261
262 std::vector<FileSys::RegisteredCache*> content_providers; 262 std::vector<FileSys::RegisteredCache*> content_providers;
263 if (bis_contents) { 263 if (bis_contents) {
@@ -309,11 +309,11 @@ inline std::vector<std::string> VerifyInstalledContents(
309 const auto title_id = nca.GetTitleId(); 309 const auto title_id = nca.GetTitleId();
310 std::string title_name = "unknown"; 310 std::string title_name = "unknown";
311 311
312 const auto control = provider->GetEntry(FileSys::GetBaseTitleID(title_id), 312 const auto control = provider.GetEntry(FileSys::GetBaseTitleID(title_id),
313 FileSys::ContentRecordType::Control); 313 FileSys::ContentRecordType::Control);
314 if (control && control->GetStatus() == Loader::ResultStatus::Success) { 314 if (control && control->GetStatus() == Loader::ResultStatus::Success) {
315 const FileSys::PatchManager pm{title_id, system->GetFileSystemController(), 315 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
316 *provider}; 316 provider};
317 const auto [nacp, logo] = pm.ParseControlNCA(*control); 317 const auto [nacp, logo] = pm.ParseControlNCA(*control);
318 if (nacp) { 318 if (nacp) {
319 title_name = nacp->GetApplicationName(); 319 title_name = nacp->GetApplicationName();
@@ -335,7 +335,7 @@ inline std::vector<std::string> VerifyInstalledContents(
335 335
336/** 336/**
337 * \brief Verifies the contents of a given game 337 * \brief Verifies the contents of a given game
338 * \param system Raw pointer to the system instance 338 * \param system Reference to the system instance
339 * \param game_path Patch to the game file 339 * \param game_path Patch to the game file
340 * \param callback Callback to report the progress of the installation. The first size_t 340 * \param callback Callback to report the progress of the installation. The first size_t
341 * parameter is the total size of the installed contents and the second is the current progress. If 341 * parameter is the total size of the installed contents and the second is the current progress. If
@@ -343,10 +343,10 @@ inline std::vector<std::string> VerifyInstalledContents(
343 * \return GameVerificationResult representing how the verification process finished 343 * \return GameVerificationResult representing how the verification process finished
344 */ 344 */
345inline GameVerificationResult VerifyGameContents( 345inline GameVerificationResult VerifyGameContents(
346 Core::System* system, const std::string& game_path, 346 Core::System& system, const std::string& game_path,
347 const std::function<bool(size_t, size_t)>& callback) { 347 const std::function<bool(size_t, size_t)>& callback) {
348 const auto loader = Loader::GetLoader( 348 const auto loader =
349 *system, system->GetFilesystem()->OpenFile(game_path, FileSys::Mode::Read)); 349 Loader::GetLoader(system, system.GetFilesystem()->OpenFile(game_path, FileSys::Mode::Read));
350 if (loader == nullptr) { 350 if (loader == nullptr) {
351 return GameVerificationResult::NotImplemented; 351 return GameVerificationResult::NotImplemented;
352 } 352 }
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index bb0fbef7c..e14410f7d 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -2499,7 +2499,7 @@ void GMainWindow::RemoveUpdateContent(u64 program_id, InstalledEntryType type) {
2499} 2499}
2500 2500
2501void GMainWindow::RemoveAddOnContent(u64 program_id, InstalledEntryType type) { 2501void GMainWindow::RemoveAddOnContent(u64 program_id, InstalledEntryType type) {
2502 const size_t count = ContentManager::RemoveAllDLC(system.get(), program_id); 2502 const size_t count = ContentManager::RemoveAllDLC(*system, program_id);
2503 if (count == 0) { 2503 if (count == 0) {
2504 QMessageBox::warning(this, GetGameListErrorRemoving(type), 2504 QMessageBox::warning(this, GetGameListErrorRemoving(type),
2505 tr("There are no DLC installed for this title.")); 2505 tr("There are no DLC installed for this title."));
@@ -2796,8 +2796,7 @@ void GMainWindow::OnGameListVerifyIntegrity(const std::string& game_path) {
2796 return progress.wasCanceled(); 2796 return progress.wasCanceled();
2797 }; 2797 };
2798 2798
2799 const auto result = 2799 const auto result = ContentManager::VerifyGameContents(*system, game_path, QtProgressCallback);
2800 ContentManager::VerifyGameContents(system.get(), game_path, QtProgressCallback);
2801 progress.close(); 2800 progress.close();
2802 switch (result) { 2801 switch (result) {
2803 case ContentManager::GameVerificationResult::Success: 2802 case ContentManager::GameVerificationResult::Success:
@@ -3266,7 +3265,7 @@ void GMainWindow::OnMenuInstallToNAND() {
3266 return false; 3265 return false;
3267 }; 3266 };
3268 future = QtConcurrent::run([this, &file, progress_callback] { 3267 future = QtConcurrent::run([this, &file, progress_callback] {
3269 return ContentManager::InstallNSP(system.get(), vfs.get(), file.toStdString(), 3268 return ContentManager::InstallNSP(*system, *vfs, file.toStdString(),
3270 progress_callback); 3269 progress_callback);
3271 }); 3270 });
3272 3271
@@ -3369,7 +3368,7 @@ ContentManager::InstallResult GMainWindow::InstallNCA(const QString& filename) {
3369 } 3368 }
3370 return false; 3369 return false;
3371 }; 3370 };
3372 return ContentManager::InstallNCA(vfs.get(), filename.toStdString(), registered_cache, 3371 return ContentManager::InstallNCA(*vfs, filename.toStdString(), *registered_cache,
3373 static_cast<FileSys::TitleType>(index), progress_callback); 3372 static_cast<FileSys::TitleType>(index), progress_callback);
3374} 3373}
3375 3374
@@ -4119,7 +4118,7 @@ void GMainWindow::OnVerifyInstalledContents() {
4119 }; 4118 };
4120 4119
4121 const std::vector<std::string> result = 4120 const std::vector<std::string> result =
4122 ContentManager::VerifyInstalledContents(system.get(), provider.get(), QtProgressCallback); 4121 ContentManager::VerifyInstalledContents(*system, *provider, QtProgressCallback);
4123 progress.close(); 4122 progress.close();
4124 4123
4125 if (result.empty()) { 4124 if (result.empty()) {