[XAM] Cleanup XamUserCreateTitlesPlayedEnumerator
This commit is contained in:
@@ -165,10 +165,6 @@ void UserTracker::AddTitleToPlayedList(uint64_t xuid) {
|
||||
UpdateTitleGpdFile();
|
||||
}
|
||||
|
||||
if (!spa_data_->include_in_profile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uint64_t current_time = Clock::QueryGuestSystemTime();
|
||||
|
||||
auto title_info = user->dashboard_gpd_.GetTitleInfo(title_id);
|
||||
|
||||
@@ -641,43 +641,39 @@ DECLARE_XAM_EXPORT1(XamUserCreateAchievementEnumerator, kUserProfiles,
|
||||
dword_result_t XamUserCreateTitlesPlayedEnumerator_entry(
|
||||
dword_t title_id, dword_t user_index, qword_t xuid, dword_t starting_index,
|
||||
dword_t game_count, lpdword_t buffer_size_ptr, lpdword_t handle_ptr) {
|
||||
if (user_index >= XUserMaxUserCount && game_count != 0 && !buffer_size_ptr &&
|
||||
if (user_index >= XUserMaxUserCount || !game_count || !buffer_size_ptr ||
|
||||
!handle_ptr) {
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
const uint32_t kEntrySize = sizeof(XTitleEnumerator::XTITLE_PLAYED);
|
||||
if (buffer_size_ptr) {
|
||||
*buffer_size_ptr = kEntrySize * game_count;
|
||||
}
|
||||
|
||||
const auto user = kernel_state()->xam_state()->GetUserProfile(user_index);
|
||||
if (!user) {
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
uint64_t requester_xuid = user->xuid();
|
||||
if (xuid) {
|
||||
requester_xuid = xuid;
|
||||
}
|
||||
|
||||
*buffer_size_ptr = game_count * sizeof(XTitleEnumerator::XTITLE_PLAYED);
|
||||
|
||||
auto e = object_ref<XTitleEnumerator>(
|
||||
new XTitleEnumerator(kernel_state(), game_count));
|
||||
new XTitleEnumerator(kernel_state(), game_count, starting_index));
|
||||
|
||||
auto result =
|
||||
e->Initialize(user_index, 0xFB, 0xB0050, 0xB000B, 0x20, game_count, 0);
|
||||
e->Initialize(user_index, 0xFB, 0xB0050, 0xB000B, 0, 0x28, nullptr);
|
||||
|
||||
if (XFAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const auto user_titles =
|
||||
kernel_state()->xam_state()->user_tracker()->GetPlayedTitles(
|
||||
user->xuid());
|
||||
requester_xuid);
|
||||
|
||||
if (!user_titles.empty()) {
|
||||
for (const auto& title : user_titles) {
|
||||
if (title.id == kDashboardID) {
|
||||
continue;
|
||||
}
|
||||
if (!title.achievements_count || !title.gamerscore_amount) {
|
||||
continue;
|
||||
}
|
||||
e->AppendItem(title);
|
||||
}
|
||||
for (const auto& title : user_titles) {
|
||||
e->AppendItem(title);
|
||||
}
|
||||
|
||||
*handle_ptr = e->handle();
|
||||
|
||||
@@ -170,8 +170,9 @@ uint32_t XTitleEnumerator::WriteItems(uint8_t* buffer_data,
|
||||
|
||||
// On console if title is played offline this field is set to 0.
|
||||
details[i].base.last_played = X_FILETIME((uint64_t)0);
|
||||
string_util::copy_and_swap_truncating((char16_t*)&details[i].title_name,
|
||||
item.title_name, 128);
|
||||
string_util::copy_and_swap_truncating(
|
||||
reinterpret_cast<char16_t*>(details[i].title_name), item.title_name,
|
||||
xe::countof(details[i].title_name));
|
||||
}
|
||||
|
||||
if (written_count) {
|
||||
|
||||
@@ -189,8 +189,10 @@ class XTitleEnumerator : public XEnumerator {
|
||||
xe::be<char16_t> title_name[64];
|
||||
};
|
||||
|
||||
XTitleEnumerator(KernelState* kernel_state, size_t items_per_enumerate)
|
||||
: XEnumerator(kernel_state, items_per_enumerate, sizeof(XTITLE_PLAYED)) {}
|
||||
XTitleEnumerator(KernelState* kernel_state, size_t items_per_enumerate,
|
||||
size_t enumeration_offset)
|
||||
: XEnumerator(kernel_state, items_per_enumerate, sizeof(XTITLE_PLAYED)),
|
||||
current_item_(enumeration_offset) {}
|
||||
|
||||
void AppendItem(const xam::TitleInfo& item) { items_.push_back(item); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user