diff options
| author | 2018-11-14 19:02:25 -0800 | |
|---|---|---|
| committer | 2018-11-14 19:02:25 -0800 | |
| commit | c6c74248fe3fc08a3b223edcc0f8b48a2efcb370 (patch) | |
| tree | 501bf72cebd62fa3b8e74076f82da3cb154924bf | |
| parent | Merge pull request #1696 from lioncash/acc-cond (diff) | |
| parent | profile_manager: Replace iterative loop with a ranged-for loop in ParseUserSa... (diff) | |
| download | yuzu-c6c74248fe3fc08a3b223edcc0f8b48a2efcb370.tar.gz yuzu-c6c74248fe3fc08a3b223edcc0f8b48a2efcb370.tar.xz yuzu-c6c74248fe3fc08a3b223edcc0f8b48a2efcb370.zip | |
Merge pull request #1697 from lioncash/acc
acc/profile_manager: Minor cleanup-related changes
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 25 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.h | 13 |
2 files changed, 23 insertions, 15 deletions
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index c08394e4c..968263846 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -2,8 +2,11 @@ | |||
| 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 <cstring> | ||
| 5 | #include <random> | 6 | #include <random> |
| 6 | 7 | ||
| 8 | #include <fmt/format.h> | ||
| 9 | |||
| 7 | #include "common/file_util.h" | 10 | #include "common/file_util.h" |
| 8 | #include "core/hle/service/acc/profile_manager.h" | 11 | #include "core/hle/service/acc/profile_manager.h" |
| 9 | #include "core/settings.h" | 12 | #include "core/settings.h" |
| @@ -39,6 +42,19 @@ UUID UUID::Generate() { | |||
| 39 | return UUID{distribution(gen), distribution(gen)}; | 42 | return UUID{distribution(gen), distribution(gen)}; |
| 40 | } | 43 | } |
| 41 | 44 | ||
| 45 | std::string UUID::Format() const { | ||
| 46 | return fmt::format("0x{:016X}{:016X}", uuid[1], uuid[0]); | ||
| 47 | } | ||
| 48 | |||
| 49 | std::string UUID::FormatSwitch() const { | ||
| 50 | std::array<u8, 16> s{}; | ||
| 51 | std::memcpy(s.data(), uuid.data(), sizeof(u128)); | ||
| 52 | return fmt::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{" | ||
| 53 | ":02x}{:02x}{:02x}{:02x}{:02x}", | ||
| 54 | s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], | ||
| 55 | s[12], s[13], s[14], s[15]); | ||
| 56 | } | ||
| 57 | |||
| 42 | ProfileManager::ProfileManager() { | 58 | ProfileManager::ProfileManager() { |
| 43 | ParseUserSaveFile(); | 59 | ParseUserSaveFile(); |
| 44 | 60 | ||
| @@ -325,11 +341,12 @@ void ProfileManager::ParseUserSaveFile() { | |||
| 325 | return; | 341 | return; |
| 326 | } | 342 | } |
| 327 | 343 | ||
| 328 | for (std::size_t i = 0; i < MAX_USERS; ++i) { | 344 | for (const auto& user : data.users) { |
| 329 | const auto& user = data.users[i]; | 345 | if (user.uuid == UUID(INVALID_UUID)) { |
| 346 | continue; | ||
| 347 | } | ||
| 330 | 348 | ||
| 331 | if (user.uuid != UUID(INVALID_UUID)) | 349 | AddUser({user.uuid, user.username, user.timestamp, {}, false}); |
| 332 | AddUser({user.uuid, user.username, user.timestamp, {}, false}); | ||
| 333 | } | 350 | } |
| 334 | 351 | ||
| 335 | std::stable_partition(profiles.begin(), profiles.end(), | 352 | std::stable_partition(profiles.begin(), profiles.end(), |
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index 747c46c20..d2d8e6c6b 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h | |||
| @@ -42,18 +42,9 @@ struct UUID { | |||
| 42 | void Invalidate() { | 42 | void Invalidate() { |
| 43 | uuid = INVALID_UUID; | 43 | uuid = INVALID_UUID; |
| 44 | } | 44 | } |
| 45 | std::string Format() const { | ||
| 46 | return fmt::format("0x{:016X}{:016X}", uuid[1], uuid[0]); | ||
| 47 | } | ||
| 48 | 45 | ||
| 49 | std::string FormatSwitch() const { | 46 | std::string Format() const; |
| 50 | std::array<u8, 16> s{}; | 47 | std::string FormatSwitch() const; |
| 51 | std::memcpy(s.data(), uuid.data(), sizeof(u128)); | ||
| 52 | return fmt::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{" | ||
| 53 | ":02x}{:02x}{:02x}{:02x}{:02x}", | ||
| 54 | s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], | ||
| 55 | s[12], s[13], s[14], s[15]); | ||
| 56 | } | ||
| 57 | }; | 48 | }; |
| 58 | static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); | 49 | static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); |
| 59 | 50 | ||