From 2d68aed68f83b402cff459bb101549f70e7dd2a5 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 21 Mar 2018 23:04:05 +0100 Subject: [PATCH] improve sceNpTrophyGetTrophyInfo and sceNpTrophyGetGameInfo --- rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp | 40 ++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index af0ae9ad81..2ff2d1a1ca 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -422,31 +422,41 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptr 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 n = trophy_base->GetChildren(); n; n = n->GetNext()) + { + const std::string n_name = n->GetName(); + if (details) { - if (n->GetName() == "title-name") + if (n_name == "title-name") { std::string titleName = n->GetNodeContent(); memcpy(details->title, titleName.c_str(), titleName.size()); + continue; } - - if (n->GetName() == "title-detail") + else if (n_name == "title-detail") { std::string titleDetail = n->GetNodeContent(); 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()); if (details) { details->numTrophies++; - switch (n->GetAttribute("ttype")[0]) { + switch (n->GetAttribute("ttype")[0]) + { case 'B': details->numBronze++; break; case 'S': details->numSilver++; break; case 'G': details->numGold++; break; @@ -459,7 +469,8 @@ error_code sceNpTrophyGetGameInfo(u32 context, u32 handle, vm::ptrtropusr->GetTrophyUnlockState(trophy_id)) { data->unlockedTrophies++; - switch (n->GetAttribute("ttype")[0]) { + switch (n->GetAttribute("ttype")[0]) + { case 'B': data->unlockedBronze++; break; case 'S': data->unlockedSilver++; break; case 'G': data->unlockedGold++; break; @@ -636,25 +647,30 @@ error_code sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, vm::p if (details) { details->trophyId = trophyId; - switch (n->GetAttribute("ttype")[0]) { + switch (n->GetAttribute("ttype")[0]) + { case 'B': details->trophyGrade = SCE_NP_TROPHY_GRADE_BRONZE; break; case 'S': details->trophyGrade = SCE_NP_TROPHY_GRADE_SILVER; break; case 'G': details->trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; 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 'n': details->hidden = false; break; } - for (std::shared_ptr n2 = n->GetChildren(); n2; n2 = n2->GetNext()) { - if (n2->GetName() == "name") + for (std::shared_ptr n2 = n->GetChildren(); n2; n2 = n2->GetNext()) + { + const std::string n2_name = n2->GetName(); + + if (n2_name == "name") { std::string name = n2->GetNodeContent(); 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(); memcpy(details->description, detail.c_str(), std::min((size_t)SCE_NP_TROPHY_DESCR_MAX_SIZE, detail.length() + 1));