From cfd965342a4a041bd1c944e68298ee2a210fa8ef Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sun, 15 Dec 2024 14:16:17 +0100 Subject: [PATCH] [XAM] Fixed issue with lack of loaded achievements while switching profile in-game --- .../xam/achievement_backends/gpd_achievement_backend.cc | 4 ++++ src/xenia/kernel/xam/profile_manager.cc | 9 +++++++++ 2 files changed, 13 insertions(+) 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 8cbc1a37e..e7903ce1e 100644 --- a/src/xenia/kernel/xam/achievement_backends/gpd_achievement_backend.cc +++ b/src/xenia/kernel/xam/achievement_backends/gpd_achievement_backend.cc @@ -72,6 +72,10 @@ bool GpdAchievementBackend::IsAchievementUnlocked( const auto achievement = GetAchievementInfoInternal(xuid, title_id, achievement_id); + if (!achievement) { + return false; + } + return (achievement->flags & static_cast(AchievementFlags::kAchieved)) != 0; } diff --git a/src/xenia/kernel/xam/profile_manager.cc b/src/xenia/kernel/xam/profile_manager.cc index b0cb38ea1..acd76f547 100644 --- a/src/xenia/kernel/xam/profile_manager.cc +++ b/src/xenia/kernel/xam/profile_manager.cc @@ -314,6 +314,15 @@ void ProfileManager::Login(const uint64_t xuid, const uint8_t user_index, logged_profiles_[assigned_user_slot] = std::make_unique(xuid, &profile); + + if (kernel_state_->emulator()->is_title_open()) { + const kernel::util::XdbfGameData db = kernel_state_->title_xdbf(); + if (db.is_valid()) { + kernel_state_->xam_state()->achievement_manager()->LoadTitleAchievements( + xuid, db); + } + } + if (notify) { kernel_state_->BroadcastNotification(kXNotificationIDSystemSignInChanged, GetUsedUserSlots().to_ulong());