1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 20:22:30 +01:00

Fix sceNpTrophyGetGameProgress (#7103)

* Fix sceNpTrophyGetGameProgress

Was missing multiplication by 100.

* apply requested changes

* Enforce round-to-nearest rounding mode
This commit is contained in:
Eladash 2019-12-18 00:43:00 +02:00 committed by Ani
parent 3efd5f360c
commit e380a8c279

View File

@ -18,6 +18,8 @@
#include "Emu/Cell/lv2/sys_event.h"
#include "Emu/Cell/lv2/sys_process.h"
#include <cmath>
LOG_CHANNEL(sceNpTrophy);
TrophyNotificationBase::~TrophyNotificationBase()
@ -922,16 +924,12 @@ error_code sceNpTrophyGetGameProgress(u32 context, u32 handle, vm::ptr<s32> 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<s32>(accuratePercentage / ctxt->tropusr->GetTrophiesCount());
verify(HERE), trp_count > 0 && trp_count <= 128;
*percentage = static_cast<s32>(std::lround((unlocked * 100.) / trp_count));
return CELL_OK;
}