From 716d4c412a77240902985d1038cc2dc724095266 Mon Sep 17 00:00:00 2001 From: emoose Date: Tue, 15 Jun 2021 22:29:29 +0100 Subject: [PATCH] [Kernel] Let XamContentAggregate.. make use of XEX alt-title-ids header --- src/xenia/kernel/xam/xam_content_aggregate.cc | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/xenia/kernel/xam/xam_content_aggregate.cc b/src/xenia/kernel/xam/xam_content_aggregate.cc index 043018b6c..3de7b1566 100644 --- a/src/xenia/kernel/xam/xam_content_aggregate.cc +++ b/src/xenia/kernel/xam/xam_content_aggregate.cc @@ -11,6 +11,7 @@ #include "xenia/base/math.h" #include "xenia/base/string_util.h" #include "xenia/kernel/kernel_state.h" +#include "xenia/kernel/user_module.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam/xam_content_device.h" #include "xenia/kernel/xam/xam_private.h" @@ -99,13 +100,26 @@ dword_result_t XamContentAggregateCreateEnumerator(qword_t xuid, auto content_type_enum = XContentType(uint32_t(content_type)); if (!device_info || device_info->device_type == DeviceType::HDD) { - // Get all content data. - auto content_datas = kernel_state()->content_manager()->ListContent( - static_cast(DummyDeviceId::HDD), content_type_enum); - for (const auto& content_data : content_datas) { - auto item = reinterpret_cast(e->AppendItem()); - assert_not_null(item); - *item = content_data; + // Fetch any alternate title IDs defined in the XEX header + // (used by games to load saves from other titles, etc) + std::vector title_ids{kCurrentlyRunningTitleId}; + auto exe_module = kernel_state()->GetExecutableModule(); + if (exe_module && exe_module->xex_module()) { + const auto& alt_ids = exe_module->xex_module()->opt_alternate_title_ids(); + std::copy(alt_ids.cbegin(), alt_ids.cend(), + std::back_inserter(title_ids)); + } + + for (auto& title_id : title_ids) { + // Get all content data. + auto content_datas = kernel_state()->content_manager()->ListContent( + static_cast(DummyDeviceId::HDD), content_type_enum, + title_id); + for (const auto& content_data : content_datas) { + auto item = reinterpret_cast(e->AppendItem()); + assert_not_null(item); + *item = content_data; + } } }