[User] Added method for calculating gamerscore

This commit is contained in:
Gliniak 2019-12-21 21:24:11 +01:00 committed by illusion
parent be83bfd145
commit a0fc9e386a
2 changed files with 18 additions and 5 deletions

View File

@ -118,7 +118,8 @@ UserProfile::UserProfile() : dash_gpd_(kDashboardID) {
// XPROFILE_GAMERCARD_REGION // XPROFILE_GAMERCARD_REGION
AddSetting(std::make_unique<Int32Setting>(0x10040005, 0)); AddSetting(std::make_unique<Int32Setting>(0x10040005, 0));
// XPROFILE_GAMERCARD_CRED // XPROFILE_GAMERCARD_CRED
AddSetting(std::make_unique<Int32Setting>(0x10040006, 0xFA)); AddSetting(
std::make_unique<Int32Setting>(0x10040006, CalculateUserGamerscore()));
// XPROFILE_GAMERCARD_REP // XPROFILE_GAMERCARD_REP
AddSetting(std::make_unique<FloatSetting>(0x5004000B, 0.0f)); AddSetting(std::make_unique<FloatSetting>(0x5004000B, 0.0f));
// XPROFILE_OPTION_VOICE_MUTED // XPROFILE_OPTION_VOICE_MUTED
@ -202,7 +203,8 @@ void UserProfile::LoadProfile() {
mmap_->Close(); 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( mmap_ = MappedMemory::Open(
xe::to_wstring(cvars::profile_directory) + L"FFFE07D1.gpd", xe::to_wstring(cvars::profile_directory) + L"FFFE07D1.gpd",
@ -598,9 +600,7 @@ void UserProfile::SaveSetting(UserProfile::Setting* setting) {
} }
} }
xdbf::GpdFile* UserProfile::GetDashboardGpd() { xdbf::GpdFile* UserProfile::GetDashboardGpd() { return &dash_gpd_; }
return &dash_gpd_;
}
xdbf::SpaFile* UserProfile::GetTitleSpa(uint32_t title_id) { xdbf::SpaFile* UserProfile::GetTitleSpa(uint32_t title_id) {
std::wstring file_location = xe::to_wstring(cvars::profile_directory) + 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); return (game_entry);
} }
uint32_t UserProfile::CalculateUserGamerscore() const {
uint32_t score = 0;
std::vector<xdbf::TitlePlayed> titles;
dash_gpd_.GetTitles(&titles);
for (auto title : titles)
score += title.gamerscore_earned;
return score;
}
} // namespace xam } // namespace xam
} // namespace kernel } // namespace kernel
} // namespace xe } // namespace xe

View File

@ -317,6 +317,7 @@ class UserProfile {
uint64_t xuid() const { return account_.xuid_online; } uint64_t xuid() const { return account_.xuid_online; }
std::string name() const { return account_.GetGamertagString(); } std::string name() const { return account_.GetGamertagString(); }
// uint32_t signin_state() const { return 1; } // uint32_t signin_state() const { return 1; }
uint32_t CalculateUserGamerscore() const;
void AddSetting(std::unique_ptr<Setting> setting); void AddSetting(std::unique_ptr<Setting> setting);
Setting* GetSetting(uint32_t setting_id); Setting* GetSetting(uint32_t setting_id);