mirror of https://github.com/RPCS3/rpcs3.git
improve sceNpTrophyGetTrophyInfo and sceNpTrophyGetGameInfo
This commit is contained in:
parent
ee0fe28ddc
commit
2d68aed68f
|
@ -422,31 +422,41 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr<SceNpTrophyGa
|
||||||
rXmlDocument doc;
|
rXmlDocument doc;
|
||||||
doc.Read(config.to_string());
|
doc.Read(config.to_string());
|
||||||
|
|
||||||
for (std::shared_ptr<rXmlNode> n = doc.GetRoot()->GetChildren(); n; n = n->GetNext())
|
auto trophy_base = doc.GetRoot();
|
||||||
|
if (trophy_base->GetChildren()->GetName() == "trophyconf")
|
||||||
{
|
{
|
||||||
|
trophy_base = trophy_base->GetChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::shared_ptr<rXmlNode> n = trophy_base->GetChildren(); n; n = n->GetNext())
|
||||||
|
{
|
||||||
|
const std::string n_name = n->GetName();
|
||||||
|
|
||||||
if (details)
|
if (details)
|
||||||
{
|
{
|
||||||
if (n->GetName() == "title-name")
|
if (n_name == "title-name")
|
||||||
{
|
{
|
||||||
std::string titleName = n->GetNodeContent();
|
std::string titleName = n->GetNodeContent();
|
||||||
memcpy(details->title, titleName.c_str(), titleName.size());
|
memcpy(details->title, titleName.c_str(), titleName.size());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (n_name == "title-detail")
|
||||||
if (n->GetName() == "title-detail")
|
|
||||||
{
|
{
|
||||||
std::string titleDetail = n->GetNodeContent();
|
std::string titleDetail = n->GetNodeContent();
|
||||||
memcpy(details->description, titleDetail.c_str(), titleDetail.size());
|
memcpy(details->description, titleDetail.c_str(), titleDetail.size());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n->GetName() == "trophy")
|
if (n_name == "trophy")
|
||||||
{
|
{
|
||||||
u32 trophy_id = atoi(n->GetAttribute("id").c_str());
|
u32 trophy_id = atoi(n->GetAttribute("id").c_str());
|
||||||
|
|
||||||
if (details)
|
if (details)
|
||||||
{
|
{
|
||||||
details->numTrophies++;
|
details->numTrophies++;
|
||||||
switch (n->GetAttribute("ttype")[0]) {
|
switch (n->GetAttribute("ttype")[0])
|
||||||
|
{
|
||||||
case 'B': details->numBronze++; break;
|
case 'B': details->numBronze++; break;
|
||||||
case 'S': details->numSilver++; break;
|
case 'S': details->numSilver++; break;
|
||||||
case 'G': details->numGold++; break;
|
case 'G': details->numGold++; break;
|
||||||
|
@ -459,7 +469,8 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr<SceNpTrophyGa
|
||||||
if (ctxt->tropusr->GetTrophyUnlockState(trophy_id))
|
if (ctxt->tropusr->GetTrophyUnlockState(trophy_id))
|
||||||
{
|
{
|
||||||
data->unlockedTrophies++;
|
data->unlockedTrophies++;
|
||||||
switch (n->GetAttribute("ttype")[0]) {
|
switch (n->GetAttribute("ttype")[0])
|
||||||
|
{
|
||||||
case 'B': data->unlockedBronze++; break;
|
case 'B': data->unlockedBronze++; break;
|
||||||
case 'S': data->unlockedSilver++; break;
|
case 'S': data->unlockedSilver++; break;
|
||||||
case 'G': data->unlockedGold++; break;
|
case 'G': data->unlockedGold++; break;
|
||||||
|
@ -636,25 +647,30 @@ error_code sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::p
|
||||||
if (details)
|
if (details)
|
||||||
{
|
{
|
||||||
details->trophyId = trophyId;
|
details->trophyId = trophyId;
|
||||||
switch (n->GetAttribute("ttype")[0]) {
|
switch (n->GetAttribute("ttype")[0])
|
||||||
|
{
|
||||||
case 'B': details->trophyGrade = SCE_NP_TROPHY_GRADE_BRONZE; break;
|
case 'B': details->trophyGrade = SCE_NP_TROPHY_GRADE_BRONZE; break;
|
||||||
case 'S': details->trophyGrade = SCE_NP_TROPHY_GRADE_SILVER; break;
|
case 'S': details->trophyGrade = SCE_NP_TROPHY_GRADE_SILVER; break;
|
||||||
case 'G': details->trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; break;
|
case 'G': details->trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; break;
|
||||||
case 'P': details->trophyGrade = SCE_NP_TROPHY_GRADE_PLATINUM; break;
|
case 'P': details->trophyGrade = SCE_NP_TROPHY_GRADE_PLATINUM; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (n->GetAttribute("hidden")[0]) {
|
switch (n->GetAttribute("hidden")[0])
|
||||||
|
{
|
||||||
case 'y': details->hidden = true; break;
|
case 'y': details->hidden = true; break;
|
||||||
case 'n': details->hidden = false; break;
|
case 'n': details->hidden = false; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::shared_ptr<rXmlNode> n2 = n->GetChildren(); n2; n2 = n2->GetNext()) {
|
for (std::shared_ptr<rXmlNode> n2 = n->GetChildren(); n2; n2 = n2->GetNext())
|
||||||
if (n2->GetName() == "name")
|
{
|
||||||
|
const std::string n2_name = n2->GetName();
|
||||||
|
|
||||||
|
if (n2_name == "name")
|
||||||
{
|
{
|
||||||
std::string name = n2->GetNodeContent();
|
std::string name = n2->GetNodeContent();
|
||||||
memcpy(details->name, name.c_str(), std::min((size_t)SCE_NP_TROPHY_NAME_MAX_SIZE, name.length() + 1));
|
memcpy(details->name, name.c_str(), std::min((size_t)SCE_NP_TROPHY_NAME_MAX_SIZE, name.length() + 1));
|
||||||
}
|
}
|
||||||
if (n2->GetName() == "detail")
|
else if (n2_name == "detail")
|
||||||
{
|
{
|
||||||
std::string detail = n2->GetNodeContent();
|
std::string detail = n2->GetNodeContent();
|
||||||
memcpy(details->description, detail.c_str(), std::min((size_t)SCE_NP_TROPHY_DESCR_MAX_SIZE, detail.length() + 1));
|
memcpy(details->description, detail.c_str(), std::min((size_t)SCE_NP_TROPHY_DESCR_MAX_SIZE, detail.length() + 1));
|
||||||
|
|
Loading…
Reference in New Issue