summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-09-01 13:11:30 -0400
committerGravatar Zach Hilman2018-09-04 16:24:02 -0400
commitc91b60a421a3bd0dc85d80e0a5a2d261370df340 (patch)
treecc4867bcef325b7e7b4d268f29705e38fd3ca180 /src
parentbktr: Add logging on successful patch (diff)
downloadyuzu-c91b60a421a3bd0dc85d80e0a5a2d261370df340.tar.gz
yuzu-c91b60a421a3bd0dc85d80e0a5a2d261370df340.tar.xz
yuzu-c91b60a421a3bd0dc85d80e0a5a2d261370df340.zip
game_list: Fix version display on non-NAND titles
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/patch_manager.cpp28
-rw-r--r--src/core/file_sys/patch_manager.h2
-rw-r--r--src/core/loader/xci.cpp11
-rw-r--r--src/yuzu/game_list.cpp41
4 files changed, 52 insertions, 30 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index 8b7d79773..b6e25f7eb 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -82,15 +82,31 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset,
82 return romfs; 82 return romfs;
83} 83}
84 84
85std::map<PatchType, u32> PatchManager::GetPatchVersionNames() const { 85std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const {
86 std::map<PatchType, u32> out; 86 std::map<PatchType, std::string> out;
87 const auto installed = Service::FileSystem::GetUnionContents(); 87 const auto installed = Service::FileSystem::GetUnionContents();
88 88
89 const auto update_tid = GetUpdateTitleID(title_id); 89 const auto update_tid = GetUpdateTitleID(title_id);
90 const auto update_version = installed->GetEntryVersion(update_tid); 90 const auto update_control = installed->GetEntry(title_id, ContentRecordType::Control);
91 if (update_version != boost::none && 91 if (update_control != nullptr) {
92 installed->HasEntry(update_tid, ContentRecordType::Program)) { 92 do {
93 out[PatchType::Update] = update_version.get(); 93 const auto romfs =
94 PatchRomFS(update_control->GetRomFS(), update_control->GetBaseIVFCOffset(),
95 FileSys::ContentRecordType::Control);
96 if (romfs == nullptr)
97 break;
98
99 const auto control_dir = FileSys::ExtractRomFS(romfs);
100 if (control_dir == nullptr)
101 break;
102
103 const auto nacp_file = control_dir->GetFile("control.nacp");
104 if (nacp_file == nullptr)
105 break;
106
107 FileSys::NACP nacp(nacp_file);
108 out[PatchType::Update] = nacp.GetVersionString();
109 } while (false);
94 } 110 }
95 111
96 return out; 112 return out;
diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h
index 021bc3366..b6bf86222 100644
--- a/src/core/file_sys/patch_manager.h
+++ b/src/core/file_sys/patch_manager.h
@@ -45,7 +45,7 @@ public:
45 45
46 // Returns a vector of pairs between patch names and patch versions. 46 // Returns a vector of pairs between patch names and patch versions.
47 // i.e. Update v80 will return {Update, 80} 47 // i.e. Update v80 will return {Update, 80}
48 std::map<PatchType, u32> GetPatchVersionNames() const; 48 std::map<PatchType, std::string> GetPatchVersionNames() const;
49 49
50private: 50private:
51 u64 title_id; 51 u64 title_id;
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp
index 75b998faa..b01d51abb 100644
--- a/src/core/loader/xci.cpp
+++ b/src/core/loader/xci.cpp
@@ -8,6 +8,7 @@
8#include "core/file_sys/card_image.h" 8#include "core/file_sys/card_image.h"
9#include "core/file_sys/content_archive.h" 9#include "core/file_sys/content_archive.h"
10#include "core/file_sys/control_metadata.h" 10#include "core/file_sys/control_metadata.h"
11#include "core/file_sys/patch_manager.h"
11#include "core/file_sys/romfs.h" 12#include "core/file_sys/romfs.h"
12#include "core/hle/kernel/process.h" 13#include "core/hle/kernel/process.h"
13#include "core/loader/nca.h" 14#include "core/loader/nca.h"
@@ -20,10 +21,18 @@ AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file)
20 nca_loader(std::make_unique<AppLoader_NCA>(xci->GetProgramNCAFile())) { 21 nca_loader(std::make_unique<AppLoader_NCA>(xci->GetProgramNCAFile())) {
21 if (xci->GetStatus() != ResultStatus::Success) 22 if (xci->GetStatus() != ResultStatus::Success)
22 return; 23 return;
24
23 const auto control_nca = xci->GetNCAByType(FileSys::NCAContentType::Control); 25 const auto control_nca = xci->GetNCAByType(FileSys::NCAContentType::Control);
26
24 if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success) 27 if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success)
25 return; 28 return;
26 const auto romfs = FileSys::ExtractRomFS(control_nca->GetRomFS()); 29
30 auto romfs_raw = control_nca->GetRomFS();
31 FileSys::PatchManager patch{xci->GetNCAByType(FileSys::NCAContentType::Program)->GetTitleId()};
32 romfs_raw = patch.PatchRomFS(romfs_raw, control_nca->GetBaseIVFCOffset(),
33 FileSys::ContentRecordType::Control);
34
35 const auto romfs = FileSys::ExtractRomFS(romfs_raw);
27 if (romfs == nullptr) 36 if (romfs == nullptr)
28 return; 37 return;
29 for (const auto& language : FileSys::LANGUAGE_NAMES) { 38 for (const auto& language : FileSys::LANGUAGE_NAMES) {
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 02d8a3882..38c5071e3 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -457,23 +457,17 @@ static QString FormatGameName(const std::string& physical_name) {
457} 457}
458 458
459static QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, 459static QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager,
460 std::string update_version_override = "",
461 bool updatable = true) { 460 bool updatable = true) {
462 QString out; 461 QString out;
463 for (const auto& kv : patch_manager.GetPatchVersionNames()) { 462 for (const auto& kv : patch_manager.GetPatchVersionNames()) {
464 if (!updatable && kv.first == FileSys::PatchType::Update) 463 if (!updatable && kv.first == FileSys::PatchType::Update)
465 continue; 464 continue;
466 465
467 if (kv.second == 0) { 466 if (kv.second.empty()) {
468 out.append(fmt::format("{}\n", FileSys::FormatPatchTypeName(kv.first)).c_str()); 467 out.append(fmt::format("{}\n", FileSys::FormatPatchTypeName(kv.first)).c_str());
469 } else { 468 } else {
470 auto version_data = FileSys::FormatTitleVersion(kv.second); 469 out.append(fmt::format("{} ({})\n", FileSys::FormatPatchTypeName(kv.first), kv.second)
471 if (kv.first == FileSys::PatchType::Update && !update_version_override.empty()) 470 .c_str());
472 version_data = update_version_override;
473
474 out.append(
475 fmt::format("{} ({})\n", FileSys::FormatPatchTypeName(kv.first), version_data)
476 .c_str());
477 } 471 }
478 } 472 }
479 473
@@ -491,8 +485,7 @@ void GameList::RefreshGameDirectory() {
491 485
492static void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager, 486static void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager,
493 const std::shared_ptr<FileSys::NCA>& nca, 487 const std::shared_ptr<FileSys::NCA>& nca,
494 std::vector<u8>& icon, std::string& name, 488 std::vector<u8>& icon, std::string& name) {
495 std::string& version) {
496 const auto romfs = patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(), 489 const auto romfs = patch_manager.PatchRomFS(nca->GetRomFS(), nca->GetBaseIVFCOffset(),
497 FileSys::ContentRecordType::Control); 490 FileSys::ContentRecordType::Control);
498 if (romfs == nullptr) 491 if (romfs == nullptr)
@@ -507,7 +500,6 @@ static void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager
507 return; 500 return;
508 FileSys::NACP nacp(nacp_file); 501 FileSys::NACP nacp(nacp_file);
509 name = nacp.GetApplicationName(); 502 name = nacp.GetApplicationName();
510 version = nacp.GetVersionString();
511 503
512 FileSys::VirtualFile icon_file = nullptr; 504 FileSys::VirtualFile icon_file = nullptr;
513 for (const auto& language : FileSys::LANGUAGE_NAMES) { 505 for (const auto& language : FileSys::LANGUAGE_NAMES) {
@@ -527,7 +519,8 @@ GameListWorker::GameListWorker(
527 519
528GameListWorker::~GameListWorker() = default; 520GameListWorker::~GameListWorker() = default;
529 521
530void GameListWorker::AddInstalledTitlesToGameList(std::shared_ptr<FileSys::RegisteredCache> cache) { 522void GameListWorker::AddInstalledTitlesToGameList() {
523 const auto cache = Service::FileSystem::GetUnionContents();
531 const auto installed_games = cache->ListEntriesFilter(FileSys::TitleType::Application, 524 const auto installed_games = cache->ListEntriesFilter(FileSys::TitleType::Application,
532 FileSys::ContentRecordType::Program); 525 FileSys::ContentRecordType::Program);
533 526
@@ -539,20 +532,28 @@ void GameListWorker::AddInstalledTitlesToGameList(std::shared_ptr<FileSys::Regis
539 532
540 std::vector<u8> icon; 533 std::vector<u8> icon;
541 std::string name; 534 std::string name;
542 std::string version = "";
543 u64 program_id = 0; 535 u64 program_id = 0;
544 loader->ReadProgramId(program_id); 536 loader->ReadProgramId(program_id);
545 537
546 const FileSys::PatchManager patch{program_id}; 538 const FileSys::PatchManager patch{program_id};
547 const auto& control = cache->GetEntry(game.title_id, FileSys::ContentRecordType::Control); 539 const auto& control = cache->GetEntry(game.title_id, FileSys::ContentRecordType::Control);
548 if (control != nullptr) 540 if (control != nullptr)
549 GetMetadataFromControlNCA(patch, control, icon, name, version); 541 GetMetadataFromControlNCA(patch, control, icon, name);
542
543 auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
544
545 // The game list uses this as compatibility number for untested games
546 QString compatibility("99");
547 if (it != compatibility_list.end())
548 compatibility = it->second.first;
549
550 emit EntryReady({ 550 emit EntryReady({
551 new GameListItemPath( 551 new GameListItemPath(
552 FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name), 552 FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name),
553 QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), 553 QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())),
554 program_id), 554 program_id),
555 new GameListItem(FormatPatchNameVersions(patch, version)), 555 new GameListItemCompat(compatibility),
556 new GameListItem(FormatPatchNameVersions(patch)),
556 new GameListItem( 557 new GameListItem(
557 QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), 558 QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))),
558 new GameListItemSize(file->GetSize()), 559 new GameListItemSize(file->GetSize()),
@@ -620,14 +621,12 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
620 621
621 const FileSys::PatchManager patch{program_id}; 622 const FileSys::PatchManager patch{program_id};
622 623
623 std::string version = "";
624
625 if (res1 != Loader::ResultStatus::Success && res3 != Loader::ResultStatus::Success && 624 if (res1 != Loader::ResultStatus::Success && res3 != Loader::ResultStatus::Success &&
626 res2 == Loader::ResultStatus::Success) { 625 res2 == Loader::ResultStatus::Success) {
627 // Use from metadata pool. 626 // Use from metadata pool.
628 if (nca_control_map.find(program_id) != nca_control_map.end()) { 627 if (nca_control_map.find(program_id) != nca_control_map.end()) {
629 const auto nca = nca_control_map[program_id]; 628 const auto nca = nca_control_map[program_id];
630 GetMetadataFromControlNCA(patch, nca, icon, name, version); 629 GetMetadataFromControlNCA(patch, nca, icon, name);
631 } 630 }
632 } 631 }
633 632
@@ -644,9 +643,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
644 QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), 643 QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())),
645 program_id), 644 program_id),
646 new GameListItemCompat(compatibility), 645 new GameListItemCompat(compatibility),
647 new GameListItem(FormatPatchNameVersions(program_id, loader->IsRomFSUpdatable())), 646 new GameListItem(FormatPatchNameVersions(patch, loader->IsRomFSUpdatable())),
648 new GameListItem(
649 FormatPatchNameVersions(patch, version, loader->IsRomFSUpdatable())),
650 new GameListItem( 647 new GameListItem(
651 QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), 648 QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))),
652 new GameListItemSize(FileUtil::GetSize(physical_name)), 649 new GameListItemSize(FileUtil::GetSize(physical_name)),