diff options
| author | 2018-09-30 21:07:17 -0400 | |
|---|---|---|
| committer | 2018-09-30 21:07:22 -0400 | |
| commit | f72046099ac1bce64017e6940daba6ee2ce8e9fb (patch) | |
| tree | 751bd8c345e7036d632e616eaa4b49ed4877f525 /src | |
| parent | aoc_u: Implement GetAddOnContentBaseId (diff) | |
| download | yuzu-f72046099ac1bce64017e6940daba6ee2ce8e9fb.tar.gz yuzu-f72046099ac1bce64017e6940daba6ee2ce8e9fb.tar.xz yuzu-f72046099ac1bce64017e6940daba6ee2ce8e9fb.zip | |
aoc_u: Extract AccumulateAOCTitleIDs to separate function
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/aoc/aoc_u.cpp | 46 |
2 files changed, 28 insertions, 21 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index ceb462ec4..57b7741f8 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <array> | 6 | #include <array> |
| 6 | #include <cstddef> | 7 | #include <cstddef> |
| 7 | 8 | ||
| @@ -185,7 +186,7 @@ std::map<PatchType, std::string> PatchManager::GetPatchVersionNames() const { | |||
| 185 | 186 | ||
| 186 | list += fmt::format("{}", dlc_match.back().title_id & 0x7FF); | 187 | list += fmt::format("{}", dlc_match.back().title_id & 0x7FF); |
| 187 | 188 | ||
| 188 | out[PatchType::DLC] = list; | 189 | out.insert_or_assign(PatchType::DLC, std::move(list)); |
| 189 | } | 190 | } |
| 190 | 191 | ||
| 191 | return out; | 192 | return out; |
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 745ee89bc..cfc28fa0c 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp | |||
| @@ -2,7 +2,9 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <numeric> | 6 | #include <numeric> |
| 7 | #include <vector> | ||
| 6 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 7 | #include "core/file_sys/content_archive.h" | 9 | #include "core/file_sys/content_archive.h" |
| 8 | #include "core/file_sys/nca_metadata.h" | 10 | #include "core/file_sys/nca_metadata.h" |
| @@ -19,25 +21,12 @@ namespace Service::AOC { | |||
| 19 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; | 21 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; |
| 20 | constexpr u64 DLC_BASE_TO_AOC_ID_MASK = 0x1000; | 22 | constexpr u64 DLC_BASE_TO_AOC_ID_MASK = 0x1000; |
| 21 | 23 | ||
| 22 | bool CheckAOCTitleIDMatchesBase(u64 base, u64 aoc) { | 24 | static bool CheckAOCTitleIDMatchesBase(u64 base, u64 aoc) { |
| 23 | return (aoc & DLC_BASE_TITLE_ID_MASK) == base; | 25 | return (aoc & DLC_BASE_TITLE_ID_MASK) == base; |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | AOC_U::AOC_U() : ServiceFramework("aoc:u") { | 28 | static std::vector<u64> AccumulateAOCTitleIDs() { |
| 27 | static const FunctionInfo functions[] = { | 29 | std::vector<u64> add_on_content; |
| 28 | {0, nullptr, "CountAddOnContentByApplicationId"}, | ||
| 29 | {1, nullptr, "ListAddOnContentByApplicationId"}, | ||
| 30 | {2, &AOC_U::CountAddOnContent, "CountAddOnContent"}, | ||
| 31 | {3, &AOC_U::ListAddOnContent, "ListAddOnContent"}, | ||
| 32 | {4, nullptr, "GetAddOnContentBaseIdByApplicationId"}, | ||
| 33 | {5, &AOC_U::GetAddOnContentBaseId, "GetAddOnContentBaseId"}, | ||
| 34 | {6, nullptr, "PrepareAddOnContentByApplicationId"}, | ||
| 35 | {7, &AOC_U::PrepareAddOnContent, "PrepareAddOnContent"}, | ||
| 36 | {8, nullptr, "GetAddOnContentListChangedEvent"}, | ||
| 37 | }; | ||
| 38 | RegisterHandlers(functions); | ||
| 39 | |||
| 40 | // Accumulate AOC title ids | ||
| 41 | const auto rcu = FileSystem::GetUnionContents(); | 30 | const auto rcu = FileSystem::GetUnionContents(); |
| 42 | const auto list = | 31 | const auto list = |
| 43 | rcu->ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); | 32 | rcu->ListEntriesFilter(FileSys::TitleType::AOC, FileSys::ContentRecordType::Data); |
| @@ -51,6 +40,22 @@ AOC_U::AOC_U() : ServiceFramework("aoc:u") { | |||
| 51 | Loader::ResultStatus::Success; | 40 | Loader::ResultStatus::Success; |
| 52 | }), | 41 | }), |
| 53 | add_on_content.end()); | 42 | add_on_content.end()); |
| 43 | return add_on_content; | ||
| 44 | } | ||
| 45 | |||
| 46 | AOC_U::AOC_U() : ServiceFramework("aoc:u"), add_on_content(AccumulateAOCTitleIDs()) { | ||
| 47 | static const FunctionInfo functions[] = { | ||
| 48 | {0, nullptr, "CountAddOnContentByApplicationId"}, | ||
| 49 | {1, nullptr, "ListAddOnContentByApplicationId"}, | ||
| 50 | {2, &AOC_U::CountAddOnContent, "CountAddOnContent"}, | ||
| 51 | {3, &AOC_U::ListAddOnContent, "ListAddOnContent"}, | ||
| 52 | {4, nullptr, "GetAddOnContentBaseIdByApplicationId"}, | ||
| 53 | {5, &AOC_U::GetAddOnContentBaseId, "GetAddOnContentBaseId"}, | ||
| 54 | {6, nullptr, "PrepareAddOnContentByApplicationId"}, | ||
| 55 | {7, &AOC_U::PrepareAddOnContent, "PrepareAddOnContent"}, | ||
| 56 | {8, nullptr, "GetAddOnContentListChangedEvent"}, | ||
| 57 | }; | ||
| 58 | RegisterHandlers(functions); | ||
| 54 | } | 59 | } |
| 55 | 60 | ||
| 56 | AOC_U::~AOC_U() = default; | 61 | AOC_U::~AOC_U() = default; |
| @@ -59,7 +64,7 @@ void AOC_U::CountAddOnContent(Kernel::HLERequestContext& ctx) { | |||
| 59 | IPC::ResponseBuilder rb{ctx, 4}; | 64 | IPC::ResponseBuilder rb{ctx, 4}; |
| 60 | rb.Push(RESULT_SUCCESS); | 65 | rb.Push(RESULT_SUCCESS); |
| 61 | 66 | ||
| 62 | const auto current = Core::System::GetInstance().CurrentProcess()->program_id; | 67 | const auto current = Core::System::GetInstance().CurrentProcess()->GetTitleID(); |
| 63 | rb.Push<u32>(std::count_if(add_on_content.begin(), add_on_content.end(), [¤t](u64 tid) { | 68 | rb.Push<u32>(std::count_if(add_on_content.begin(), add_on_content.end(), [¤t](u64 tid) { |
| 64 | return (tid & DLC_BASE_TITLE_ID_MASK) == current; | 69 | return (tid & DLC_BASE_TITLE_ID_MASK) == current; |
| 65 | })); | 70 | })); |
| @@ -71,7 +76,7 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) { | |||
| 71 | const auto offset = rp.PopRaw<u32>(); | 76 | const auto offset = rp.PopRaw<u32>(); |
| 72 | auto count = rp.PopRaw<u32>(); | 77 | auto count = rp.PopRaw<u32>(); |
| 73 | 78 | ||
| 74 | const auto current = Core::System::GetInstance().CurrentProcess()->program_id; | 79 | const auto current = Core::System::GetInstance().CurrentProcess()->GetTitleID(); |
| 75 | 80 | ||
| 76 | std::vector<u32> out; | 81 | std::vector<u32> out; |
| 77 | for (size_t i = 0; i < add_on_content.size(); ++i) { | 82 | for (size_t i = 0; i < add_on_content.size(); ++i) { |
| @@ -87,7 +92,8 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) { | |||
| 87 | } | 92 | } |
| 88 | 93 | ||
| 89 | count = std::min<size_t>(out.size() - offset, count); | 94 | count = std::min<size_t>(out.size() - offset, count); |
| 90 | out = std::vector<u32>(out.begin() + offset, out.begin() + offset + count); | 95 | std::rotate(out.begin(), out.begin() + offset, out.end()); |
| 96 | out.resize(count); | ||
| 91 | 97 | ||
| 92 | ctx.WriteBuffer(out); | 98 | ctx.WriteBuffer(out); |
| 93 | 99 | ||
| @@ -98,7 +104,7 @@ void AOC_U::ListAddOnContent(Kernel::HLERequestContext& ctx) { | |||
| 98 | void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) { | 104 | void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) { |
| 99 | IPC::ResponseBuilder rb{ctx, 4}; | 105 | IPC::ResponseBuilder rb{ctx, 4}; |
| 100 | rb.Push(RESULT_SUCCESS); | 106 | rb.Push(RESULT_SUCCESS); |
| 101 | rb.Push(Core::System::GetInstance().CurrentProcess()->program_id | DLC_BASE_TO_AOC_ID_MASK); | 107 | rb.Push(Core::System::GetInstance().CurrentProcess()->GetTitleID() | DLC_BASE_TO_AOC_ID_MASK); |
| 102 | } | 108 | } |
| 103 | 109 | ||
| 104 | void AOC_U::PrepareAddOnContent(Kernel::HLERequestContext& ctx) { | 110 | void AOC_U::PrepareAddOnContent(Kernel::HLERequestContext& ctx) { |