From a18c594b6c47b0476b8063bc432d4a8961fb8ca7 Mon Sep 17 00:00:00 2001 From: DanielSvoboda Date: Wed, 26 Feb 2025 02:15:48 -0300 Subject: [PATCH] fixes crash due to having too many trophies The game 'My Name is Mayo' has so many trophies in sequence that when overlapping them, the emulator ended up crashing, so if there is something on the screen and a new trophies are achieved, it will clear and show the new one. --- src/core/libraries/np_trophy/trophy_ui.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/core/libraries/np_trophy/trophy_ui.cpp b/src/core/libraries/np_trophy/trophy_ui.cpp index ca14acdb0..e8e98715d 100644 --- a/src/core/libraries/np_trophy/trophy_ui.cpp +++ b/src/core/libraries/np_trophy/trophy_ui.cpp @@ -183,13 +183,20 @@ void AddTrophyToQueue(const std::filesystem::path& trophyIconPath, const std::st if (Config::getisTrophyPopupDisabled()) { return; } else if (current_trophy_ui.has_value()) { - TrophyInfo new_trophy; - new_trophy.trophy_icon_path = trophyIconPath; - new_trophy.trophy_name = trophyName; - new_trophy.trophy_type = rarity; - trophy_queue.push(new_trophy); - } else { - current_trophy_ui.emplace(trophyIconPath, trophyName, rarity); + current_trophy_ui.reset(); + } + + TrophyInfo new_trophy; + new_trophy.trophy_icon_path = trophyIconPath; + new_trophy.trophy_name = trophyName; + new_trophy.trophy_type = rarity; + trophy_queue.push(new_trophy); + + if (!current_trophy_ui.has_value()) { + TrophyInfo next_trophy = trophy_queue.front(); + trophy_queue.pop(); + current_trophy_ui.emplace(next_trophy.trophy_icon_path, next_trophy.trophy_name, + next_trophy.trophy_type); } }