From 37c220af729cbf3a49a4cf4543c896cdd5c3d929 Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 30 Nov 2019 23:16:29 +0200 Subject: [PATCH] Fix sceNpTrophyRegisterContext hack --- rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index b11563c2a2..01e52d0f8a 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -438,15 +438,19 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle, }); } - // If too much time passes just send the rest of the events anyway - if (const u32 val = *queued) - { - queued->wait(val, atomic_wait_timeout{300000}); - } + u64 current = get_system_time(); + const u64 until = current + 300'000; - if (ppu.is_stopped()) + // If too much time passes just send the rest of the events anyway + for (u32 old_value; current < until && (old_value = *queued); + current = get_system_time()) { - return 0; + queued->wait(old_value, atomic_wait_timeout{std::min((until - current) * 1000, 300'000'000)}); + + if (ppu.is_stopped()) + { + return 0; + } } }