From 84cb20bc72031947ac9e625b4a2b5e0059dda441 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 14 Jul 2023 20:16:39 -0400 Subject: core: remove ResultVal type --- src/core/hle/service/mii/mii.cpp | 34 +++++++++++--------------------- src/core/hle/service/mii/mii_manager.cpp | 5 ++--- src/core/hle/service/mii/mii_manager.h | 4 ++-- 3 files changed, 16 insertions(+), 27 deletions(-) (limited to 'src/core/hle/service/mii') diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 5c7adf97d..65c11a2f3 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -101,20 +101,14 @@ private: LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag); - const auto result{manager.GetDefault(source_flag)}; - if (result.Failed()) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result.Code()); - return; - } - - if (result->size() > 0) { - ctx.WriteBuffer(SerializeArray(*result)); + const auto default_miis{manager.GetDefault(source_flag)}; + if (default_miis.size() > 0) { + ctx.WriteBuffer(SerializeArray(default_miis)); } IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(static_cast(result->size())); + rb.Push(static_cast(default_miis.size())); } void Get1(HLERequestContext& ctx) { @@ -123,15 +117,10 @@ private: LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag); - const auto result{manager.GetDefault(source_flag)}; - if (result.Failed()) { - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result.Code()); - return; - } + const auto default_miis{manager.GetDefault(source_flag)}; std::vector values; - for (const auto& element : *result) { + for (const auto& element : default_miis) { values.emplace_back(element.info); } @@ -139,7 +128,7 @@ private: IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(static_cast(result->size())); + rb.Push(static_cast(default_miis.size())); } void UpdateLatest(HLERequestContext& ctx) { @@ -149,16 +138,17 @@ private: LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag); - const auto result{manager.UpdateLatest(info, source_flag)}; - if (result.Failed()) { + CharInfo new_char_info{}; + const auto result{manager.UpdateLatest(&new_char_info, info, source_flag)}; + if (result != ResultSuccess) { IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result.Code()); + rb.Push(result); return; } IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; rb.Push(ResultSuccess); - rb.PushRaw(*result); + rb.PushRaw(new_char_info); } void BuildRandom(HLERequestContext& ctx) { diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index c920650f5..46125d473 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp @@ -409,8 +409,7 @@ u32 MiiManager::GetCount(SourceFlag source_flag) const { return static_cast(count); } -ResultVal MiiManager::UpdateLatest([[maybe_unused]] const CharInfo& info, - SourceFlag source_flag) { +Result MiiManager::UpdateLatest(CharInfo* out_info, const CharInfo& info, SourceFlag source_flag) { if ((source_flag & SourceFlag::Database) == SourceFlag::None) { return ERROR_CANNOT_FIND_ENTRY; } @@ -672,7 +671,7 @@ bool MiiManager::ValidateV3Info(const Ver3StoreData& mii_v3) const { return is_valid; } -ResultVal> MiiManager::GetDefault(SourceFlag source_flag) { +std::vector MiiManager::GetDefault(SourceFlag source_flag) { std::vector result; if ((source_flag & SourceFlag::Default) == SourceFlag::None) { diff --git a/src/core/hle/service/mii/mii_manager.h b/src/core/hle/service/mii/mii_manager.h index 5525fcd1c..45c2be3c8 100644 --- a/src/core/hle/service/mii/mii_manager.h +++ b/src/core/hle/service/mii/mii_manager.h @@ -19,12 +19,12 @@ public: bool CheckAndResetUpdateCounter(SourceFlag source_flag, u64& current_update_counter); bool IsFullDatabase() const; u32 GetCount(SourceFlag source_flag) const; - ResultVal UpdateLatest(const CharInfo& info, SourceFlag source_flag); + Result UpdateLatest(CharInfo* out_info, const CharInfo& info, SourceFlag source_flag); CharInfo BuildRandom(Age age, Gender gender, Race race); CharInfo BuildDefault(std::size_t index); CharInfo ConvertV3ToCharInfo(const Ver3StoreData& mii_v3) const; bool ValidateV3Info(const Ver3StoreData& mii_v3) const; - ResultVal> GetDefault(SourceFlag source_flag); + std::vector GetDefault(SourceFlag source_flag); Result GetIndex(const CharInfo& info, u32& index); // This is nn::mii::detail::Ver::StoreDataRaw::BuildFromStoreData -- cgit v1.2.3