mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00: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:
parent
3efd5f360c
commit
e380a8c279
@ -18,6 +18,8 @@
|
|||||||
#include "Emu/Cell/lv2/sys_event.h"
|
#include "Emu/Cell/lv2/sys_event.h"
|
||||||
#include "Emu/Cell/lv2/sys_process.h"
|
#include "Emu/Cell/lv2/sys_process.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
LOG_CHANNEL(sceNpTrophy);
|
LOG_CHANNEL(sceNpTrophy);
|
||||||
|
|
||||||
TrophyNotificationBase::~TrophyNotificationBase()
|
TrophyNotificationBase::~TrophyNotificationBase()
|
||||||
@ -922,16 +924,12 @@ error_code sceNpTrophyGetGameProgress(u32 context, u32 handle, vm::ptr<s32> perc
|
|||||||
return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
|
return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
double accuratePercentage = 0;
|
const u32 unlocked = ctxt->tropusr->GetUnlockedTrophiesCount();
|
||||||
for (int i = ctxt->tropusr->GetTrophiesCount() - 1; i >= 0; i--)
|
const u32 trp_count = ctxt->tropusr->GetTrophiesCount();
|
||||||
{
|
|
||||||
if (ctxt->tropusr->GetTrophyUnlockState(i))
|
|
||||||
{
|
|
||||||
accuratePercentage++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*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;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user