diff options
| author | 2021-09-22 17:52:37 -0400 | |
|---|---|---|
| committer | 2021-09-22 17:59:00 -0400 | |
| commit | 40314cc58646e9e91e961e0d82b7d1b53bd839a0 (patch) | |
| tree | 17ec58af41507fc0edff29325b528ac4029d599b /src | |
| parent | Merge pull request #7003 from ameerj/unlocked-present-mode (diff) | |
| download | yuzu-40314cc58646e9e91e961e0d82b7d1b53bd839a0.tar.gz yuzu-40314cc58646e9e91e961e0d82b7d1b53bd839a0.tar.xz yuzu-40314cc58646e9e91e961e0d82b7d1b53bd839a0.zip | |
common/uuid: Add validity checking functions to interface
Given we have a function to invalidate, we should also have ones to
query the validity. Also makes the code more straightforward to read.
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/uuid.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/acc/acc.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applet_profile_select.cpp | 2 |
4 files changed, 14 insertions, 7 deletions
diff --git a/src/common/uuid.h b/src/common/uuid.h index 2353179d8..8ea01f8da 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h | |||
| @@ -58,6 +58,13 @@ struct UUID { | |||
| 58 | uuid = INVALID_UUID; | 58 | uuid = INVALID_UUID; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | [[nodiscard]] constexpr bool IsInvalid() const { | ||
| 62 | return uuid == INVALID_UUID; | ||
| 63 | } | ||
| 64 | [[nodiscard]] constexpr bool IsValid() const { | ||
| 65 | return !IsInvalid(); | ||
| 66 | } | ||
| 67 | |||
| 61 | // TODO(ogniK): Properly generate a Nintendo ID | 68 | // TODO(ogniK): Properly generate a Nintendo ID |
| 62 | [[nodiscard]] constexpr u64 GetNintendoID() const { | 69 | [[nodiscard]] constexpr u64 GetNintendoID() const { |
| 63 | return uuid[0]; | 70 | return uuid[0]; |
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 6d9ec0a8a..689b36056 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -929,8 +929,7 @@ void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContex | |||
| 929 | } | 929 | } |
| 930 | 930 | ||
| 931 | const auto user_list = profile_manager->GetAllUsers(); | 931 | const auto user_list = profile_manager->GetAllUsers(); |
| 932 | if (std::all_of(user_list.begin(), user_list.end(), | 932 | if (std::ranges::all_of(user_list, [](const auto& user) { return user.IsInvalid(); })) { |
| 933 | [](const auto& user) { return user.uuid == Common::INVALID_UUID; })) { | ||
| 934 | rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code | 933 | rb.Push(ResultUnknown); // TODO(ogniK): Find the correct error code |
| 935 | rb.PushRaw<u128>(Common::INVALID_UUID); | 934 | rb.PushRaw<u128>(Common::INVALID_UUID); |
| 936 | return; | 935 | return; |
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 24a1c9157..568303ced 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -208,9 +208,10 @@ bool ProfileManager::UserExists(UUID uuid) const { | |||
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | bool ProfileManager::UserExistsIndex(std::size_t index) const { | 210 | bool ProfileManager::UserExistsIndex(std::size_t index) const { |
| 211 | if (index >= MAX_USERS) | 211 | if (index >= MAX_USERS) { |
| 212 | return false; | 212 | return false; |
| 213 | return profiles[index].user_uuid.uuid != Common::INVALID_UUID; | 213 | } |
| 214 | return profiles[index].user_uuid.IsValid(); | ||
| 214 | } | 215 | } |
| 215 | 216 | ||
| 216 | /// Opens a specific user | 217 | /// Opens a specific user |
| @@ -304,7 +305,7 @@ bool ProfileManager::RemoveUser(UUID uuid) { | |||
| 304 | 305 | ||
| 305 | bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { | 306 | bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { |
| 306 | const auto index = GetUserIndex(uuid); | 307 | const auto index = GetUserIndex(uuid); |
| 307 | if (!index || profile_new.user_uuid == UUID(Common::INVALID_UUID)) { | 308 | if (!index || profile_new.user_uuid.IsInvalid()) { |
| 308 | return false; | 309 | return false; |
| 309 | } | 310 | } |
| 310 | 311 | ||
| @@ -346,7 +347,7 @@ void ProfileManager::ParseUserSaveFile() { | |||
| 346 | } | 347 | } |
| 347 | 348 | ||
| 348 | for (const auto& user : data.users) { | 349 | for (const auto& user : data.users) { |
| 349 | if (user.uuid == UUID(Common::INVALID_UUID)) { | 350 | if (user.uuid.IsInvalid()) { |
| 350 | continue; | 351 | continue; |
| 351 | } | 352 | } |
| 352 | 353 | ||
diff --git a/src/core/hle/service/am/applets/applet_profile_select.cpp b/src/core/hle/service/am/applets/applet_profile_select.cpp index bdc21778e..a6e891944 100644 --- a/src/core/hle/service/am/applets/applet_profile_select.cpp +++ b/src/core/hle/service/am/applets/applet_profile_select.cpp | |||
| @@ -60,7 +60,7 @@ void ProfileSelect::Execute() { | |||
| 60 | void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) { | 60 | void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) { |
| 61 | UserSelectionOutput output{}; | 61 | UserSelectionOutput output{}; |
| 62 | 62 | ||
| 63 | if (uuid.has_value() && uuid->uuid != Common::INVALID_UUID) { | 63 | if (uuid.has_value() && uuid->IsValid()) { |
| 64 | output.result = 0; | 64 | output.result = 0; |
| 65 | output.uuid_selected = uuid->uuid; | 65 | output.uuid_selected = uuid->uuid; |
| 66 | } else { | 66 | } else { |