mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
sceNpTrophy: Check if a trophy configuration file exists before starting the install process
This commit is contained in:
parent
7d84d0f83e
commit
94bb75fb7c
1 changed files with 24 additions and 24 deletions
|
@ -575,12 +575,28 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Callbacks
|
// open trophy pack file
|
||||||
// From RE-ing a game's state machine, it seems the possible order is one of the following:
|
std::string trp_path = vfs::get(Emu.GetDir() + "TROPDIR/" + ctxt->trp_name + "/TROPHY.TRP");
|
||||||
// * Install (Not installed) - Setup - Progress * ? - Finalize - Complete - Installed
|
fs::file stream(trp_path);
|
||||||
// * Reinstall (Corrupted) - Setup - Progress * ? - Finalize - Complete - Installed
|
|
||||||
// * Update (Required update) - Setup - Progress * ? - Finalize - Complete - Installed
|
if (!stream && Emu.GetCat() == "GD")
|
||||||
// * Installed
|
{
|
||||||
|
sceNpTrophy.warning("sceNpTrophyRegisterContext failed to open trophy file from boot path: '%s' (%s)", trp_path, fs::g_tls_error);
|
||||||
|
trp_path = vfs::get("/dev_bdvd/PS3_GAME/TROPDIR/" + ctxt->trp_name + "/TROPHY.TRP");
|
||||||
|
stream.open(trp_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if exists and opened
|
||||||
|
if (!stream)
|
||||||
|
{
|
||||||
|
const std::string msg = fmt::format("Failed to open trophy file: '%s' (%s)", trp_path, fs::g_tls_error);
|
||||||
|
return {SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST, msg};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// SCE_NP_TROPHY_STATUS_DATA_CORRUPT -> reinstall
|
||||||
|
// SCE_NP_TROPHY_STATUS_REQUIRES_UPDATE -> reinstall (for example if a patch has updates for the trophy data)
|
||||||
|
// SCE_NP_TROPHY_STATUS_CHANGES_DETECTED -> reinstall (only possible in dev mode)
|
||||||
|
|
||||||
const std::string trophyPath = "/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name;
|
const std::string trophyPath = "/dev_hdd0/home/" + Emu.GetUsr() + "/trophy/" + ctxt->trp_name;
|
||||||
const s32 trp_status = fs::is_dir(vfs::get(trophyPath)) ? SCE_NP_TROPHY_STATUS_INSTALLED : SCE_NP_TROPHY_STATUS_NOT_INSTALLED;
|
const s32 trp_status = fs::is_dir(vfs::get(trophyPath)) ? SCE_NP_TROPHY_STATUS_INSTALLED : SCE_NP_TROPHY_STATUS_NOT_INSTALLED;
|
||||||
|
@ -589,6 +605,7 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
|
||||||
|
|
||||||
sceNpTrophy.notice("sceNpTrophyRegisterContext(): Callback is being called (trp_status=%u)", trp_status);
|
sceNpTrophy.notice("sceNpTrophyRegisterContext(): Callback is being called (trp_status=%u)", trp_status);
|
||||||
|
|
||||||
|
// "Ask permission" to install the trophy data.
|
||||||
// The callback is called once and then if it returns >= 0 the cb is called through events(coming from vsh) that are passed to the CB through cellSysutilCheckCallback
|
// The callback is called once and then if it returns >= 0 the cb is called through events(coming from vsh) that are passed to the CB through cellSysutilCheckCallback
|
||||||
if (statusCb(ppu, context, trp_status, 0, 0, arg) < 0)
|
if (statusCb(ppu, context, trp_status, 0, 0, arg) < 0)
|
||||||
{
|
{
|
||||||
|
@ -628,24 +645,6 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
|
||||||
return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
|
return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open trophy pack file
|
|
||||||
std::string trp_path = vfs::get(Emu.GetDir() + "TROPDIR/" + ctxt->trp_name + "/TROPHY.TRP");
|
|
||||||
fs::file stream(trp_path);
|
|
||||||
|
|
||||||
if (!stream && Emu.GetCat() == "GD")
|
|
||||||
{
|
|
||||||
sceNpTrophy.warning("sceNpTrophyRegisterContext failed to open trophy file from boot path: '%s' (%s)", trp_path, fs::g_tls_error);
|
|
||||||
trp_path = vfs::get("/dev_bdvd/PS3_GAME/TROPDIR/" + ctxt->trp_name + "/TROPHY.TRP");
|
|
||||||
stream.open(trp_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if exists and opened
|
|
||||||
if (!stream)
|
|
||||||
{
|
|
||||||
const std::string msg = fmt::format("Failed to open trophy file: '%s' (%s)", trp_path, fs::g_tls_error);
|
|
||||||
return {SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST, msg};
|
|
||||||
}
|
|
||||||
|
|
||||||
TRPLoader trp(stream);
|
TRPLoader trp(stream);
|
||||||
if (!trp.LoadHeader())
|
if (!trp.LoadHeader())
|
||||||
{
|
{
|
||||||
|
@ -725,6 +724,7 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle,
|
||||||
{
|
{
|
||||||
sysutil_register_cb([statusCb, status, context, completed, arg, wkptr](ppu_thread& cb_ppu) -> s32
|
sysutil_register_cb([statusCb, status, context, completed, arg, wkptr](ppu_thread& cb_ppu) -> s32
|
||||||
{
|
{
|
||||||
|
// TODO: it is possible that we need to check the return value here as well.
|
||||||
statusCb(cb_ppu, context, status.first, completed, status.second, arg);
|
statusCb(cb_ppu, context, status.first, completed, status.second, arg);
|
||||||
|
|
||||||
const auto queued = wkptr.lock();
|
const auto queued = wkptr.lock();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue