From b8e70faa2df59086f04ad1d128c742ea23037dc3 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Sat, 11 Aug 2018 20:45:06 +1000 Subject: Added GetOpenUserCount --- src/core/hle/service/acc/acc.cpp | 3 ++- src/core/hle/service/acc/profile_manager.cpp | 13 +++++++++++-- src/core/hle/service/acc/profile_manager.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src/core/hle/service/acc') diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 9a377e86d..c9ab8311e 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -158,8 +158,9 @@ void Module::Interface::ListAllUsers(Kernel::HLERequestContext& ctx) { void Module::Interface::ListOpenUsers(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_ACC, "called"); ctx.WriteBuffer(profile_manager->GetOpenUsers()); - IPC::ResponseBuilder rb{ctx, 2}; + IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); + rb.Push(static_cast(profile_manager->GetOpenUserCount())); } void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index ef793b311..e8f6884d1 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -118,6 +118,11 @@ size_t ProfileManager::GetUserCount() const { return user_count; } +size_t ProfileManager::GetOpenUserCount() const { + return std::count_if(profiles.begin(), profiles.end(), + [](const ProfileInfo& p) { return p.is_open; }); +} + bool ProfileManager::UserExists(UUID uuid) const { return (GetUserIndex(uuid) != std::numeric_limits::max()); } @@ -148,8 +153,12 @@ std::array ProfileManager::GetAllUsers() const { std::array ProfileManager::GetOpenUsers() const { std::array output; - std::copy_if(profiles.begin(), profiles.end(), output.begin(), - [](const ProfileInfo& p) { return p.is_open; }); + std::transform(profiles.begin(), profiles.end(), output.begin(), [](const ProfileInfo& p) { + if (p.is_open) + return p.user_uuid; + return UUID{}; + }); + std::stable_partition(output.begin(), output.end(), [](const UUID& uuid) { return uuid; }); return output; } diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index 121206954..8ec1273e4 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h @@ -92,6 +92,7 @@ public: bool GetProfileBaseAndData(ProfileInfo user, ProfileBase& profile, std::array& data); size_t GetUserCount() const; + size_t GetOpenUserCount() const; bool UserExists(UUID uuid) const; void OpenUser(UUID uuid); void CloseUser(UUID uuid); -- cgit v1.2.3