diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index 0db29e53fc..111c2e78c9 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -18,6 +18,8 @@ #include "Emu/Cell/lv2/sys_event.h" #include "Emu/Cell/lv2/sys_process.h" +#include + LOG_CHANNEL(sceNpTrophy); TrophyNotificationBase::~TrophyNotificationBase() @@ -922,16 +924,12 @@ error_code sceNpTrophyGetGameProgress(u32 context, u32 handle, vm::ptr perc return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE; } - double accuratePercentage = 0; - for (int i = ctxt->tropusr->GetTrophiesCount() - 1; i >= 0; i--) - { - if (ctxt->tropusr->GetTrophyUnlockState(i)) - { - accuratePercentage++; - } - } + const u32 unlocked = ctxt->tropusr->GetUnlockedTrophiesCount(); + const u32 trp_count = ctxt->tropusr->GetTrophiesCount(); - *percentage = static_cast(accuratePercentage / ctxt->tropusr->GetTrophiesCount()); + verify(HERE), trp_count > 0 && trp_count <= 128; + + *percentage = static_cast(std::lround((unlocked * 100.) / trp_count)); return CELL_OK; }