From 901f503a3a14e8d3d6317448d85b3420dbe7cd91 Mon Sep 17 00:00:00 2001 From: Cornee Traas Date: Thu, 16 Mar 2017 23:04:43 +0100 Subject: [PATCH] Fix mounting bdvd when elf in subdirectory Causes MGS4 to boot further --- rpcs3/Emu/System.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 99390def52..b47edb5b8e 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -226,8 +226,8 @@ void Emulator::Load() // Mount all devices const std::string emu_dir_ = g_cfg_vfs_emulator_dir; const std::string emu_dir = emu_dir_.empty() ? fs::get_config_dir() : emu_dir_; - const std::string bdvd_dir = g_cfg_vfs_dev_bdvd; const std::string home_dir = g_cfg_vfs_app_home; + std::string bdvd_dir = g_cfg_vfs_dev_bdvd; vfs::mount("dev_hdd0", fmt::replace_all(g_cfg_vfs_dev_hdd0, "$(EmulatorDir)", emu_dir)); vfs::mount("dev_hdd1", fmt::replace_all(g_cfg_vfs_dev_hdd1, "$(EmulatorDir)", emu_dir)); @@ -237,25 +237,18 @@ void Emulator::Load() vfs::mount("app_home", home_dir.empty() ? elf_dir + '/' : fmt::replace_all(home_dir, "$(EmulatorDir)", emu_dir)); // Mount /dev_bdvd/ if necessary - if (bdvd_dir.empty() && fs::is_file(elf_dir + "/../../PS3_DISC.SFB")) + if (bdvd_dir.empty()) { - const auto dir_list = fmt::split(elf_dir, { "/", "\\" }); - - // Check latest two directories - if (dir_list.size() >= 2 && dir_list.back() == "USRDIR" && *(dir_list.end() - 2) == "PS3_GAME") - { - vfs::mount("dev_bdvd", elf_dir.substr(0, elf_dir.length() - 15)); + size_t pos = elf_dir.rfind("PS3_GAME"); + std::string temp = elf_dir.substr(0, pos); + if ((pos != std::string::npos) && fs::is_file(temp + "/PS3_DISC.SFB")) { + bdvd_dir = temp; } - else - { - vfs::mount("dev_bdvd", elf_dir + "/../../"); - } - - LOG_NOTICE(LOADER, "Disc: %s", vfs::get("/dev_bdvd")); } - else if (bdvd_dir.size()) + if (!bdvd_dir.empty() && fs::is_dir(bdvd_dir)) { vfs::mount("dev_bdvd", fmt::replace_all(bdvd_dir, "$(EmulatorDir)", emu_dir)); + LOG_NOTICE(LOADER, "Disc: %s", vfs::get("/dev_bdvd")); } // Mount /host_root/ if necessary