2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

main: Fallback to loader if no control nca is found with patch manager

In some rare instances, the patch manager is not able to find a control nca, fallback to the previous method of parsing a control nca through the loader if this occurs.
This commit is contained in:
Morph 2020-07-19 23:52:06 -04:00
parent 1146049de0
commit cf946312ca

View file

@ -1244,13 +1244,24 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
std::string path; std::string path;
QString open_target; QString open_target;
FileSys::PatchManager pm{program_id}; const auto [user_save_size, device_save_size] = [this, &program_id, &game_path] {
const auto control = pm.GetControlMetadata(); FileSys::PatchManager pm{program_id};
const auto v_file = Core::GetGameFileFromPath(vfs, game_path); const auto control = pm.GetControlMetadata().first;
const auto loader = Loader::GetLoader(v_file); if (control != nullptr) {
return std::make_pair(control->GetDefaultNormalSaveSize(),
control->GetDeviceSaveDataSize());
} else {
const auto file = Core::GetGameFileFromPath(vfs, game_path);
const auto loader = Loader::GetLoader(file);
const bool has_user_save{control.first->GetDefaultNormalSaveSize() > 0}; FileSys::NACP nacp{};
const bool has_device_save{control.first->GetDeviceSaveDataSize() > 0}; loader->ReadControlData(nacp);
return std::make_pair(nacp.GetDefaultNormalSaveSize(), nacp.GetDeviceSaveDataSize());
}
}();
const bool has_user_save{user_save_size > 0};
const bool has_device_save{device_save_size > 0};
ASSERT_MSG(has_user_save != has_device_save, "Game uses both user and device savedata?"); ASSERT_MSG(has_user_save != has_device_save, "Game uses both user and device savedata?");