Skip to content

Commit

Permalink
System.cpp: Fix disc game PS3_GAME mounting with update
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jul 9, 2023
1 parent 1c283c1 commit 0025503
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
42 changes: 36 additions & 6 deletions rpcs3/Emu/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
}
} cleanup{this};

std::string inherited_ps3_game_path;

{
Init();

Expand Down Expand Up @@ -918,7 +920,14 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
// Load /dev_bdvd/ from game list if available
if (std::string game_path = m_games_config.get_path(m_title_id); !game_path.empty())
{
disc = std::move(game_path);
if (fs::is_file(game_path + "/PS3_DISC.SFB"))
{
disc = std::move(game_path);
}
else
{
inherited_ps3_game_path = std::move(game_path);
}
}
else if (!g_cfg.savestate.state_inspection_mode)
{
Expand Down Expand Up @@ -1485,7 +1494,14 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
// Load /dev_bdvd/ from game list if available
if (std::string game_path = m_games_config.get_path(m_title_id); !game_path.empty())
{
bdvd_dir = std::move(game_path);
if (fs::is_file(game_path + "/PS3_DISC.SFB"))
{
bdvd_dir = std::move(game_path);
}
else
{
inherited_ps3_game_path = std::move(game_path);
}
}
else
{
Expand Down Expand Up @@ -1587,9 +1603,9 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
vfs::mount("/dev_hdd0/game/" + m_title_id, game_dir + '/');
}
}
else if (m_cat == "DG" && from_hdd0_game && disc.empty())
else if (!inherited_ps3_game_path.empty() || (from_hdd0_game && m_cat == "DG" && disc.empty()))
{
// Disc game located in dev_hdd0/game
// Disc game
bdvd_dir = g_cfg_vfs.get(g_cfg_vfs.dev_bdvd, rpcs3::utils::get_emu_dir());

if (fs::get_dir_size(bdvd_dir))
Expand All @@ -1598,9 +1614,23 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
return game_boot_result::invalid_bdvd_folder;
}

// TODO: Verify timestamps and error codes with sys_fs
vfs::mount("/dev_bdvd", bdvd_dir);
vfs::mount("/dev_bdvd/PS3_GAME", hdd0_game + m_path.substr(hdd0_game.size(), 10));
sys_log.notice("Game: %s", vfs::get("/dev_bdvd/PS3_GAME"));

vfs::mount("/dev_bdvd/PS3_GAME", inherited_ps3_game_path.empty() ? hdd0_game + m_path.substr(hdd0_game.size(), 10) : inherited_ps3_game_path);

const std::string new_ps3_game = vfs::get("/dev_bdvd/PS3_GAME");
sys_log.notice("Game: %s", new_ps3_game);

// Store /dev_bdvd/PS3_GAME location
if (m_games_config.add_game(m_title_id, new_ps3_game))
{
sys_log.notice("Registered BDVD/PS3_GAME game directory for title '%s': %s", m_title_id, new_ps3_game);
}
else
{
sys_log.error("Failed to save BDVD/PS3_GAME location of title '%s' (error=%s)", m_title_id, fs::g_tls_error);
}
}
else if (disc.empty())
{
Expand Down
6 changes: 4 additions & 2 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,17 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
}
};

add_dir(_hdd + "game/", false);
const std::string hdd0_game = _hdd + "game/";

add_dir(hdd0_game, false);
add_dir(_hdd + "disc/", true); // Deprecated

for (const auto& [serial, path] : Emu.GetGamesConfig().get_games())
{
std::string game_dir = path;
game_dir.resize(game_dir.find_last_not_of('/') + 1);

if (game_dir.empty())
if (game_dir.empty() || path.starts_with(hdd0_game))
{
continue;
}
Expand Down

0 comments on commit 0025503

Please sign in to comment.