diff --git a/src/xenia/kernel/xam/achievement_backends/gpd_achievement_backend.cc b/src/xenia/kernel/xam/achievement_backends/gpd_achievement_backend.cc index e7903ce1e..333ca574f 100644 --- a/src/xenia/kernel/xam/achievement_backends/gpd_achievement_backend.cc +++ b/src/xenia/kernel/xam/achievement_backends/gpd_achievement_backend.cc @@ -43,8 +43,7 @@ void GpdAchievementBackend::EarnAchievement(const uint64_t xuid, achievement->flags = achievement->flags | static_cast(AchievementFlags::kAchieved) | static_cast(AchievementFlags::kAchievedOnline); - achievement->unlock_time.high_part = static_cast(unlock_time >> 32); - achievement->unlock_time.low_part = static_cast(unlock_time); + achievement->unlock_time = unlock_time; SaveAchievementData(xuid, title_id, achievement_id); } diff --git a/src/xenia/kernel/xam/achievement_manager.h b/src/xenia/kernel/xam/achievement_manager.h index 5790870a0..0efd18814 100644 --- a/src/xenia/kernel/xam/achievement_manager.h +++ b/src/xenia/kernel/xam/achievement_manager.h @@ -15,6 +15,7 @@ #include #include +#include "xenia/base/chrono.h" #include "xenia/kernel/util/xdbf_utils.h" #include "xenia/xbox.h" @@ -53,6 +54,23 @@ enum class AchievementFlags : uint32_t { struct X_ACHIEVEMENT_UNLOCK_TIME { xe::be high_part; xe::be low_part; + + X_ACHIEVEMENT_UNLOCK_TIME() { + high_part = 0; + low_part = 0; + } + + X_ACHIEVEMENT_UNLOCK_TIME(uint64_t filetime) { + high_part = static_cast(filetime >> 32); + low_part = static_cast(filetime); + } + + chrono::WinSystemClock::time_point to_time_point() const { + const uint64_t filetime = + (static_cast(high_part) << 32) | low_part; + + return chrono::WinSystemClock::from_file_time(filetime); + } }; struct X_ACHIEVEMENT_DETAILS { diff --git a/src/xenia/kernel/xam/xam_ui.cc b/src/xenia/kernel/xam/xam_ui.cc index 04061dfad..02e112176 100644 --- a/src/xenia/kernel/xam/xam_ui.cc +++ b/src/xenia/kernel/xam/xam_ui.cc @@ -461,12 +461,8 @@ class GameAchievementsDialog final : public XamDialog { info.unlock_time = {}; if (entry.IsUnlocked()) { - const uint64_t filetime_time = - (static_cast(entry.unlock_time.high_part) << 32) | - entry.unlock_time.low_part; - - info.unlock_time = chrono::WinSystemClock::to_sys( - chrono::WinSystemClock::from_file_time(filetime_time)); + info.unlock_time = + chrono::WinSystemClock::to_sys(entry.unlock_time.to_time_point()); } achievements_info_.insert({info.id, info});