From 8926bdcdd695bcf7f8f95938f0e44c59fbf9be14 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sat, 15 Mar 2025 23:59:34 +0100 Subject: [PATCH] [XAM] Fixed issue with achievements saving in Forza series. Remove this ducktape asap and remove hardcodes --- src/xenia/kernel/xam/profile_manager.cc | 7 ++++--- src/xenia/kernel/xam/profile_manager.h | 2 ++ src/xenia/kernel/xam/user_profile.cc | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/xenia/kernel/xam/profile_manager.cc b/src/xenia/kernel/xam/profile_manager.cc index bdd73ffd3..336b0b0a1 100644 --- a/src/xenia/kernel/xam/profile_manager.cc +++ b/src/xenia/kernel/xam/profile_manager.cc @@ -183,7 +183,8 @@ bool ProfileManager::LoadAccount(const uint64_t xuid) { MountProfile(xuid); - const std::string guest_path = xuid_as_string + ":\\Account"; + const std::string guest_path = + fmt::format(kDefaultMountFormat, xuid) + ":\\Account"; xe::vfs::File* output_file; xe::vfs::FileAction action = {}; @@ -257,7 +258,7 @@ void ProfileManager::ModifyGamertag(const uint64_t xuid, std::string gamertag) { bool ProfileManager::MountProfile(const uint64_t xuid, std::string mount_path) { std::filesystem::path profile_path = GetProfilePath(xuid); if (mount_path.empty()) { - mount_path = fmt::format("{:016X}", xuid); + mount_path = fmt::format(kDefaultMountFormat, xuid); } mount_path += ':'; @@ -275,7 +276,7 @@ bool ProfileManager::MountProfile(const uint64_t xuid, std::string mount_path) { bool ProfileManager::DismountProfile(const uint64_t xuid) { return kernel_state_->file_system()->UnregisterDevice( - fmt::format("{:016X}", xuid) + ':'); + fmt::format(kDefaultMountFormat, xuid) + ':'); } void ProfileManager::Login(const uint64_t xuid, const uint8_t user_index, diff --git a/src/xenia/kernel/xam/profile_manager.h b/src/xenia/kernel/xam/profile_manager.h index ed5bf3a58..f40f7662b 100644 --- a/src/xenia/kernel/xam/profile_manager.h +++ b/src/xenia/kernel/xam/profile_manager.h @@ -42,6 +42,8 @@ constexpr uint32_t kDashboardID = 0xFFFE07D1; const static std::string kDashboardStringID = fmt::format("{:08X}", kDashboardID); +constexpr std::string kDefaultMountFormat = "User_{:016X}"; + class ProfileManager { public: static bool DecryptAccountFile(const uint8_t* data, X_XAMACCOUNTINFO* output, diff --git a/src/xenia/kernel/xam/user_profile.cc b/src/xenia/kernel/xam/user_profile.cc index 4db7dfb41..1dc8dcd55 100644 --- a/src/xenia/kernel/xam/user_profile.cc +++ b/src/xenia/kernel/xam/user_profile.cc @@ -74,7 +74,7 @@ void UserProfile::LoadProfileIcon(XTileType tile_type) { } const std::string path = - fmt::format("{:016X}:\\{}", xuid_, kTileFileNames.at(tile_type)); + fmt::format("User_{:016X}:\\{}", xuid_, kTileFileNames.at(tile_type)); vfs::File* file = nullptr; vfs::FileAction action; @@ -97,7 +97,7 @@ void UserProfile::LoadProfileIcon(XTileType tile_type) { std::vector UserProfile::LoadGpd(const uint32_t title_id) { auto entry = kernel_state()->file_system()->ResolvePath( - fmt::format("{:016X}:\\{:08X}.gpd", xuid_, title_id)); + fmt::format("User_{:016X}:\\{:08X}.gpd", xuid_, title_id)); if (!entry) { XELOGW("User {} (XUID: {:016X}) doesn't have profile GPD!", name(), xuid()); @@ -139,7 +139,7 @@ bool UserProfile::WriteGpd(const uint32_t title_id) { vfs::FileAction action; const std::string mounted_path = - fmt::format("{:016X}:\\{:08X}.gpd", xuid_, title_id); + fmt::format("User_{:016X}:\\{:08X}.gpd", xuid_, title_id); const X_STATUS result = kernel_state()->file_system()->OpenFile( nullptr, mounted_path, vfs::FileDisposition::kOverwriteIf,