From 3a93aeba931fbdb173209e62828d87c43d3a35e8 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sat, 21 Dec 2019 21:24:11 +0100 Subject: [PATCH] [User] Added method for calculating gamerscore --- src/xenia/kernel/xam/user_profile.cc | 22 +++++++++++++++++----- src/xenia/kernel/xam/user_profile.h | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/xenia/kernel/xam/user_profile.cc b/src/xenia/kernel/xam/user_profile.cc index fbf9de9a3..624e27ae9 100644 --- a/src/xenia/kernel/xam/user_profile.cc +++ b/src/xenia/kernel/xam/user_profile.cc @@ -118,7 +118,8 @@ UserProfile::UserProfile() : dash_gpd_(kDashboardID) { // XPROFILE_GAMERCARD_REGION AddSetting(std::make_unique(0x10040005, 0)); // XPROFILE_GAMERCARD_CRED - AddSetting(std::make_unique(0x10040006, 0xFA)); + AddSetting( + std::make_unique(0x10040006, CalculateUserGamerscore())); // XPROFILE_GAMERCARD_REP AddSetting(std::make_unique(0x5004000B, 0.0f)); // XPROFILE_OPTION_VOICE_MUTED @@ -202,7 +203,8 @@ void UserProfile::LoadProfile() { mmap_->Close(); } - XELOGI("Loading profile GPDs from path %S", xe::to_wstring(cvars::profile_directory).c_str()); + XELOGI("Loading profile GPDs from path %S", + xe::to_wstring(cvars::profile_directory).c_str()); mmap_ = MappedMemory::Open( xe::to_wstring(cvars::profile_directory) + L"FFFE07D1.gpd", @@ -598,9 +600,7 @@ void UserProfile::SaveSetting(UserProfile::Setting* setting) { } } -xdbf::GpdFile* UserProfile::GetDashboardGpd() { - return &dash_gpd_; -} +xdbf::GpdFile* UserProfile::GetDashboardGpd() { return &dash_gpd_; } xdbf::SpaFile* UserProfile::GetTitleSpa(uint32_t title_id) { std::wstring file_location = xe::to_wstring(cvars::profile_directory) + @@ -619,6 +619,18 @@ xdbf::SpaFile* UserProfile::GetTitleSpa(uint32_t title_id) { return (game_entry); } +uint32_t UserProfile::CalculateUserGamerscore() const { + uint32_t score = 0; + + std::vector titles; + dash_gpd_.GetTitles(&titles); + + for (auto title : titles) + score += title.gamerscore_earned; + + return score; +} + } // namespace xam } // namespace kernel } // namespace xe diff --git a/src/xenia/kernel/xam/user_profile.h b/src/xenia/kernel/xam/user_profile.h index d0071bcb1..43c7d469b 100644 --- a/src/xenia/kernel/xam/user_profile.h +++ b/src/xenia/kernel/xam/user_profile.h @@ -317,6 +317,7 @@ class UserProfile { uint64_t xuid() const { return account_.xuid_online; } std::string name() const { return account_.GetGamertagString(); } // uint32_t signin_state() const { return 1; } + uint32_t CalculateUserGamerscore() const; void AddSetting(std::unique_ptr setting); Setting* GetSetting(uint32_t setting_id);