diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index cf7f8aef57..3407778d64 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -716,9 +716,9 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle, lock2.unlock(); - struct register_context_thread : register_context_thread_name + lv2_obj::sleep(ppu); { - void operator()(s32 progress_cb_count, u32 context, vm::ptr statusCb, vm::ptr arg) const + const s32 progress_cb_count = ::narrow(tropusr->GetTrophiesCount()) - 1; { // This emulates vsh sending the events and ensures that not 2 events are processed at once const std::pair statuses[] = @@ -732,6 +732,13 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle, // Create a counter which is destroyed after the function ends const auto queued = std::make_shared>(0); + u32 total_events = 0; + + for (auto status : statuses) + { + total_events += status.second + 1; + } + for (auto status : statuses) { for (s32 completed = 0; completed <= status.second; completed++) @@ -754,8 +761,9 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle, u64 current = get_system_time(); - const u64 until_max = current + 300'000; - const u64 until_min = current + 100'000; + // Minimum register trophy time 2 seconds globally. + const u64 until_min = current + (2'000'000 / total_events); + const u64 until_max = until_min + 50'000; // If too much time passes just send the rest of the events anyway for (u32 old_value = *queued; current < (old_value ? until_max : until_min); @@ -772,19 +780,13 @@ error_code sceNpTrophyRegisterContext(ppu_thread& ppu, u32 context, u32 handle, if (thread_ctrl::state() == thread_state::aborting) { - return; + return {}; } } } } } - }; - - lv2_obj::sleep(ppu); - - g_fxo->get>()(::narrow(tropusr->GetTrophiesCount()) - 1, context, statusCb, arg); - - thread_ctrl::wait_for(200'000); + } return CELL_OK; }