[Kernel] Add UserProfile::GetTitles, add title_id param to UpdateTitleGpd

Also changed GetTItleGpd to check for -1 to use current GPD (some games might be using 00... as title id, eg. protos)
This commit is contained in:
emoose 2018-11-18 00:10:44 +00:00
parent 00cffcacbb
commit fa2cd63b1f
No known key found for this signature in database
GPG Key ID: 3735C67912F5FF97
2 changed files with 20 additions and 9 deletions

View File

@ -294,7 +294,7 @@ util::GpdFile* UserProfile::SetTitleSpaData(const util::SpaFile& spa_data) {
}
util::GpdFile* UserProfile::GetTitleGpd(uint32_t title_id) {
if (!title_id) {
if (title_id == -1) {
return curr_gpd_;
}
@ -306,16 +306,25 @@ util::GpdFile* UserProfile::GetTitleGpd(uint32_t title_id) {
return &(*gpd).second;
}
bool UserProfile::UpdateTitleGpd() {
void UserProfile::GetTitles(std::vector<util::GpdFile*>& titles) {
for (auto title : title_gpds_) {
titles.push_back(&title.second);
}
}
bool UserProfile::UpdateTitleGpd(uint32_t title_id) {
if (title_id == -1) {
if (!curr_gpd_ || curr_title_id_ == -1) {
return false;
}
title_id = curr_title_id_;
}
bool result = UpdateGpd(curr_title_id_, *curr_gpd_);
bool result = UpdateGpd(title_id, *curr_gpd_);
if (!result) {
XELOGE("UpdateTitleGpd failed on title %X!", curr_title_id_);
XELOGE("UpdateTitleGpd failed on title %X!", title_id);
} else {
XELOGD("Updated title %X GPD successfully!", curr_title_id_);
XELOGD("Updated title %X GPD successfully!", title_id);
}
return result;
}

View File

@ -208,9 +208,11 @@ class UserProfile {
Setting* GetSetting(uint32_t setting_id);
util::GpdFile* SetTitleSpaData(const util::SpaFile& spa_data);
util::GpdFile* GetTitleGpd(uint32_t title_id = 0);
util::GpdFile* GetTitleGpd(uint32_t title_id = -1);
bool UpdateTitleGpd();
void GetTitles(std::vector<util::GpdFile*>& titles);
bool UpdateTitleGpd(uint32_t title_id = -1);
bool UpdateAllGpds();
private: