mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-15 11:18:36 +12:00
Fix rXml limitation
(trophies)
This commit is contained in:
parent
1262263f5c
commit
2e510e5ca0
4 changed files with 39 additions and 29 deletions
|
@ -398,12 +398,15 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr<SceNpTrophyGa
|
|||
}
|
||||
|
||||
// TODO: Get the path of the current user
|
||||
const std::string& path = vfs::get("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + "/TROPCONF.SFM");
|
||||
fs::file config(vfs::get("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + "/TROPCONF.SFM"));
|
||||
|
||||
if (!config)
|
||||
{
|
||||
return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
// TODO: rXmlDocument can open only real file
|
||||
verify(HERE), !fs::get_virtual_device(path);
|
||||
rXmlDocument doc;
|
||||
doc.Load(path);
|
||||
doc.Read(config.to_string());
|
||||
|
||||
for (std::shared_ptr<rXmlNode> n = doc.GetRoot()->GetChildren(); n; n = n->GetNext())
|
||||
{
|
||||
|
@ -551,12 +554,16 @@ error_code sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::p
|
|||
}
|
||||
|
||||
// TODO: Get the path of the current user
|
||||
const std::string& path = vfs::get("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + "/TROPCONF.SFM");
|
||||
fs::file config(vfs::get("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + "/TROPCONF.SFM"));
|
||||
|
||||
if (!config)
|
||||
{
|
||||
return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
// TODO: rXmlDocument can open only real file
|
||||
verify(HERE), !fs::get_virtual_device(path);
|
||||
rXmlDocument doc;
|
||||
doc.Load(path);
|
||||
doc.Read(config.to_string());
|
||||
|
||||
auto trophy_base = doc.GetRoot();
|
||||
if (trophy_base->GetChildren()->GetName() == "trophyconf")
|
||||
{
|
||||
|
@ -564,7 +571,8 @@ error_code sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::p
|
|||
}
|
||||
|
||||
bool found = false;
|
||||
for (std::shared_ptr<rXmlNode> n = trophy_base->GetChildren(); n; n = n->GetNext()) {
|
||||
for (std::shared_ptr<rXmlNode> n = trophy_base->GetChildren(); n; n = n->GetNext())
|
||||
{
|
||||
if (n->GetName() == "trophy" && (trophyId == atoi(n->GetAttribute("id").c_str())))
|
||||
{
|
||||
found = true;
|
||||
|
@ -681,21 +689,21 @@ error_code sceNpTrophyGetGameIcon(u32 context, u32 handle, vm::ptr<void> buffer,
|
|||
return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
|
||||
}
|
||||
|
||||
const std::string& path = vfs::get("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + "/ICON0.PNG");
|
||||
fs::file icon_file(vfs::get("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + "/ICON0.PNG"));
|
||||
|
||||
if (!fs::exists(path))
|
||||
if (!icon_file)
|
||||
{
|
||||
return SCE_NP_TROPHY_ERROR_UNKNOWN_FILE;
|
||||
}
|
||||
|
||||
fs::file gameIconFile(path);
|
||||
const u32 icon_size = ::size32(icon_file);
|
||||
|
||||
if (buffer && *size >= gameIconFile.size())
|
||||
if (buffer && *size >= icon_size)
|
||||
{
|
||||
gameIconFile.read(buffer.get_ptr(), gameIconFile.size());
|
||||
icon_file.read(buffer.get_ptr(), icon_size);
|
||||
}
|
||||
|
||||
*size = gameIconFile.size();
|
||||
*size = icon_size;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -734,21 +742,21 @@ error_code sceNpTrophyGetTrophyIcon(u32 context, u32 handle, s32 trophyId, vm::p
|
|||
return hidden ? SCE_NP_TROPHY_ERROR_HIDDEN : SCE_NP_TROPHY_ERROR_LOCKED;
|
||||
}
|
||||
|
||||
const std::string& path = vfs::get("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + fmt::format("/TROP%03d.PNG", trophyId));
|
||||
fs::file icon_file(vfs::get("/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name + fmt::format("/TROP%03d.PNG", trophyId)));
|
||||
|
||||
if (!fs::exists(path))
|
||||
if (!icon_file)
|
||||
{
|
||||
return SCE_NP_TROPHY_ERROR_UNKNOWN_FILE;
|
||||
}
|
||||
|
||||
fs::file trophyIconFile(path);
|
||||
const u32 icon_size = ::size32(icon_file);
|
||||
|
||||
if (buffer && *size >= trophyIconFile.size())
|
||||
if (buffer && *size >= icon_size)
|
||||
{
|
||||
trophyIconFile.read(buffer.get_ptr(), trophyIconFile.size());
|
||||
icon_file.read(buffer.get_ptr(), icon_size);
|
||||
}
|
||||
|
||||
*size = trophyIconFile.size();
|
||||
*size = icon_size;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue