From 3a68b7ac0d6ba46b40fea81a9619e497b3772eaf Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 12 Feb 2023 21:17:03 +0100 Subject: [PATCH] Fix C00 boot from external HG games --- rpcs3/Emu/System.cpp | 24 ++++++++++++++++++++---- rpcs3/rpcs3qt/game_list_frame.cpp | 6 ++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 9344fc1288..ef619f3a49 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -1184,7 +1184,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool } else { - m_sfo_dir = rpcs3::utils::get_sfo_dir_from_game_path(elf_dir + "/../", m_title_id); + m_sfo_dir = rpcs3::utils::get_sfo_dir_from_game_path(fs::get_parent_dir(elf_dir), m_title_id); } _psf = psf::load_object(m_sfo_dir + "/PARAM.SFO"); @@ -1633,8 +1633,16 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool if (!m_title_id.empty() && !from_hdd0_game && m_cat == "HG") { + std::string game_dir = m_sfo_dir; + + // Don't use the C00 subdirectory in our game list + if (game_dir.ends_with("/C00") || game_dir.ends_with("\\C00")) + { + game_dir = game_dir.substr(0, game_dir.size() - 4); + } + // Add HG games not in HDD0 to games.yml - games[m_title_id] = m_sfo_dir; + games[m_title_id] = game_dir; YAML::Emitter out; out << games; @@ -1645,7 +1653,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool sys_log.error("Failed to save HG game location of title '%s' (error=%s)", m_title_id, fs::g_tls_error); } - vfs::mount("/dev_hdd0/game/" + m_title_id, m_sfo_dir + '/'); + vfs::mount("/dev_hdd0/game/" + m_title_id, game_dir + '/'); } } else if (m_cat == "DG" && from_hdd0_game && disc.empty()) @@ -1977,8 +1985,16 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool } else if (!m_title_id.empty() && m_cat == "HG") { + std::string game_dir = m_sfo_dir; + + // Remove the C00 suffix + if (game_dir.ends_with("/C00") || game_dir.ends_with("\\C00")) + { + game_dir = game_dir.substr(0, game_dir.size() - 4); + } + m_dir = "/dev_hdd0/game/" + m_title_id + '/'; - argv[0] = m_dir + unescape(resolved_path.substr(GetCallbacks().resolve_path(m_sfo_dir).size())); + argv[0] = m_dir + unescape(resolved_path.substr(GetCallbacks().resolve_path(game_dir).size())); sys_log.notice("Boot path: %s", m_dir); } else if (g_cfg.vfs.host_root) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index b105779baa..e7a6b7d2d7 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -546,6 +546,12 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) continue; } + // Don't use the C00 subdirectory in our game list + if (game_dir.ends_with("/C00") || game_dir.ends_with("\\C00")) + { + game_dir = game_dir.substr(0, game_dir.size() - 4); + } + const bool has_sfo = fs::is_file(game_dir + "/PARAM.SFO"); if (!has_sfo && fs::is_file(game_dir + "/PS3_DISC.SFB"))