diff options
| author | 2018-11-26 17:11:12 -0500 | |
|---|---|---|
| committer | 2018-11-26 17:11:12 -0500 | |
| commit | dac0c33fd219e7f3fadbb85e0fcd2005f8f9c338 (patch) | |
| tree | 285accc2e3341050c3abb14dcf2aaeff6cb53e04 | |
| parent | Merge pull request #1641 from DarkLordZach/sm-register-unregister (diff) | |
| download | yuzu-dac0c33fd219e7f3fadbb85e0fcd2005f8f9c338.tar.gz yuzu-dac0c33fd219e7f3fadbb85e0fcd2005f8f9c338.tar.xz yuzu-dac0c33fd219e7f3fadbb85e0fcd2005f8f9c338.zip | |
profile_manager: Save and load ProfileData from disk
The ProfileData is a 0x80-sized structure that stores various pieces of miscellaneous data for the account.
| -rw-r--r-- | src/core/hle/service/acc/acc.cpp | 17 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/acc/profile_manager.h | 14 |
3 files changed, 19 insertions, 17 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index c629f9357..9521431bb 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -21,17 +21,6 @@ | |||
| 21 | 21 | ||
| 22 | namespace Service::Account { | 22 | namespace Service::Account { |
| 23 | 23 | ||
| 24 | // TODO: RE this structure | ||
| 25 | struct UserData { | ||
| 26 | INSERT_PADDING_WORDS(1); | ||
| 27 | u32 icon_id; | ||
| 28 | u8 bg_color_id; | ||
| 29 | INSERT_PADDING_BYTES(0x7); | ||
| 30 | INSERT_PADDING_BYTES(0x10); | ||
| 31 | INSERT_PADDING_BYTES(0x60); | ||
| 32 | }; | ||
| 33 | static_assert(sizeof(UserData) == 0x80, "UserData structure has incorrect size"); | ||
| 34 | |||
| 35 | // Smallest JPEG https://github.com/mathiasbynens/small/blob/master/jpeg.jpg | 24 | // Smallest JPEG https://github.com/mathiasbynens/small/blob/master/jpeg.jpg |
| 36 | // used as a backup should the one on disk not exist | 25 | // used as a backup should the one on disk not exist |
| 37 | constexpr u32 backup_jpeg_size = 107; | 26 | constexpr u32 backup_jpeg_size = 107; |
| @@ -72,9 +61,11 @@ private: | |||
| 72 | void Get(Kernel::HLERequestContext& ctx) { | 61 | void Get(Kernel::HLERequestContext& ctx) { |
| 73 | LOG_INFO(Service_ACC, "called user_id={}", user_id.Format()); | 62 | LOG_INFO(Service_ACC, "called user_id={}", user_id.Format()); |
| 74 | ProfileBase profile_base{}; | 63 | ProfileBase profile_base{}; |
| 75 | std::array<u8, MAX_DATA> data{}; | 64 | ProfileData data{}; |
| 76 | if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) { | 65 | if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) { |
| 77 | ctx.WriteBuffer(data); | 66 | std::array<u8, sizeof(ProfileData)> raw_data; |
| 67 | std::memcpy(raw_data.data(), &data, sizeof(ProfileData)); | ||
| 68 | ctx.WriteBuffer(raw_data); | ||
| 78 | IPC::ResponseBuilder rb{ctx, 16}; | 69 | IPC::ResponseBuilder rb{ctx, 16}; |
| 79 | rb.Push(RESULT_SUCCESS); | 70 | rb.Push(RESULT_SUCCESS); |
| 80 | rb.PushRaw(profile_base); | 71 | rb.PushRaw(profile_base); |
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 968263846..1316d0b07 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -18,7 +18,7 @@ struct UserRaw { | |||
| 18 | UUID uuid2; | 18 | UUID uuid2; |
| 19 | u64 timestamp; | 19 | u64 timestamp; |
| 20 | ProfileUsername username; | 20 | ProfileUsername username; |
| 21 | INSERT_PADDING_BYTES(0x80); | 21 | ProfileData extra_data; |
| 22 | }; | 22 | }; |
| 23 | static_assert(sizeof(UserRaw) == 0xC8, "UserRaw has incorrect size."); | 23 | static_assert(sizeof(UserRaw) == 0xC8, "UserRaw has incorrect size."); |
| 24 | 24 | ||
| @@ -346,7 +346,7 @@ void ProfileManager::ParseUserSaveFile() { | |||
| 346 | continue; | 346 | continue; |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | AddUser({user.uuid, user.username, user.timestamp, {}, false}); | 349 | AddUser({user.uuid, user.username, user.timestamp, user.extra_data, false}); |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | std::stable_partition(profiles.begin(), profiles.end(), | 352 | std::stable_partition(profiles.begin(), profiles.end(), |
| @@ -361,6 +361,7 @@ void ProfileManager::WriteUserSaveFile() { | |||
| 361 | raw.users[i].uuid2 = profiles[i].user_uuid; | 361 | raw.users[i].uuid2 = profiles[i].user_uuid; |
| 362 | raw.users[i].uuid = profiles[i].user_uuid; | 362 | raw.users[i].uuid = profiles[i].user_uuid; |
| 363 | raw.users[i].timestamp = profiles[i].creation_time; | 363 | raw.users[i].timestamp = profiles[i].creation_time; |
| 364 | raw.users[i].extra_data = profiles[i].data; | ||
| 364 | } | 365 | } |
| 365 | 366 | ||
| 366 | const auto raw_path = | 367 | const auto raw_path = |
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index d2d8e6c6b..c4ce2e0b3 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | namespace Service::Account { | 14 | namespace Service::Account { |
| 15 | constexpr std::size_t MAX_USERS = 8; | 15 | constexpr std::size_t MAX_USERS = 8; |
| 16 | constexpr std::size_t MAX_DATA = 128; | ||
| 17 | constexpr u128 INVALID_UUID{{0, 0}}; | 16 | constexpr u128 INVALID_UUID{{0, 0}}; |
| 18 | 17 | ||
| 19 | struct UUID { | 18 | struct UUID { |
| @@ -50,9 +49,20 @@ static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); | |||
| 50 | 49 | ||
| 51 | constexpr std::size_t profile_username_size = 32; | 50 | constexpr std::size_t profile_username_size = 32; |
| 52 | using ProfileUsername = std::array<u8, profile_username_size>; | 51 | using ProfileUsername = std::array<u8, profile_username_size>; |
| 53 | using ProfileData = std::array<u8, MAX_DATA>; | ||
| 54 | using UserIDArray = std::array<UUID, MAX_USERS>; | 52 | using UserIDArray = std::array<UUID, MAX_USERS>; |
| 55 | 53 | ||
| 54 | /// Contains extra data related to a user. | ||
| 55 | /// TODO: RE this structure | ||
| 56 | struct ProfileData { | ||
| 57 | INSERT_PADDING_WORDS(1); | ||
| 58 | u32 icon_id; | ||
| 59 | u8 bg_color_id; | ||
| 60 | INSERT_PADDING_BYTES(0x7); | ||
| 61 | INSERT_PADDING_BYTES(0x10); | ||
| 62 | INSERT_PADDING_BYTES(0x60); | ||
| 63 | }; | ||
| 64 | static_assert(sizeof(ProfileData) == 0x80, "ProfileData structure has incorrect size"); | ||
| 65 | |||
| 56 | /// This holds general information about a users profile. This is where we store all the information | 66 | /// This holds general information about a users profile. This is where we store all the information |
| 57 | /// based on a specific user | 67 | /// based on a specific user |
| 58 | struct ProfileInfo { | 68 | struct ProfileInfo { |