From bd4e9f1803d74c35f5d0622ca8c480d091d246a0 Mon Sep 17 00:00:00 2001 From: offtkp Date: Wed, 2 Oct 2024 03:24:30 +0300 Subject: [PATCH] Some nits and fixes --- src/core/libraries/np_trophy/np_trophy.cpp | 2 +- src/core/libraries/np_trophy/trophy_ui.cpp | 13 ++++++------- src/core/libraries/np_trophy/trophy_ui.h | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/core/libraries/np_trophy/np_trophy.cpp b/src/core/libraries/np_trophy/np_trophy.cpp index 0641a2c06..d759b7a2f 100644 --- a/src/core/libraries/np_trophy/np_trophy.cpp +++ b/src/core/libraries/np_trophy/np_trophy.cpp @@ -966,7 +966,7 @@ int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTr } } - doc.save_file((trophy_dir.string() + "/trophy00/Xml/TROP.XML").c_str()); + doc.save_file((trophy_dir / "trophy00" / "Xml" / "TROP.XML").native().c_str()); return ORBIS_OK; } diff --git a/src/core/libraries/np_trophy/trophy_ui.cpp b/src/core/libraries/np_trophy/trophy_ui.cpp index 740bd3a10..618f8db46 100644 --- a/src/core/libraries/np_trophy/trophy_ui.cpp +++ b/src/core/libraries/np_trophy/trophy_ui.cpp @@ -16,12 +16,13 @@ std::optional current_trophy_ui; std::queue trophy_queue; std::mutex queueMtx; -TrophyUI::TrophyUI(std::filesystem::path trophyIconPath, std::string trophyName) +TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::string& trophyName) : trophy_name(trophyName) { if (std::filesystem::exists(trophyIconPath)) { trophy_icon = RefCountedTexture::DecodePngFile(trophyIconPath); } else { - LOG_ERROR(Lib_NpTrophy, "Couldnt load trophy icon at {}", trophyIconPath.string()); + LOG_ERROR(Lib_NpTrophy, "Couldnt load trophy icon at {}", + fmt::UTF(trophyIconPath.u8string())); } AddLayer(this); } @@ -66,7 +67,7 @@ void TrophyUI::Draw() { trophy_timer -= io.DeltaTime; if (trophy_timer <= 0) { - queueMtx.lock(); + std::lock_guard lock(queueMtx); if (!trophy_queue.empty()) { TrophyInfo next_trophy = trophy_queue.front(); trophy_queue.pop(); @@ -74,12 +75,11 @@ void TrophyUI::Draw() { } else { current_trophy_ui.reset(); } - queueMtx.unlock(); } } -void AddTrophyToQueue(std::filesystem::path trophyIconPath, std::string trophyName) { - queueMtx.lock(); +void AddTrophyToQueue(const std::filesystem::path& trophyIconPath, const std::string& trophyName) { + std::lock_guard lock(queueMtx); if (current_trophy_ui.has_value()) { TrophyInfo new_trophy; new_trophy.trophy_icon_path = trophyIconPath; @@ -88,7 +88,6 @@ void AddTrophyToQueue(std::filesystem::path trophyIconPath, std::string trophyNa } else { current_trophy_ui.emplace(trophyIconPath, trophyName); } - queueMtx.unlock(); } } // namespace Libraries::NpTrophy \ No newline at end of file diff --git a/src/core/libraries/np_trophy/trophy_ui.h b/src/core/libraries/np_trophy/trophy_ui.h index 4448c2281..ce7a1c63a 100644 --- a/src/core/libraries/np_trophy/trophy_ui.h +++ b/src/core/libraries/np_trophy/trophy_ui.h @@ -17,7 +17,7 @@ namespace Libraries::NpTrophy { class TrophyUI final : public ImGui::Layer { public: - TrophyUI(std::filesystem::path trophyIconPath, std::string trophyName); + TrophyUI(const std::filesystem::path& trophyIconPath, const std::string& trophyName); ~TrophyUI() override; void Finish(); @@ -35,6 +35,6 @@ struct TrophyInfo { std::string trophy_name; }; -void AddTrophyToQueue(std::filesystem::path trophyIconPath, std::string trophyName); +void AddTrophyToQueue(const std::filesystem::path& trophyIconPath, const std::string& trophyName); }; // namespace Libraries::NpTrophy \ No newline at end of file