only pass one smdh

This commit is contained in:
BreadFish64 2018-01-23 21:32:27 -06:00
parent 4da837c929
commit eb1b5f588a
2 changed files with 16 additions and 21 deletions

View file

@ -396,37 +396,34 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
if (!loader)
return true;
std::vector<u8> smdh;
loader->ReadIcon(smdh);
u64 program_id = 0;
loader->ReadProgramId(program_id);
std::vector<u8> update_smdh = [program_id]() -> std::vector<u8> {
if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF)
return {};
std::vector<u8> smdh = [program_id, &loader]() -> std::vector<u8> {
std::vector<u8> original_smdh;
loader->ReadIcon(original_smdh);
u64 update_id = program_id + 0xe00000000;
std::string update_path =
Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, update_id);
if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF)
return original_smdh;
std::string update_path = Service::AM::GetTitleContentPath(
Service::FS::MediaType::SDMC, program_id + 0xe00000000);
if (!FileUtil::Exists(update_path))
return {};
return original_smdh;
std::unique_ptr<Loader::AppLoader> update_loader = Loader::GetLoader(update_path);
if (!update_loader)
return {};
return original_smdh;
std::vector<u8> update_smdh;
update_loader->ReadIcon(update_smdh);
update_loader->ReadProgramId(update_id);
return update_smdh;
}();
emit EntryReady({
new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id,
update_smdh),
new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id),
new GameListItem(
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))),
new GameListItemSize(FileUtil::GetSize(physical_name)),

View file

@ -72,22 +72,20 @@ public:
static const int ProgramIdRole = Qt::UserRole + 3;
GameListItemPath() : GameListItem() {}
GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id,
const std::vector<u8>& update_smdh)
GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id)
: GameListItem() {
setData(game_path, FullPathRole);
setData(qulonglong(program_id), ProgramIdRole);
Loader::SMDH smdh;
if (Loader::IsValidSMDH(update_smdh)) {
memcpy(&smdh, update_smdh.data(), sizeof(Loader::SMDH));
} else if (Loader::IsValidSMDH(smdh_data)) {
memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH));
} else {
if (!Loader::IsValidSMDH(smdh_data)) {
// SMDH is not valid, set a default icon
setData(GetDefaultIcon(true), Qt::DecorationRole);
return;
}
memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH));
// Get icon from SMDH
setData(GetQPixmapFromSMDH(smdh, true), Qt::DecorationRole);