[Kernel] Remove item limit from enumerators, fixes #1255

Like said in that issue, it seems the limit passed to XamContentCreateEnumerator is actually a limit on how many results XamEnumerate should return per call, not a limit on the number of enumeration items in total.
These changes fix Sonic Unleashed not loading more than 1 DLC (it passes 1 as the limit, but then loops over XamEnumerate to load in each DLC one at a time), and likely many other games.
This commit is contained in:
emoose
2018-11-07 22:47:59 +00:00
parent 3103ad8e16
commit 7f479ffb79
3 changed files with 19 additions and 22 deletions

View File

@@ -158,7 +158,7 @@ SHIM_CALL XamContentResolve_shim(PPCContext* ppc_context,
dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
dword_t content_type,
dword_t content_flags,
dword_t max_count,
dword_t items_per_enumerate,
lpdword_t buffer_size_ptr,
lpdword_t handle_out) {
assert_not_null(handle_out);
@@ -173,11 +173,11 @@ dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
}
if (buffer_size_ptr) {
*buffer_size_ptr = (uint32_t)XCONTENT_DATA::kSize * max_count;
*buffer_size_ptr = (uint32_t)XCONTENT_DATA::kSize * items_per_enumerate;
}
auto e =
new XStaticEnumerator(kernel_state(), max_count, XCONTENT_DATA::kSize);
auto e = new XStaticEnumerator(kernel_state(), items_per_enumerate,
XCONTENT_DATA::kSize);
e->Initialize();
// Get all content data.
@@ -187,14 +187,13 @@ dword_result_t XamContentCreateEnumerator(dword_t user_index, dword_t device_id,
content_type);
for (auto& content_data : content_datas) {
auto ptr = e->AppendItem();
if (!ptr) {
// Too many items.
break;
}
assert_not_null(ptr);
content_data.Write(ptr);
}
XELOGD("XamContentCreateEnumerator: added %d items to enumerator",
e->item_count());
*handle_out = e->handle();
return X_ERROR_SUCCESS;
}