diff options
author | german77 <juangerman-13@hotmail.com> | 2023-09-11 16:53:23 +0200 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2023-09-11 17:54:32 +0200 |
commit | ec25f847d8c066241d3aa9bb00bd11cb0c47b161 (patch) | |
tree | 0fb517718e80499316fcd1994e93355391844af3 /src/core/hle/service/mii/types | |
parent | mii: Prepare Interface for new implementation (diff) | |
download | yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.gz yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.bz2 yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.lz yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.xz yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.tar.zst yuzu-ec25f847d8c066241d3aa9bb00bd11cb0c47b161.zip |
Diffstat (limited to 'src/core/hle/service/mii/types')
-rw-r--r-- | src/core/hle/service/mii/types/char_info.cpp | 112 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/char_info.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/core_data.cpp | 12 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/raw_data.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/raw_data.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/ver3_store_data.cpp | 23 | ||||
-rw-r--r-- | src/core/hle/service/mii/types/ver3_store_data.h | 6 |
7 files changed, 71 insertions, 88 deletions
diff --git a/src/core/hle/service/mii/types/char_info.cpp b/src/core/hle/service/mii/types/char_info.cpp index 0f9c37b84..cd7154c91 100644 --- a/src/core/hle/service/mii/types/char_info.cpp +++ b/src/core/hle/service/mii/types/char_info.cpp @@ -62,161 +62,161 @@ void CharInfo::SetFromStoreData(const StoreData& store_data) { padding = '\0'; } -u32 CharInfo::Verify() const { +ValidationResult CharInfo::Verify() const { if (!create_id.IsValid()) { - return 0x32; + return ValidationResult::InvalidCreateId; } if (!name.IsValid()) { - return 0x33; + return ValidationResult::InvalidName; } if (3 < font_region) { - return 0x17; + return ValidationResult::InvalidFont; } if (0xb < favorite_color) { - return 0x16; + return ValidationResult::InvalidColor; } if (1 < gender) { - return 0x18; + return ValidationResult::InvalidGender; } - if (height < 0) { - return 0x20; + if (height > 0x7f) { + return ValidationResult::InvalidHeight; } - if (build < 0) { - return 3; + if (build > 0x7f) { + return ValidationResult::InvalidBuild; } if (1 < type) { - return 0x35; + return ValidationResult::InvalidType; } if (3 < region_move) { - return 0x31; + return ValidationResult::InvalidRegionMove; } if (0xb < faceline_type) { - return 0x15; + return ValidationResult::InvalidFacelineType; } if (9 < faceline_color) { - return 0x12; + return ValidationResult::InvalidFacelineColor; } if (0xb < faceline_wrinkle) { - return 0x14; + return ValidationResult::InvalidFacelineWrinkle; } if (0xb < faceline_make) { - return 0x13; + return ValidationResult::InvalidFacelineMake; } if (0x83 < hair_type) { - return 0x1f; + return ValidationResult::InvalidHairType; } if (99 < hair_color) { - return 0x1d; + return ValidationResult::InvalidHairColor; } if (1 < hair_flip) { - return 0x1e; + return ValidationResult::InvalidHairFlip; } if (0x3b < eye_type) { - return 8; + return ValidationResult::InvalidEyeType; } if (99 < eye_color) { - return 5; + return ValidationResult::InvalidEyeColor; } if (7 < eye_scale) { - return 7; + return ValidationResult::InvalidEyeScale; } if (6 < eye_aspect) { - return 4; + return ValidationResult::InvalidEyeAspect; } if (7 < eye_rotate) { - return 6; + return ValidationResult::InvalidEyeRotate; } if (0xc < eye_x) { - return 9; + return ValidationResult::InvalidEyeX; } if (0x12 < eye_y) { - return 10; + return ValidationResult::InvalidEyeY; } if (0x17 < eyebrow_type) { - return 0xf; + return ValidationResult::InvalidEyebrowType; } if (99 < eyebrow_color) { - return 0xc; + return ValidationResult::InvalidEyebrowColor; } if (8 < eyebrow_scale) { - return 0xe; + return ValidationResult::InvalidEyebrowScale; } if (6 < eyebrow_aspect) { - return 0xb; + return ValidationResult::InvalidEyebrowAspect; } if (0xb < eyebrow_rotate) { - return 0xd; + return ValidationResult::InvalidEyebrowRotate; } if (0xc < eyebrow_x) { - return 0x10; + return ValidationResult::InvalidEyebrowX; } if (0xf < eyebrow_y - 3) { - return 0x11; + return ValidationResult::InvalidEyebrowY; } if (0x11 < nose_type) { - return 0x2f; + return ValidationResult::InvalidNoseType; } if (nose_scale >= 9) { - return 0x2e; + return ValidationResult::InvalidNoseScale; } if (0x12 < nose_y) { - return 0x30; + return ValidationResult::InvalidNoseY; } if (0x23 < mouth_type) { - return 0x28; + return ValidationResult::InvalidMouthType; } if (99 < mouth_color) { - return 0x26; + return ValidationResult::InvalidMouthColor; } if (8 < mouth_scale) { - return 0x27; + return ValidationResult::InvalidMouthScale; } if (6 < mouth_aspect) { - return 0x25; + return ValidationResult::InvalidMouthAspect; } if (0x12 < mouth_y) { - return 0x29; + return ValidationResult::InvalidMoleY; } if (99 < beard_color) { - return 1; + return ValidationResult::InvalidBeardColor; } if (5 < beard_type) { - return 2; + return ValidationResult::InvalidBeardType; } if (5 < mustache_type) { - return 0x2b; + return ValidationResult::InvalidMustacheType; } if (8 < mustache_scale) { - return 0x2a; + return ValidationResult::InvalidMustacheScale; } if (0x10 < mustache_y) { - return 0x2c; + return ValidationResult::InvalidMustacheY; } if (0x13 < glasses_type) { - return 0x1b; + return ValidationResult::InvalidGlassType; } if (99 < glasses_color) { - return 0x19; + return ValidationResult::InvalidGlassColor; } if (7 < glasses_scale) { - return 0x1a; + return ValidationResult::InvalidGlassScale; } if (0x14 < glasses_y) { - return 0x1c; + return ValidationResult::InvalidGlassY; } if (mole_type >= 2) { - return 0x22; + return ValidationResult::InvalidMoleType; } if (8 < mole_scale) { - return 0x21; + return ValidationResult::InvalidMoleScale; } if (mole_x >= 0x11) { - return 0x23; + return ValidationResult::InvalidMoleX; } if (0x1e < mole_y) { - return 0x24; + return ValidationResult::InvalidMoleY; } - return 0; + return ValidationResult::NoErrors; } Common::UUID CharInfo::GetCreateId() const { @@ -424,7 +424,7 @@ u8 CharInfo::GetMoleY() const { } bool CharInfo::operator==(const CharInfo& info) { - bool is_identical = info.Verify() == 0; + bool is_identical = info.Verify() == ValidationResult::NoErrors; is_identical &= name.data == info.GetNickname().data; is_identical &= create_id == info.GetCreateId(); is_identical &= font_region == info.GetFontRegion(); diff --git a/src/core/hle/service/mii/types/char_info.h b/src/core/hle/service/mii/types/char_info.h index 4f70edc24..65a7707d3 100644 --- a/src/core/hle/service/mii/types/char_info.h +++ b/src/core/hle/service/mii/types/char_info.h @@ -13,7 +13,7 @@ class CharInfo { public: void SetFromStoreData(const StoreData& store_data_raw); - u32 Verify() const; + ValidationResult Verify() const; Common::UUID GetCreateId() const; Nickname GetNickname() const; diff --git a/src/core/hle/service/mii/types/core_data.cpp b/src/core/hle/service/mii/types/core_data.cpp index 9d7e604a9..de82481b0 100644 --- a/src/core/hle/service/mii/types/core_data.cpp +++ b/src/core/hle/service/mii/types/core_data.cpp @@ -26,10 +26,10 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) { data.build.Assign(64); if (age == Age::All) { - const auto temp{MiiUtil::GetRandomValue<int>(10)}; - if (temp >= 8) { + const auto random{MiiUtil::GetRandomValue<int>(10)}; + if (random >= 8) { age = Age::Old; - } else if (temp >= 4) { + } else if (random >= 4) { age = Age::Normal; } else { age = Age::Young; @@ -37,10 +37,10 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) { } if (race == Race::All) { - const auto temp{MiiUtil::GetRandomValue<int>(10)}; - if (temp >= 8) { + const auto random{MiiUtil::GetRandomValue<int>(10)}; + if (random >= 8) { race = Race::Black; - } else if (temp >= 4) { + } else if (random >= 4) { race = Race::White; } else { race = Race::Asian; diff --git a/src/core/hle/service/mii/types/raw_data.cpp b/src/core/hle/service/mii/types/raw_data.cpp index ef678c527..ed299521f 100644 --- a/src/core/hle/service/mii/types/raw_data.cpp +++ b/src/core/hle/service/mii/types/raw_data.cpp @@ -5,7 +5,7 @@ namespace Service::Mii::RawData { -constexpr std::array<u8, 0x10> FromVer3FacelineColorTable{ +constexpr std::array<u8, 16> FromVer3FacelineColorTable{ 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x0, 0x1, 0x5, 0x5, }; diff --git a/src/core/hle/service/mii/types/raw_data.h b/src/core/hle/service/mii/types/raw_data.h index 180f49fd0..8c910096f 100644 --- a/src/core/hle/service/mii/types/raw_data.h +++ b/src/core/hle/service/mii/types/raw_data.h @@ -10,7 +10,7 @@ namespace Service::Mii::RawData { struct RandomMiiValues { - std::array<u8, 0xbc> values{}; + std::array<u8, 188> values{}; }; static_assert(sizeof(RandomMiiValues) == 0xbc, "RandomMiiValues has incorrect size."); diff --git a/src/core/hle/service/mii/types/ver3_store_data.cpp b/src/core/hle/service/mii/types/ver3_store_data.cpp index 53a3fe44b..c7624520c 100644 --- a/src/core/hle/service/mii/types/ver3_store_data.cpp +++ b/src/core/hle/service/mii/types/ver3_store_data.cpp @@ -33,16 +33,7 @@ void Ver3StoreData::BuildToStoreData(StoreData& out_store_data) const { out_store_data.SetHeight(height); out_store_data.SetBuild(build); - // Copy name until string terminator - Nickname name = {}; - for (std::size_t index = 0; index < name.data.size() - 1; index++) { - name.data[index] = mii_name[index]; - if (name.data[index] == 0) { - break; - } - } - - out_store_data.SetNickname(name); + out_store_data.SetNickname(mii_name); out_store_data.SetFontRegion( static_cast<FontRegion>(static_cast<u8>(region_information.font_region))); @@ -108,15 +99,7 @@ void Ver3StoreData::BuildFromStoreData(const StoreData& store_data) { height = store_data.GetHeight(); build = store_data.GetBuild(); - // Copy name until string terminator - mii_name = {}; - for (std::size_t index = 0; index < store_data.GetNickname().data.size() - 1; index++) { - mii_name[index] = store_data.GetNickname().data[index]; - if (mii_name[index] == 0) { - break; - } - } - + mii_name = store_data.GetNickname(); region_information.font_region.Assign(static_cast<u8>(store_data.GetFontRegion())); appearance_bits1.faceline_type.Assign(store_data.GetFacelineType()); @@ -183,7 +166,7 @@ void Ver3StoreData::BuildFromStoreData(const StoreData& store_data) { u32 Ver3StoreData::IsValid() const { bool is_valid = version == 0 || version == 3; - is_valid = is_valid && (mii_name[0] != 0); + is_valid = is_valid && (mii_name.data[0] != 0); is_valid = is_valid && (mii_information.birth_month < 13); is_valid = is_valid && (mii_information.birth_day < 32); diff --git a/src/core/hle/service/mii/types/ver3_store_data.h b/src/core/hle/service/mii/types/ver3_store_data.h index 11caeb5c3..47907bf7d 100644 --- a/src/core/hle/service/mii/types/ver3_store_data.h +++ b/src/core/hle/service/mii/types/ver3_store_data.h @@ -47,7 +47,7 @@ public: u16_be mii_id; u64_be system_id; u32_be specialness_and_creation_date; - std::array<u8, 0x6> creator_mac; + std::array<u8, 6> creator_mac; u16_be padding; union { u16 raw; @@ -58,7 +58,7 @@ public: BitField<10, 4, u16> favorite_color; BitField<14, 1, u16> favorite; } mii_information; - std::array<char16_t, 0xA> mii_name; + Nickname mii_name; u8 height; u8 build; union { @@ -150,7 +150,7 @@ public: BitField<10, 5, u16> mole_y; } appearance_bits11; - std::array<u16_le, 0xA> author_name; + Nickname author_name; INSERT_PADDING_BYTES(0x2); u16_be crc; }; |