mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-10-30 23:49:01 -05:00 
			
		
		
		
	core: Initialize several structs that make use of Common::UUID.
This commit is contained in:
		| @@ -211,7 +211,7 @@ protected: | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     ProfileManager& profile_manager; |     ProfileManager& profile_manager; | ||||||
|     Common::UUID user_id; ///< The user id this profile refers to. |     Common::UUID user_id{Common::INVALID_UUID}; ///< The user id this profile refers to. | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class IProfile final : public IProfileCommon { | class IProfile final : public IProfileCommon { | ||||||
|   | |||||||
| @@ -16,17 +16,17 @@ namespace Service::Account { | |||||||
| using Common::UUID; | using Common::UUID; | ||||||
|  |  | ||||||
| struct UserRaw { | struct UserRaw { | ||||||
|     UUID uuid; |     UUID uuid{Common::INVALID_UUID}; | ||||||
|     UUID uuid2; |     UUID uuid2{Common::INVALID_UUID}; | ||||||
|     u64 timestamp; |     u64 timestamp{}; | ||||||
|     ProfileUsername username; |     ProfileUsername username{}; | ||||||
|     ProfileData extra_data; |     ProfileData extra_data{}; | ||||||
| }; | }; | ||||||
| static_assert(sizeof(UserRaw) == 0xC8, "UserRaw has incorrect size."); | static_assert(sizeof(UserRaw) == 0xC8, "UserRaw has incorrect size."); | ||||||
|  |  | ||||||
| struct ProfileDataRaw { | struct ProfileDataRaw { | ||||||
|     INSERT_PADDING_BYTES(0x10); |     INSERT_PADDING_BYTES(0x10); | ||||||
|     std::array<UserRaw, MAX_USERS> users; |     std::array<UserRaw, MAX_USERS> users{}; | ||||||
| }; | }; | ||||||
| static_assert(sizeof(ProfileDataRaw) == 0x650, "ProfileDataRaw has incorrect size."); | static_assert(sizeof(ProfileDataRaw) == 0x650, "ProfileDataRaw has incorrect size."); | ||||||
|  |  | ||||||
| @@ -238,7 +238,7 @@ UserIDArray ProfileManager::GetOpenUsers() const { | |||||||
|     std::transform(profiles.begin(), profiles.end(), output.begin(), [](const ProfileInfo& p) { |     std::transform(profiles.begin(), profiles.end(), output.begin(), [](const ProfileInfo& p) { | ||||||
|         if (p.is_open) |         if (p.is_open) | ||||||
|             return p.user_uuid; |             return p.user_uuid; | ||||||
|         return UUID{}; |         return UUID{Common::INVALID_UUID}; | ||||||
|     }); |     }); | ||||||
|     std::stable_partition(output.begin(), output.end(), [](const UUID& uuid) { return uuid; }); |     std::stable_partition(output.begin(), output.end(), [](const UUID& uuid) { return uuid; }); | ||||||
|     return output; |     return output; | ||||||
|   | |||||||
| @@ -13,9 +13,10 @@ | |||||||
| #include "core/hle/result.h" | #include "core/hle/result.h" | ||||||
|  |  | ||||||
| namespace Service::Account { | namespace Service::Account { | ||||||
| constexpr std::size_t MAX_USERS = 8; |  | ||||||
|  |  | ||||||
| constexpr std::size_t profile_username_size = 32; | constexpr std::size_t MAX_USERS{8}; | ||||||
|  | constexpr std::size_t profile_username_size{32}; | ||||||
|  |  | ||||||
| using ProfileUsername = std::array<u8, profile_username_size>; | using ProfileUsername = std::array<u8, profile_username_size>; | ||||||
| using UserIDArray = std::array<Common::UUID, MAX_USERS>; | using UserIDArray = std::array<Common::UUID, MAX_USERS>; | ||||||
|  |  | ||||||
| @@ -23,8 +24,8 @@ using UserIDArray = std::array<Common::UUID, MAX_USERS>; | |||||||
| /// TODO: RE this structure | /// TODO: RE this structure | ||||||
| struct ProfileData { | struct ProfileData { | ||||||
|     INSERT_PADDING_WORDS(1); |     INSERT_PADDING_WORDS(1); | ||||||
|     u32 icon_id; |     u32 icon_id{}; | ||||||
|     u8 bg_color_id; |     u8 bg_color_id{}; | ||||||
|     INSERT_PADDING_BYTES(0x7); |     INSERT_PADDING_BYTES(0x7); | ||||||
|     INSERT_PADDING_BYTES(0x10); |     INSERT_PADDING_BYTES(0x10); | ||||||
|     INSERT_PADDING_BYTES(0x60); |     INSERT_PADDING_BYTES(0x60); | ||||||
| @@ -34,17 +35,17 @@ static_assert(sizeof(ProfileData) == 0x80, "ProfileData structure has incorrect | |||||||
| /// This holds general information about a users profile. This is where we store all the information | /// This holds general information about a users profile. This is where we store all the information | ||||||
| /// based on a specific user | /// based on a specific user | ||||||
| struct ProfileInfo { | struct ProfileInfo { | ||||||
|     Common::UUID user_uuid; |     Common::UUID user_uuid{Common::INVALID_UUID}; | ||||||
|     ProfileUsername username; |     ProfileUsername username{}; | ||||||
|     u64 creation_time; |     u64 creation_time{}; | ||||||
|     ProfileData data; // TODO(ognik): Work out what this is |     ProfileData data{}; // TODO(ognik): Work out what this is | ||||||
|     bool is_open; |     bool is_open{}; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct ProfileBase { | struct ProfileBase { | ||||||
|     Common::UUID user_uuid; |     Common::UUID user_uuid{Common::INVALID_UUID}; | ||||||
|     u64_le timestamp; |     u64_le timestamp{}; | ||||||
|     ProfileUsername username; |     ProfileUsername username{}; | ||||||
|  |  | ||||||
|     // Zero out all the fields to make the profile slot considered "Empty" |     // Zero out all the fields to make the profile slot considered "Empty" | ||||||
|     void Invalidate() { |     void Invalidate() { | ||||||
| @@ -101,7 +102,7 @@ private: | |||||||
|     bool RemoveProfileAtIndex(std::size_t index); |     bool RemoveProfileAtIndex(std::size_t index); | ||||||
|  |  | ||||||
|     std::array<ProfileInfo, MAX_USERS> profiles{}; |     std::array<ProfileInfo, MAX_USERS> profiles{}; | ||||||
|     std::size_t user_count = 0; |     std::size_t user_count{}; | ||||||
|     Common::UUID last_opened_user{Common::INVALID_UUID}; |     Common::UUID last_opened_user{Common::INVALID_UUID}; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -241,7 +241,7 @@ private: | |||||||
|         bool has_received_friend_request; |         bool has_received_friend_request; | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     Common::UUID uuid; |     Common::UUID uuid{Common::INVALID_UUID}; | ||||||
|     Kernel::EventPair notification_event; |     Kernel::EventPair notification_event; | ||||||
|     std::queue<SizedNotificationInfo> notifications; |     std::queue<SizedNotificationInfo> notifications; | ||||||
|     States states{}; |     States states{}; | ||||||
|   | |||||||
| @@ -10,13 +10,13 @@ | |||||||
|  |  | ||||||
| namespace Service::Mii { | namespace Service::Mii { | ||||||
|  |  | ||||||
| constexpr std::size_t MAX_MIIS = 100; | constexpr std::size_t MAX_MIIS{100}; | ||||||
| constexpr u32 INVALID_INDEX = 0xFFFFFFFF; | constexpr u32 INVALID_INDEX{0xFFFFFFFF}; | ||||||
|  |  | ||||||
| struct RandomParameters { | struct RandomParameters { | ||||||
|     u32 unknown_1; |     u32 unknown_1{}; | ||||||
|     u32 unknown_2; |     u32 unknown_2{}; | ||||||
|     u32 unknown_3; |     u32 unknown_3{}; | ||||||
| }; | }; | ||||||
| static_assert(sizeof(RandomParameters) == 0xC, "RandomParameters has incorrect size."); | static_assert(sizeof(RandomParameters) == 0xC, "RandomParameters has incorrect size."); | ||||||
|  |  | ||||||
| @@ -30,57 +30,57 @@ enum class Source : u32 { | |||||||
| std::ostream& operator<<(std::ostream& os, Source source); | std::ostream& operator<<(std::ostream& os, Source source); | ||||||
|  |  | ||||||
| struct MiiInfo { | struct MiiInfo { | ||||||
|     Common::UUID uuid; |     Common::UUID uuid{Common::INVALID_UUID}; | ||||||
|     std::array<char16_t, 11> name; |     std::array<char16_t, 11> name{}; | ||||||
|     u8 font_region; |     u8 font_region{}; | ||||||
|     u8 favorite_color; |     u8 favorite_color{}; | ||||||
|     u8 gender; |     u8 gender{}; | ||||||
|     u8 height; |     u8 height{}; | ||||||
|     u8 weight; |     u8 weight{}; | ||||||
|     u8 mii_type; |     u8 mii_type{}; | ||||||
|     u8 mii_region; |     u8 mii_region{}; | ||||||
|     u8 face_type; |     u8 face_type{}; | ||||||
|     u8 face_color; |     u8 face_color{}; | ||||||
|     u8 face_wrinkle; |     u8 face_wrinkle{}; | ||||||
|     u8 face_makeup; |     u8 face_makeup{}; | ||||||
|     u8 hair_type; |     u8 hair_type{}; | ||||||
|     u8 hair_color; |     u8 hair_color{}; | ||||||
|     bool hair_flip; |     bool hair_flip{}; | ||||||
|     u8 eye_type; |     u8 eye_type{}; | ||||||
|     u8 eye_color; |     u8 eye_color{}; | ||||||
|     u8 eye_scale; |     u8 eye_scale{}; | ||||||
|     u8 eye_aspect_ratio; |     u8 eye_aspect_ratio{}; | ||||||
|     u8 eye_rotate; |     u8 eye_rotate{}; | ||||||
|     u8 eye_x; |     u8 eye_x{}; | ||||||
|     u8 eye_y; |     u8 eye_y{}; | ||||||
|     u8 eyebrow_type; |     u8 eyebrow_type{}; | ||||||
|     u8 eyebrow_color; |     u8 eyebrow_color{}; | ||||||
|     u8 eyebrow_scale; |     u8 eyebrow_scale{}; | ||||||
|     u8 eyebrow_aspect_ratio; |     u8 eyebrow_aspect_ratio{}; | ||||||
|     u8 eyebrow_rotate; |     u8 eyebrow_rotate{}; | ||||||
|     u8 eyebrow_x; |     u8 eyebrow_x{}; | ||||||
|     u8 eyebrow_y; |     u8 eyebrow_y{}; | ||||||
|     u8 nose_type; |     u8 nose_type{}; | ||||||
|     u8 nose_scale; |     u8 nose_scale{}; | ||||||
|     u8 nose_y; |     u8 nose_y{}; | ||||||
|     u8 mouth_type; |     u8 mouth_type{}; | ||||||
|     u8 mouth_color; |     u8 mouth_color{}; | ||||||
|     u8 mouth_scale; |     u8 mouth_scale{}; | ||||||
|     u8 mouth_aspect_ratio; |     u8 mouth_aspect_ratio{}; | ||||||
|     u8 mouth_y; |     u8 mouth_y{}; | ||||||
|     u8 facial_hair_color; |     u8 facial_hair_color{}; | ||||||
|     u8 beard_type; |     u8 beard_type{}; | ||||||
|     u8 mustache_type; |     u8 mustache_type{}; | ||||||
|     u8 mustache_scale; |     u8 mustache_scale{}; | ||||||
|     u8 mustache_y; |     u8 mustache_y{}; | ||||||
|     u8 glasses_type; |     u8 glasses_type{}; | ||||||
|     u8 glasses_color; |     u8 glasses_color{}; | ||||||
|     u8 glasses_scale; |     u8 glasses_scale{}; | ||||||
|     u8 glasses_y; |     u8 glasses_y{}; | ||||||
|     u8 mole_type; |     u8 mole_type{}; | ||||||
|     u8 mole_scale; |     u8 mole_scale{}; | ||||||
|     u8 mole_x; |     u8 mole_x{}; | ||||||
|     u8 mole_y; |     u8 mole_y{}; | ||||||
|     INSERT_PADDING_BYTES(1); |     INSERT_PADDING_BYTES(1); | ||||||
|  |  | ||||||
|     std::u16string Name() const; |     std::u16string Name() const; | ||||||
| @@ -94,14 +94,14 @@ bool operator!=(const MiiInfo& lhs, const MiiInfo& rhs); | |||||||
|  |  | ||||||
| #pragma pack(push, 4) | #pragma pack(push, 4) | ||||||
| struct MiiInfoElement { | struct MiiInfoElement { | ||||||
|     MiiInfo info; |     MiiInfo info{}; | ||||||
|     Source source; |     Source source{}; | ||||||
| }; | }; | ||||||
| static_assert(sizeof(MiiInfoElement) == 0x5C, "MiiInfoElement has incorrect size."); | static_assert(sizeof(MiiInfoElement) == 0x5C, "MiiInfoElement has incorrect size."); | ||||||
|  |  | ||||||
| struct MiiStoreBitFields { | struct MiiStoreBitFields { | ||||||
|     union { |     union { | ||||||
|         u32 word_0; |         u32 word_0{}; | ||||||
|  |  | ||||||
|         BitField<24, 8, u32> hair_type; |         BitField<24, 8, u32> hair_type; | ||||||
|         BitField<23, 1, u32> mole_type; |         BitField<23, 1, u32> mole_type; | ||||||
| @@ -112,7 +112,7 @@ struct MiiStoreBitFields { | |||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     union { |     union { | ||||||
|         u32 word_1; |         u32 word_1{}; | ||||||
|  |  | ||||||
|         BitField<31, 1, u32> gender; |         BitField<31, 1, u32> gender; | ||||||
|         BitField<24, 7, u32> eye_color; |         BitField<24, 7, u32> eye_color; | ||||||
| @@ -122,7 +122,7 @@ struct MiiStoreBitFields { | |||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     union { |     union { | ||||||
|         u32 word_2; |         u32 word_2{}; | ||||||
|  |  | ||||||
|         BitField<31, 1, u32> mii_type; |         BitField<31, 1, u32> mii_type; | ||||||
|         BitField<24, 7, u32> glasses_color; |         BitField<24, 7, u32> glasses_color; | ||||||
| @@ -135,7 +135,7 @@ struct MiiStoreBitFields { | |||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     union { |     union { | ||||||
|         u32 word_3; |         u32 word_3{}; | ||||||
|  |  | ||||||
|         BitField<29, 3, u32> mustache_type; |         BitField<29, 3, u32> mustache_type; | ||||||
|         BitField<24, 5, u32> eyebrow_type; |         BitField<24, 5, u32> eyebrow_type; | ||||||
| @@ -148,7 +148,7 @@ struct MiiStoreBitFields { | |||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     union { |     union { | ||||||
|         u32 word_4; |         u32 word_4{}; | ||||||
|  |  | ||||||
|         BitField<29, 3, u32> eye_rotate; |         BitField<29, 3, u32> eye_rotate; | ||||||
|         BitField<24, 5, u32> mustache_y; |         BitField<24, 5, u32> mustache_y; | ||||||
| @@ -160,7 +160,7 @@ struct MiiStoreBitFields { | |||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     union { |     union { | ||||||
|         u32 word_5; |         u32 word_5{}; | ||||||
|  |  | ||||||
|         BitField<24, 5, u32> glasses_type; |         BitField<24, 5, u32> glasses_type; | ||||||
|         BitField<20, 4, u32> face_type; |         BitField<20, 4, u32> face_type; | ||||||
| @@ -172,7 +172,7 @@ struct MiiStoreBitFields { | |||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     union { |     union { | ||||||
|         u32 word_6; |         u32 word_6{}; | ||||||
|  |  | ||||||
|         BitField<28, 4, u32> eyebrow_rotate; |         BitField<28, 4, u32> eyebrow_rotate; | ||||||
|         BitField<24, 4, u32> eyebrow_scale; |         BitField<24, 4, u32> eyebrow_scale; | ||||||
| @@ -192,30 +192,30 @@ struct MiiStoreData { | |||||||
|     // This corresponds to the above structure MiiStoreBitFields. I did it like this because the |     // This corresponds to the above structure MiiStoreBitFields. I did it like this because the | ||||||
|     // BitField<> type makes this (and any thing that contains it) not trivially copyable, which is |     // BitField<> type makes this (and any thing that contains it) not trivially copyable, which is | ||||||
|     // not suitable for our uses. |     // not suitable for our uses. | ||||||
|     std::array<u8, 0x1C> data; |     std::array<u8, 0x1C> data{}; | ||||||
|     static_assert(sizeof(MiiStoreBitFields) == sizeof(data), "data field has incorrect size."); |     static_assert(sizeof(MiiStoreBitFields) == sizeof(data), "data field has incorrect size."); | ||||||
|  |  | ||||||
|     std::array<char16_t, 10> name; |     std::array<char16_t, 10> name{}; | ||||||
|     Common::UUID uuid; |     Common::UUID uuid{Common::INVALID_UUID}; | ||||||
|     u16 crc_1; |     u16 crc_1{}; | ||||||
|     u16 crc_2; |     u16 crc_2{}; | ||||||
|  |  | ||||||
|     std::u16string Name() const; |     std::u16string Name() const; | ||||||
| }; | }; | ||||||
| static_assert(sizeof(MiiStoreData) == 0x44, "MiiStoreData has incorrect size."); | static_assert(sizeof(MiiStoreData) == 0x44, "MiiStoreData has incorrect size."); | ||||||
|  |  | ||||||
| struct MiiStoreDataElement { | struct MiiStoreDataElement { | ||||||
|     MiiStoreData data; |     MiiStoreData data{}; | ||||||
|     Source source; |     Source source{}; | ||||||
| }; | }; | ||||||
| static_assert(sizeof(MiiStoreDataElement) == 0x48, "MiiStoreDataElement has incorrect size."); | static_assert(sizeof(MiiStoreDataElement) == 0x48, "MiiStoreDataElement has incorrect size."); | ||||||
|  |  | ||||||
| struct MiiDatabase { | struct MiiDatabase { | ||||||
|     u32 magic; // 'NFDB' |     u32 magic{}; // 'NFDB' | ||||||
|     std::array<MiiStoreData, MAX_MIIS> miis; |     std::array<MiiStoreData, MAX_MIIS> miis{}; | ||||||
|     INSERT_PADDING_BYTES(1); |     INSERT_PADDING_BYTES(1); | ||||||
|     u8 count; |     u8 count{}; | ||||||
|     u16 crc; |     u16 crc{}; | ||||||
| }; | }; | ||||||
| static_assert(sizeof(MiiDatabase) == 0x1A98, "MiiDatabase has incorrect size."); | static_assert(sizeof(MiiDatabase) == 0x1A98, "MiiDatabase has incorrect size."); | ||||||
| #pragma pack(pop) | #pragma pack(pop) | ||||||
| @@ -266,8 +266,8 @@ private: | |||||||
|     void EnsureDatabasePartition(); |     void EnsureDatabasePartition(); | ||||||
|  |  | ||||||
|     MiiDatabase database; |     MiiDatabase database; | ||||||
|     bool updated_flag = false; |     bool updated_flag{}; | ||||||
|     bool is_test_mode_enabled = false; |     bool is_test_mode_enabled{}; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }; // namespace Service::Mii | }; // namespace Service::Mii | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bunnei
					bunnei