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 c683df9 commit a19383d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
40 changes: 34 additions & 6 deletions rpcs3/Emu/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,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
{
m_inherited_ps3_game = std::move(game_path);
}
}
else if (!g_cfg.savestate.state_inspection_mode)
{
Expand Down Expand Up @@ -1485,7 +1492,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
{
m_inherited_ps3_game = std::move(game_path);
}
}
else
{
Expand Down Expand Up @@ -1587,9 +1601,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 (!m_inherited_ps3_game.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 +1612,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", m_inherited_ps3_game.empty() ? hdd0_game + m_path.substr(hdd0_game.size(), 10) : m_inherited_ps3_game);

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
1 change: 1 addition & 0 deletions rpcs3/Emu/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class Emulator final
std::vector<u8> data;
std::vector<u128> klic;
std::string disc;
std::string m_inherited_ps3_game;
std::string hdd1;
std::function<void(u32)> init_mem_containers;
std::function<void()> after_kill_callback;
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 a19383d

Please sign in to comment.