diff options
| -rw-r--r-- | src/core/hle/service/mii/mii_result.h | 9 | ||||
| -rw-r--r-- | src/core/hle/service/mii/mii_types.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/char_info.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/char_info.h | 106 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/core_data.cpp | 213 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/core_data.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/store_data.cpp | 83 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/store_data.h | 17 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/ver3_store_data.cpp | 78 |
9 files changed, 387 insertions, 138 deletions
diff --git a/src/core/hle/service/mii/mii_result.h b/src/core/hle/service/mii/mii_result.h index 021cb76da..e2c36e556 100644 --- a/src/core/hle/service/mii/mii_result.h +++ b/src/core/hle/service/mii/mii_result.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| @@ -13,8 +13,15 @@ constexpr Result ResultNotUpdated{ErrorModule::Mii, 3}; | |||
| 13 | constexpr Result ResultNotFound{ErrorModule::Mii, 4}; | 13 | constexpr Result ResultNotFound{ErrorModule::Mii, 4}; |
| 14 | constexpr Result ResultDatabaseFull{ErrorModule::Mii, 5}; | 14 | constexpr Result ResultDatabaseFull{ErrorModule::Mii, 5}; |
| 15 | constexpr Result ResultInvalidCharInfo{ErrorModule::Mii, 100}; | 15 | constexpr Result ResultInvalidCharInfo{ErrorModule::Mii, 100}; |
| 16 | constexpr Result ResultInvalidDatabaseChecksum{ErrorModule::Mii, 101}; | ||
| 17 | constexpr Result ResultInvalidDatabaseSignature{ErrorModule::Mii, 103}; | ||
| 18 | constexpr Result ResultInvalidDatabaseVersion{ErrorModule::Mii, 104}; | ||
| 19 | constexpr Result ResultInvalidDatabaseLength{ErrorModule::Mii, 105}; | ||
| 20 | constexpr Result ResultInvalidCharInfo2{ErrorModule::Mii, 107}; | ||
| 16 | constexpr Result ResultInvalidStoreData{ErrorModule::Mii, 109}; | 21 | constexpr Result ResultInvalidStoreData{ErrorModule::Mii, 109}; |
| 17 | constexpr Result ResultInvalidOperation{ErrorModule::Mii, 202}; | 22 | constexpr Result ResultInvalidOperation{ErrorModule::Mii, 202}; |
| 18 | constexpr Result ResultPermissionDenied{ErrorModule::Mii, 203}; | 23 | constexpr Result ResultPermissionDenied{ErrorModule::Mii, 203}; |
| 24 | constexpr Result ResultTestModeOnly{ErrorModule::Mii, 204}; | ||
| 25 | constexpr Result ResultInvalidCharInfoType{ErrorModule::Mii, 205}; | ||
| 19 | 26 | ||
| 20 | }; // namespace Service::Mii | 27 | }; // namespace Service::Mii |
diff --git a/src/core/hle/service/mii/mii_types.h b/src/core/hle/service/mii/mii_types.h index 611ff4f81..9efe6c915 100644 --- a/src/core/hle/service/mii/mii_types.h +++ b/src/core/hle/service/mii/mii_types.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| @@ -26,14 +26,14 @@ constexpr u8 MaxEyebrowScale = 8; | |||
| 26 | constexpr u8 MaxEyebrowAspect = 6; | 26 | constexpr u8 MaxEyebrowAspect = 6; |
| 27 | constexpr u8 MaxEyebrowRotate = 11; | 27 | constexpr u8 MaxEyebrowRotate = 11; |
| 28 | constexpr u8 MaxEyebrowX = 12; | 28 | constexpr u8 MaxEyebrowX = 12; |
| 29 | constexpr u8 MaxEyebrowY = 18; | 29 | constexpr u8 MaxEyebrowY = 15; |
| 30 | constexpr u8 MaxNoseScale = 8; | 30 | constexpr u8 MaxNoseScale = 8; |
| 31 | constexpr u8 MaxNoseY = 18; | 31 | constexpr u8 MaxNoseY = 18; |
| 32 | constexpr u8 MaxMouthScale = 8; | 32 | constexpr u8 MaxMouthScale = 8; |
| 33 | constexpr u8 MaxMoutAspect = 6; | 33 | constexpr u8 MaxMoutAspect = 6; |
| 34 | constexpr u8 MaxMouthY = 18; | 34 | constexpr u8 MaxMouthY = 18; |
| 35 | constexpr u8 MaxMustacheScale = 8; | 35 | constexpr u8 MaxMustacheScale = 8; |
| 36 | constexpr u8 MasMustacheY = 16; | 36 | constexpr u8 MaxMustacheY = 16; |
| 37 | constexpr u8 MaxGlassScale = 7; | 37 | constexpr u8 MaxGlassScale = 7; |
| 38 | constexpr u8 MaxGlassY = 20; | 38 | constexpr u8 MaxGlassY = 20; |
| 39 | constexpr u8 MaxMoleScale = 8; | 39 | constexpr u8 MaxMoleScale = 8; |
| @@ -599,6 +599,7 @@ enum class ValidationResult : u32 { | |||
| 599 | InvalidRegionMove = 0x31, | 599 | InvalidRegionMove = 0x31, |
| 600 | InvalidCreateId = 0x32, | 600 | InvalidCreateId = 0x32, |
| 601 | InvalidName = 0x33, | 601 | InvalidName = 0x33, |
| 602 | InvalidChecksum = 0x34, | ||
| 602 | InvalidType = 0x35, | 603 | InvalidType = 0x35, |
| 603 | }; | 604 | }; |
| 604 | 605 | ||
diff --git a/src/core/hle/service/mii/types/char_info.cpp b/src/core/hle/service/mii/types/char_info.cpp index bb948c628..e90124af4 100644 --- a/src/core/hle/service/mii/types/char_info.cpp +++ b/src/core/hle/service/mii/types/char_info.cpp | |||
| @@ -37,7 +37,7 @@ void CharInfo::SetFromStoreData(const StoreData& store_data) { | |||
| 37 | eyebrow_aspect = store_data.GetEyebrowAspect(); | 37 | eyebrow_aspect = store_data.GetEyebrowAspect(); |
| 38 | eyebrow_rotate = store_data.GetEyebrowRotate(); | 38 | eyebrow_rotate = store_data.GetEyebrowRotate(); |
| 39 | eyebrow_x = store_data.GetEyebrowX(); | 39 | eyebrow_x = store_data.GetEyebrowX(); |
| 40 | eyebrow_y = store_data.GetEyebrowY(); | 40 | eyebrow_y = store_data.GetEyebrowY() + 3; |
| 41 | nose_type = store_data.GetNoseType(); | 41 | nose_type = store_data.GetNoseType(); |
| 42 | nose_scale = store_data.GetNoseScale(); | 42 | nose_scale = store_data.GetNoseScale(); |
| 43 | nose_y = store_data.GetNoseY(); | 43 | nose_y = store_data.GetNoseY(); |
| @@ -150,7 +150,7 @@ ValidationResult CharInfo::Verify() const { | |||
| 150 | if (eyebrow_x > MaxEyebrowX) { | 150 | if (eyebrow_x > MaxEyebrowX) { |
| 151 | return ValidationResult::InvalidEyebrowX; | 151 | return ValidationResult::InvalidEyebrowX; |
| 152 | } | 152 | } |
| 153 | if (eyebrow_y > MaxEyebrowY) { | 153 | if (eyebrow_y - 3 > MaxEyebrowY) { |
| 154 | return ValidationResult::InvalidEyebrowY; | 154 | return ValidationResult::InvalidEyebrowY; |
| 155 | } | 155 | } |
| 156 | if (nose_type > NoseType::Max) { | 156 | if (nose_type > NoseType::Max) { |
| @@ -189,7 +189,7 @@ ValidationResult CharInfo::Verify() const { | |||
| 189 | if (mustache_scale > MaxMustacheScale) { | 189 | if (mustache_scale > MaxMustacheScale) { |
| 190 | return ValidationResult::InvalidMustacheScale; | 190 | return ValidationResult::InvalidMustacheScale; |
| 191 | } | 191 | } |
| 192 | if (mustache_y > MasMustacheY) { | 192 | if (mustache_y > MaxMustacheY) { |
| 193 | return ValidationResult::InvalidMustacheY; | 193 | return ValidationResult::InvalidMustacheY; |
| 194 | } | 194 | } |
| 195 | if (glass_type > GlassType::Max) { | 195 | if (glass_type > GlassType::Max) { |
diff --git a/src/core/hle/service/mii/types/char_info.h b/src/core/hle/service/mii/types/char_info.h index d069b221f..d0c457fd5 100644 --- a/src/core/hle/service/mii/types/char_info.h +++ b/src/core/hle/service/mii/types/char_info.h | |||
| @@ -70,59 +70,59 @@ public: | |||
| 70 | bool operator==(const CharInfo& info); | 70 | bool operator==(const CharInfo& info); |
| 71 | 71 | ||
| 72 | private: | 72 | private: |
| 73 | Common::UUID create_id; | 73 | Common::UUID create_id{}; |
| 74 | Nickname name; | 74 | Nickname name{}; |
| 75 | u16 null_terminator; | 75 | u16 null_terminator{}; |
| 76 | FontRegion font_region; | 76 | FontRegion font_region{}; |
| 77 | FavoriteColor favorite_color; | 77 | FavoriteColor favorite_color{}; |
| 78 | Gender gender; | 78 | Gender gender{}; |
| 79 | u8 height; | 79 | u8 height{}; |
| 80 | u8 build; | 80 | u8 build{}; |
| 81 | u8 type; | 81 | u8 type{}; |
| 82 | u8 region_move; | 82 | u8 region_move{}; |
| 83 | FacelineType faceline_type; | 83 | FacelineType faceline_type{}; |
| 84 | FacelineColor faceline_color; | 84 | FacelineColor faceline_color{}; |
| 85 | FacelineWrinkle faceline_wrinkle; | 85 | FacelineWrinkle faceline_wrinkle{}; |
| 86 | FacelineMake faceline_make; | 86 | FacelineMake faceline_make{}; |
| 87 | HairType hair_type; | 87 | HairType hair_type{}; |
| 88 | CommonColor hair_color; | 88 | CommonColor hair_color{}; |
| 89 | HairFlip hair_flip; | 89 | HairFlip hair_flip{}; |
| 90 | EyeType eye_type; | 90 | EyeType eye_type{}; |
| 91 | CommonColor eye_color; | 91 | CommonColor eye_color{}; |
| 92 | u8 eye_scale; | 92 | u8 eye_scale{}; |
| 93 | u8 eye_aspect; | 93 | u8 eye_aspect{}; |
| 94 | u8 eye_rotate; | 94 | u8 eye_rotate{}; |
| 95 | u8 eye_x; | 95 | u8 eye_x{}; |
| 96 | u8 eye_y; | 96 | u8 eye_y{}; |
| 97 | EyebrowType eyebrow_type; | 97 | EyebrowType eyebrow_type{}; |
| 98 | CommonColor eyebrow_color; | 98 | CommonColor eyebrow_color{}; |
| 99 | u8 eyebrow_scale; | 99 | u8 eyebrow_scale{}; |
| 100 | u8 eyebrow_aspect; | 100 | u8 eyebrow_aspect{}; |
| 101 | u8 eyebrow_rotate; | 101 | u8 eyebrow_rotate{}; |
| 102 | u8 eyebrow_x; | 102 | u8 eyebrow_x{}; |
| 103 | u8 eyebrow_y; | 103 | u8 eyebrow_y{}; |
| 104 | NoseType nose_type; | 104 | NoseType nose_type{}; |
| 105 | u8 nose_scale; | 105 | u8 nose_scale{}; |
| 106 | u8 nose_y; | 106 | u8 nose_y{}; |
| 107 | MouthType mouth_type; | 107 | MouthType mouth_type{}; |
| 108 | CommonColor mouth_color; | 108 | CommonColor mouth_color{}; |
| 109 | u8 mouth_scale; | 109 | u8 mouth_scale{}; |
| 110 | u8 mouth_aspect; | 110 | u8 mouth_aspect{}; |
| 111 | u8 mouth_y; | 111 | u8 mouth_y{}; |
| 112 | CommonColor beard_color; | 112 | CommonColor beard_color{}; |
| 113 | BeardType beard_type; | 113 | BeardType beard_type{}; |
| 114 | MustacheType mustache_type; | 114 | MustacheType mustache_type{}; |
| 115 | u8 mustache_scale; | 115 | u8 mustache_scale{}; |
| 116 | u8 mustache_y; | 116 | u8 mustache_y{}; |
| 117 | GlassType glass_type; | 117 | GlassType glass_type{}; |
| 118 | CommonColor glass_color; | 118 | CommonColor glass_color{}; |
| 119 | u8 glass_scale; | 119 | u8 glass_scale{}; |
| 120 | u8 glass_y; | 120 | u8 glass_y{}; |
| 121 | MoleType mole_type; | 121 | MoleType mole_type{}; |
| 122 | u8 mole_scale; | 122 | u8 mole_scale{}; |
| 123 | u8 mole_x; | 123 | u8 mole_x{}; |
| 124 | u8 mole_y; | 124 | u8 mole_y{}; |
| 125 | u8 padding; | 125 | u8 padding{}; |
| 126 | }; | 126 | }; |
| 127 | static_assert(sizeof(CharInfo) == 0x58, "CharInfo has incorrect size."); | 127 | static_assert(sizeof(CharInfo) == 0x58, "CharInfo has incorrect size."); |
| 128 | static_assert(std::has_unique_object_representations_v<CharInfo>, | 128 | static_assert(std::has_unique_object_representations_v<CharInfo>, |
diff --git a/src/core/hle/service/mii/types/core_data.cpp b/src/core/hle/service/mii/types/core_data.cpp index 659288b51..465c6293a 100644 --- a/src/core/hle/service/mii/types/core_data.cpp +++ b/src/core/hle/service/mii/types/core_data.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include "common/assert.h" | 4 | #include "common/assert.h" |
| 5 | #include "core/hle/service/mii/mii_util.h" | 5 | #include "core/hle/service/mii/mii_util.h" |
| 6 | #include "core/hle/service/mii/types/char_info.h" | ||
| 6 | #include "core/hle/service/mii/types/core_data.h" | 7 | #include "core/hle/service/mii/types/core_data.h" |
| 7 | #include "core/hle/service/mii/types/raw_data.h" | 8 | #include "core/hle/service/mii/types/raw_data.h" |
| 8 | 9 | ||
| @@ -185,9 +186,211 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) { | |||
| 185 | SetMoleY(20); | 186 | SetMoleY(20); |
| 186 | } | 187 | } |
| 187 | 188 | ||
| 188 | u32 CoreData::IsValid() const { | 189 | void CoreData::BuildFromCharInfo(const CharInfo& char_info) { |
| 189 | // TODO: Complete this | 190 | name = char_info.GetNickname(); |
| 190 | return 0; | 191 | SetFontRegion(char_info.GetFontRegion()); |
| 192 | SetFavoriteColor(char_info.GetFavoriteColor()); | ||
| 193 | SetGender(char_info.GetGender()); | ||
| 194 | SetHeight(char_info.GetHeight()); | ||
| 195 | SetBuild(char_info.GetBuild()); | ||
| 196 | SetType(char_info.GetType()); | ||
| 197 | SetRegionMove(char_info.GetRegionMove()); | ||
| 198 | SetFacelineType(char_info.GetFacelineType()); | ||
| 199 | SetFacelineColor(char_info.GetFacelineColor()); | ||
| 200 | SetFacelineWrinkle(char_info.GetFacelineWrinkle()); | ||
| 201 | SetFacelineMake(char_info.GetFacelineMake()); | ||
| 202 | SetHairType(char_info.GetHairType()); | ||
| 203 | SetHairColor(char_info.GetHairColor()); | ||
| 204 | SetHairFlip(char_info.GetHairFlip()); | ||
| 205 | SetEyeType(char_info.GetEyeType()); | ||
| 206 | SetEyeColor(char_info.GetEyeColor()); | ||
| 207 | SetEyeScale(char_info.GetEyeScale()); | ||
| 208 | SetEyeAspect(char_info.GetEyeAspect()); | ||
| 209 | SetEyeRotate(char_info.GetEyeRotate()); | ||
| 210 | SetEyeX(char_info.GetEyeX()); | ||
| 211 | SetEyeY(char_info.GetEyeY()); | ||
| 212 | SetEyebrowType(char_info.GetEyebrowType()); | ||
| 213 | SetEyebrowColor(char_info.GetEyebrowColor()); | ||
| 214 | SetEyebrowScale(char_info.GetEyebrowScale()); | ||
| 215 | SetEyebrowAspect(char_info.GetEyebrowAspect()); | ||
| 216 | SetEyebrowRotate(char_info.GetEyebrowRotate()); | ||
| 217 | SetEyebrowX(char_info.GetEyebrowX()); | ||
| 218 | SetEyebrowY(char_info.GetEyebrowY() - 3); | ||
| 219 | SetNoseType(char_info.GetNoseType()); | ||
| 220 | SetNoseScale(char_info.GetNoseScale()); | ||
| 221 | SetNoseY(char_info.GetNoseY()); | ||
| 222 | SetMouthType(char_info.GetMouthType()); | ||
| 223 | SetMouthColor(char_info.GetMouthColor()); | ||
| 224 | SetMouthScale(char_info.GetMouthScale()); | ||
| 225 | SetMouthAspect(char_info.GetMouthAspect()); | ||
| 226 | SetMouthY(char_info.GetMouthY()); | ||
| 227 | SetBeardColor(char_info.GetBeardColor()); | ||
| 228 | SetBeardType(char_info.GetBeardType()); | ||
| 229 | SetMustacheType(char_info.GetMustacheType()); | ||
| 230 | SetMustacheScale(char_info.GetMustacheScale()); | ||
| 231 | SetMustacheY(char_info.GetMustacheY()); | ||
| 232 | SetGlassType(char_info.GetGlassType()); | ||
| 233 | SetGlassColor(char_info.GetGlassColor()); | ||
| 234 | SetGlassScale(char_info.GetGlassScale()); | ||
| 235 | SetGlassY(char_info.GetGlassY()); | ||
| 236 | SetMoleType(char_info.GetMoleType()); | ||
| 237 | SetMoleScale(char_info.GetMoleScale()); | ||
| 238 | SetMoleX(char_info.GetMoleX()); | ||
| 239 | SetMoleY(char_info.GetMoleY()); | ||
| 240 | } | ||
| 241 | |||
| 242 | ValidationResult CoreData::IsValid() const { | ||
| 243 | if (!name.IsValid()) { | ||
| 244 | return ValidationResult::InvalidName; | ||
| 245 | } | ||
| 246 | if (GetFontRegion() > FontRegion::Max) { | ||
| 247 | return ValidationResult::InvalidFont; | ||
| 248 | } | ||
| 249 | if (GetFavoriteColor() > FavoriteColor::Max) { | ||
| 250 | return ValidationResult::InvalidColor; | ||
| 251 | } | ||
| 252 | if (GetGender() > Gender::Max) { | ||
| 253 | return ValidationResult::InvalidGender; | ||
| 254 | } | ||
| 255 | if (GetHeight() > MaxHeight) { | ||
| 256 | return ValidationResult::InvalidHeight; | ||
| 257 | } | ||
| 258 | if (GetBuild() > MaxBuild) { | ||
| 259 | return ValidationResult::InvalidBuild; | ||
| 260 | } | ||
| 261 | if (GetType() > MaxType) { | ||
| 262 | return ValidationResult::InvalidType; | ||
| 263 | } | ||
| 264 | if (GetRegionMove() > MaxRegionMove) { | ||
| 265 | return ValidationResult::InvalidRegionMove; | ||
| 266 | } | ||
| 267 | if (GetFacelineType() > FacelineType::Max) { | ||
| 268 | return ValidationResult::InvalidFacelineType; | ||
| 269 | } | ||
| 270 | if (GetFacelineColor() > FacelineColor::Max) { | ||
| 271 | return ValidationResult::InvalidFacelineColor; | ||
| 272 | } | ||
| 273 | if (GetFacelineWrinkle() > FacelineWrinkle::Max) { | ||
| 274 | return ValidationResult::InvalidFacelineWrinkle; | ||
| 275 | } | ||
| 276 | if (GetFacelineMake() > FacelineMake::Max) { | ||
| 277 | return ValidationResult::InvalidFacelineMake; | ||
| 278 | } | ||
| 279 | if (GetHairType() > HairType::Max) { | ||
| 280 | return ValidationResult::InvalidHairType; | ||
| 281 | } | ||
| 282 | if (GetHairColor() > CommonColor::Max) { | ||
| 283 | return ValidationResult::InvalidHairColor; | ||
| 284 | } | ||
| 285 | if (GetHairFlip() > HairFlip::Max) { | ||
| 286 | return ValidationResult::InvalidHairFlip; | ||
| 287 | } | ||
| 288 | if (GetEyeType() > EyeType::Max) { | ||
| 289 | return ValidationResult::InvalidEyeType; | ||
| 290 | } | ||
| 291 | if (GetEyeColor() > CommonColor::Max) { | ||
| 292 | return ValidationResult::InvalidEyeColor; | ||
| 293 | } | ||
| 294 | if (GetEyeScale() > MaxEyeScale) { | ||
| 295 | return ValidationResult::InvalidEyeScale; | ||
| 296 | } | ||
| 297 | if (GetEyeAspect() > MaxEyeAspect) { | ||
| 298 | return ValidationResult::InvalidEyeAspect; | ||
| 299 | } | ||
| 300 | if (GetEyeRotate() > MaxEyeRotate) { | ||
| 301 | return ValidationResult::InvalidEyeRotate; | ||
| 302 | } | ||
| 303 | if (GetEyeX() > MaxEyeX) { | ||
| 304 | return ValidationResult::InvalidEyeX; | ||
| 305 | } | ||
| 306 | if (GetEyeY() > MaxEyeY) { | ||
| 307 | return ValidationResult::InvalidEyeY; | ||
| 308 | } | ||
| 309 | if (GetEyebrowType() > EyebrowType::Max) { | ||
| 310 | return ValidationResult::InvalidEyebrowType; | ||
| 311 | } | ||
| 312 | if (GetEyebrowColor() > CommonColor::Max) { | ||
| 313 | return ValidationResult::InvalidEyebrowColor; | ||
| 314 | } | ||
| 315 | if (GetEyebrowScale() > MaxEyebrowScale) { | ||
| 316 | return ValidationResult::InvalidEyebrowScale; | ||
| 317 | } | ||
| 318 | if (GetEyebrowAspect() > MaxEyebrowAspect) { | ||
| 319 | return ValidationResult::InvalidEyebrowAspect; | ||
| 320 | } | ||
| 321 | if (GetEyebrowRotate() > MaxEyebrowRotate) { | ||
| 322 | return ValidationResult::InvalidEyebrowRotate; | ||
| 323 | } | ||
| 324 | if (GetEyebrowX() > MaxEyebrowX) { | ||
| 325 | return ValidationResult::InvalidEyebrowX; | ||
| 326 | } | ||
| 327 | if (GetEyebrowY() > MaxEyebrowY) { | ||
| 328 | return ValidationResult::InvalidEyebrowY; | ||
| 329 | } | ||
| 330 | if (GetNoseType() > NoseType::Max) { | ||
| 331 | return ValidationResult::InvalidNoseType; | ||
| 332 | } | ||
| 333 | if (GetNoseScale() > MaxNoseScale) { | ||
| 334 | return ValidationResult::InvalidNoseScale; | ||
| 335 | } | ||
| 336 | if (GetNoseY() > MaxNoseY) { | ||
| 337 | return ValidationResult::InvalidNoseY; | ||
| 338 | } | ||
| 339 | if (GetMouthType() > MouthType::Max) { | ||
| 340 | return ValidationResult::InvalidMouthType; | ||
| 341 | } | ||
| 342 | if (GetMouthColor() > CommonColor::Max) { | ||
| 343 | return ValidationResult::InvalidMouthColor; | ||
| 344 | } | ||
| 345 | if (GetMouthScale() > MaxMouthScale) { | ||
| 346 | return ValidationResult::InvalidMouthScale; | ||
| 347 | } | ||
| 348 | if (GetMouthAspect() > MaxMoutAspect) { | ||
| 349 | return ValidationResult::InvalidMouthAspect; | ||
| 350 | } | ||
| 351 | if (GetMouthY() > MaxMouthY) { | ||
| 352 | return ValidationResult::InvalidMouthY; | ||
| 353 | } | ||
| 354 | if (GetBeardColor() > CommonColor::Max) { | ||
| 355 | return ValidationResult::InvalidBeardColor; | ||
| 356 | } | ||
| 357 | if (GetBeardType() > BeardType::Max) { | ||
| 358 | return ValidationResult::InvalidBeardType; | ||
| 359 | } | ||
| 360 | if (GetMustacheType() > MustacheType::Max) { | ||
| 361 | return ValidationResult::InvalidMustacheType; | ||
| 362 | } | ||
| 363 | if (GetMustacheScale() > MaxMustacheScale) { | ||
| 364 | return ValidationResult::InvalidMustacheScale; | ||
| 365 | } | ||
| 366 | if (GetMustacheY() > MaxMustacheY) { | ||
| 367 | return ValidationResult::InvalidMustacheY; | ||
| 368 | } | ||
| 369 | if (GetGlassType() > GlassType::Max) { | ||
| 370 | return ValidationResult::InvalidGlassType; | ||
| 371 | } | ||
| 372 | if (GetGlassColor() > CommonColor::Max) { | ||
| 373 | return ValidationResult::InvalidGlassColor; | ||
| 374 | } | ||
| 375 | if (GetGlassScale() > MaxGlassScale) { | ||
| 376 | return ValidationResult::InvalidGlassScale; | ||
| 377 | } | ||
| 378 | if (GetGlassY() > MaxGlassY) { | ||
| 379 | return ValidationResult::InvalidGlassY; | ||
| 380 | } | ||
| 381 | if (GetMoleType() > MoleType::Max) { | ||
| 382 | return ValidationResult::InvalidMoleType; | ||
| 383 | } | ||
| 384 | if (GetMoleScale() > MaxMoleScale) { | ||
| 385 | return ValidationResult::InvalidMoleScale; | ||
| 386 | } | ||
| 387 | if (GetMoleX() > MaxMoleX) { | ||
| 388 | return ValidationResult::InvalidMoleX; | ||
| 389 | } | ||
| 390 | if (GetMoleY() > MaxMoleY) { | ||
| 391 | return ValidationResult::InvalidMoleY; | ||
| 392 | } | ||
| 393 | return ValidationResult::NoErrors; | ||
| 191 | } | 394 | } |
| 192 | 395 | ||
| 193 | void CoreData::SetFontRegion(FontRegion value) { | 396 | void CoreData::SetFontRegion(FontRegion value) { |
| @@ -314,8 +517,8 @@ void CoreData::SetNoseY(u8 value) { | |||
| 314 | data.nose_y.Assign(value); | 517 | data.nose_y.Assign(value); |
| 315 | } | 518 | } |
| 316 | 519 | ||
| 317 | void CoreData::SetMouthType(u8 value) { | 520 | void CoreData::SetMouthType(MouthType value) { |
| 318 | data.mouth_type.Assign(value); | 521 | data.mouth_type.Assign(static_cast<u32>(value)); |
| 319 | } | 522 | } |
| 320 | 523 | ||
| 321 | void CoreData::SetMouthColor(CommonColor value) { | 524 | void CoreData::SetMouthColor(CommonColor value) { |
diff --git a/src/core/hle/service/mii/types/core_data.h b/src/core/hle/service/mii/types/core_data.h index cebcd2ee4..e6398f68f 100644 --- a/src/core/hle/service/mii/types/core_data.h +++ b/src/core/hle/service/mii/types/core_data.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "core/hle/service/mii/mii_types.h" | 6 | #include "core/hle/service/mii/mii_types.h" |
| 7 | 7 | ||
| 8 | namespace Service::Mii { | 8 | namespace Service::Mii { |
| 9 | class CharInfo; | ||
| 9 | 10 | ||
| 10 | struct StoreDataBitFields { | 11 | struct StoreDataBitFields { |
| 11 | union { | 12 | union { |
| @@ -100,8 +101,9 @@ class CoreData { | |||
| 100 | public: | 101 | public: |
| 101 | void SetDefault(); | 102 | void SetDefault(); |
| 102 | void BuildRandom(Age age, Gender gender, Race race); | 103 | void BuildRandom(Age age, Gender gender, Race race); |
| 104 | void BuildFromCharInfo(const CharInfo& char_info); | ||
| 103 | 105 | ||
| 104 | u32 IsValid() const; | 106 | ValidationResult IsValid() const; |
| 105 | 107 | ||
| 106 | void SetFontRegion(FontRegion value); | 108 | void SetFontRegion(FontRegion value); |
| 107 | void SetFavoriteColor(FavoriteColor value); | 109 | void SetFavoriteColor(FavoriteColor value); |
| @@ -134,7 +136,7 @@ public: | |||
| 134 | void SetNoseType(NoseType value); | 136 | void SetNoseType(NoseType value); |
| 135 | void SetNoseScale(u8 value); | 137 | void SetNoseScale(u8 value); |
| 136 | void SetNoseY(u8 value); | 138 | void SetNoseY(u8 value); |
| 137 | void SetMouthType(u8 value); | 139 | void SetMouthType(MouthType value); |
| 138 | void SetMouthColor(CommonColor value); | 140 | void SetMouthColor(CommonColor value); |
| 139 | void SetMouthScale(u8 value); | 141 | void SetMouthScale(u8 value); |
| 140 | void SetMouthAspect(u8 value); | 142 | void SetMouthAspect(u8 value); |
diff --git a/src/core/hle/service/mii/types/store_data.cpp b/src/core/hle/service/mii/types/store_data.cpp index 8fce636c7..127221fdb 100644 --- a/src/core/hle/service/mii/types/store_data.cpp +++ b/src/core/hle/service/mii/types/store_data.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/mii/mii_result.h" | ||
| 4 | #include "core/hle/service/mii/mii_util.h" | 5 | #include "core/hle/service/mii/mii_util.h" |
| 5 | #include "core/hle/service/mii/types/raw_data.h" | 6 | #include "core/hle/service/mii/types/raw_data.h" |
| 6 | #include "core/hle/service/mii/types/store_data.h" | 7 | #include "core/hle/service/mii/types/store_data.h" |
| @@ -35,13 +36,13 @@ void StoreData::BuildDefault(u32 mii_index) { | |||
| 35 | core_data.SetEyebrowAspect(static_cast<u8>(default_mii.eyebrow_aspect)); | 36 | core_data.SetEyebrowAspect(static_cast<u8>(default_mii.eyebrow_aspect)); |
| 36 | core_data.SetEyebrowRotate(static_cast<u8>(default_mii.eyebrow_rotate)); | 37 | core_data.SetEyebrowRotate(static_cast<u8>(default_mii.eyebrow_rotate)); |
| 37 | core_data.SetEyebrowX(static_cast<u8>(default_mii.eyebrow_x)); | 38 | core_data.SetEyebrowX(static_cast<u8>(default_mii.eyebrow_x)); |
| 38 | core_data.SetEyebrowY(static_cast<u8>(default_mii.eyebrow_y)); | 39 | core_data.SetEyebrowY(static_cast<u8>(default_mii.eyebrow_y - 3)); |
| 39 | 40 | ||
| 40 | core_data.SetNoseType(static_cast<NoseType>(default_mii.nose_type)); | 41 | core_data.SetNoseType(static_cast<NoseType>(default_mii.nose_type)); |
| 41 | core_data.SetNoseScale(static_cast<u8>(default_mii.nose_scale)); | 42 | core_data.SetNoseScale(static_cast<u8>(default_mii.nose_scale)); |
| 42 | core_data.SetNoseY(static_cast<u8>(default_mii.nose_y)); | 43 | core_data.SetNoseY(static_cast<u8>(default_mii.nose_y)); |
| 43 | 44 | ||
| 44 | core_data.SetMouthType(static_cast<u8>(default_mii.mouth_type)); | 45 | core_data.SetMouthType(static_cast<MouthType>(default_mii.mouth_type)); |
| 45 | core_data.SetMouthColor( | 46 | core_data.SetMouthColor( |
| 46 | RawData::GetMouthColorFromVer3(static_cast<u8>(default_mii.mouth_color))); | 47 | RawData::GetMouthColorFromVer3(static_cast<u8>(default_mii.mouth_color))); |
| 47 | core_data.SetMouthScale(static_cast<u8>(default_mii.mouth_scale)); | 48 | core_data.SetMouthScale(static_cast<u8>(default_mii.mouth_scale)); |
| @@ -75,10 +76,8 @@ void StoreData::BuildDefault(u32 mii_index) { | |||
| 75 | core_data.SetType(static_cast<u8>(default_mii.type)); | 76 | core_data.SetType(static_cast<u8>(default_mii.type)); |
| 76 | core_data.SetNickname(default_mii.nickname); | 77 | core_data.SetNickname(default_mii.nickname); |
| 77 | 78 | ||
| 78 | const auto device_id = MiiUtil::GetDeviceId(); | ||
| 79 | create_id = MiiUtil::MakeCreateId(); | 79 | create_id = MiiUtil::MakeCreateId(); |
| 80 | device_crc = MiiUtil::CalculateCrc16(&device_id, sizeof(Common::UUID)); | 80 | SetChecksum(); |
| 81 | data_crc = MiiUtil::CalculateCrc16(&core_data, sizeof(CoreData)); | ||
| 82 | } | 81 | } |
| 83 | 82 | ||
| 84 | void StoreData::BuildBase(Gender gender) { | 83 | void StoreData::BuildBase(Gender gender) { |
| @@ -109,13 +108,13 @@ void StoreData::BuildBase(Gender gender) { | |||
| 109 | core_data.SetEyebrowAspect(static_cast<u8>(default_mii.eyebrow_aspect)); | 108 | core_data.SetEyebrowAspect(static_cast<u8>(default_mii.eyebrow_aspect)); |
| 110 | core_data.SetEyebrowRotate(static_cast<u8>(default_mii.eyebrow_rotate)); | 109 | core_data.SetEyebrowRotate(static_cast<u8>(default_mii.eyebrow_rotate)); |
| 111 | core_data.SetEyebrowX(static_cast<u8>(default_mii.eyebrow_x)); | 110 | core_data.SetEyebrowX(static_cast<u8>(default_mii.eyebrow_x)); |
| 112 | core_data.SetEyebrowY(static_cast<u8>(default_mii.eyebrow_y)); | 111 | core_data.SetEyebrowY(static_cast<u8>(default_mii.eyebrow_y - 3)); |
| 113 | 112 | ||
| 114 | core_data.SetNoseType(static_cast<NoseType>(default_mii.nose_type)); | 113 | core_data.SetNoseType(static_cast<NoseType>(default_mii.nose_type)); |
| 115 | core_data.SetNoseScale(static_cast<u8>(default_mii.nose_scale)); | 114 | core_data.SetNoseScale(static_cast<u8>(default_mii.nose_scale)); |
| 116 | core_data.SetNoseY(static_cast<u8>(default_mii.nose_y)); | 115 | core_data.SetNoseY(static_cast<u8>(default_mii.nose_y)); |
| 117 | 116 | ||
| 118 | core_data.SetMouthType(static_cast<u8>(default_mii.mouth_type)); | 117 | core_data.SetMouthType(static_cast<MouthType>(default_mii.mouth_type)); |
| 119 | core_data.SetMouthColor( | 118 | core_data.SetMouthColor( |
| 120 | RawData::GetMouthColorFromVer3(static_cast<u8>(default_mii.mouth_color))); | 119 | RawData::GetMouthColorFromVer3(static_cast<u8>(default_mii.mouth_color))); |
| 121 | core_data.SetMouthScale(static_cast<u8>(default_mii.mouth_scale)); | 120 | core_data.SetMouthScale(static_cast<u8>(default_mii.mouth_scale)); |
| @@ -149,37 +148,51 @@ void StoreData::BuildBase(Gender gender) { | |||
| 149 | core_data.SetType(static_cast<u8>(default_mii.type)); | 148 | core_data.SetType(static_cast<u8>(default_mii.type)); |
| 150 | core_data.SetNickname(default_mii.nickname); | 149 | core_data.SetNickname(default_mii.nickname); |
| 151 | 150 | ||
| 152 | const auto device_id = MiiUtil::GetDeviceId(); | ||
| 153 | create_id = MiiUtil::MakeCreateId(); | 151 | create_id = MiiUtil::MakeCreateId(); |
| 154 | device_crc = MiiUtil::CalculateCrc16(&device_id, sizeof(Common::UUID)); | 152 | SetChecksum(); |
| 155 | data_crc = MiiUtil::CalculateCrc16(&core_data, sizeof(CoreData)); | ||
| 156 | } | 153 | } |
| 157 | 154 | ||
| 158 | void StoreData::BuildRandom(Age age, Gender gender, Race race) { | 155 | void StoreData::BuildRandom(Age age, Gender gender, Race race) { |
| 159 | core_data.BuildRandom(age, gender, race); | 156 | core_data.BuildRandom(age, gender, race); |
| 160 | const auto device_id = MiiUtil::GetDeviceId(); | ||
| 161 | create_id = MiiUtil::MakeCreateId(); | 157 | create_id = MiiUtil::MakeCreateId(); |
| 162 | device_crc = MiiUtil::CalculateCrc16(&device_id, sizeof(Common::UUID)); | 158 | SetChecksum(); |
| 163 | data_crc = MiiUtil::CalculateCrc16(&core_data, sizeof(CoreData)); | ||
| 164 | } | 159 | } |
| 165 | 160 | ||
| 166 | void StoreData::SetInvalidName() { | 161 | void StoreData::BuildWithCharInfo(const CharInfo& char_info) { |
| 167 | const auto& invalid_name = core_data.GetInvalidNickname(); | 162 | core_data.BuildFromCharInfo(char_info); |
| 163 | create_id = MiiUtil::MakeCreateId(); | ||
| 164 | SetChecksum(); | ||
| 165 | } | ||
| 166 | |||
| 167 | void StoreData::BuildWithCoreData(const CoreData& in_core_data) { | ||
| 168 | core_data = in_core_data; | ||
| 169 | create_id = MiiUtil::MakeCreateId(); | ||
| 170 | SetChecksum(); | ||
| 171 | } | ||
| 172 | |||
| 173 | Result StoreData::Restore() { | ||
| 174 | // TODO: Implement this | ||
| 175 | return ResultNotUpdated; | ||
| 176 | } | ||
| 177 | |||
| 178 | ValidationResult StoreData::IsValid() const { | ||
| 179 | if (core_data.IsValid() != ValidationResult::NoErrors) { | ||
| 180 | return core_data.IsValid(); | ||
| 181 | } | ||
| 182 | if (data_crc != MiiUtil::CalculateCrc16(&core_data, sizeof(CoreData) + sizeof(Common::UUID))) { | ||
| 183 | return ValidationResult::InvalidChecksum; | ||
| 184 | } | ||
| 168 | const auto device_id = MiiUtil::GetDeviceId(); | 185 | const auto device_id = MiiUtil::GetDeviceId(); |
| 169 | core_data.SetNickname(invalid_name); | 186 | if (device_crc != MiiUtil::CalculateDeviceCrc16(device_id, sizeof(StoreData))) { |
| 170 | device_crc = MiiUtil::CalculateCrc16(&device_id, sizeof(Common::UUID)); | 187 | return ValidationResult::InvalidChecksum; |
| 171 | data_crc = MiiUtil::CalculateCrc16(&core_data, sizeof(CoreData)); | 188 | } |
| 189 | return ValidationResult::NoErrors; | ||
| 172 | } | 190 | } |
| 173 | 191 | ||
| 174 | bool StoreData::IsSpecial() const { | 192 | bool StoreData::IsSpecial() const { |
| 175 | return GetType() == 1; | 193 | return GetType() == 1; |
| 176 | } | 194 | } |
| 177 | 195 | ||
| 178 | u32 StoreData::IsValid() const { | ||
| 179 | // TODO: complete this | ||
| 180 | return 0; | ||
| 181 | } | ||
| 182 | |||
| 183 | void StoreData::SetFontRegion(FontRegion value) { | 196 | void StoreData::SetFontRegion(FontRegion value) { |
| 184 | core_data.SetFontRegion(value); | 197 | core_data.SetFontRegion(value); |
| 185 | } | 198 | } |
| @@ -304,7 +317,7 @@ void StoreData::SetNoseY(u8 value) { | |||
| 304 | core_data.SetNoseY(value); | 317 | core_data.SetNoseY(value); |
| 305 | } | 318 | } |
| 306 | 319 | ||
| 307 | void StoreData::SetMouthType(u8 value) { | 320 | void StoreData::SetMouthType(MouthType value) { |
| 308 | core_data.SetMouthType(value); | 321 | core_data.SetMouthType(value); |
| 309 | } | 322 | } |
| 310 | 323 | ||
| @@ -380,6 +393,26 @@ void StoreData::SetNickname(Nickname value) { | |||
| 380 | core_data.SetNickname(value); | 393 | core_data.SetNickname(value); |
| 381 | } | 394 | } |
| 382 | 395 | ||
| 396 | void StoreData::SetInvalidName() { | ||
| 397 | const auto& invalid_name = core_data.GetInvalidNickname(); | ||
| 398 | core_data.SetNickname(invalid_name); | ||
| 399 | SetChecksum(); | ||
| 400 | } | ||
| 401 | |||
| 402 | void StoreData::SetChecksum() { | ||
| 403 | SetDataChecksum(); | ||
| 404 | SetDeviceChecksum(); | ||
| 405 | } | ||
| 406 | |||
| 407 | void StoreData::SetDataChecksum() { | ||
| 408 | data_crc = MiiUtil::CalculateCrc16(&core_data, sizeof(CoreData) + sizeof(Common::UUID)); | ||
| 409 | } | ||
| 410 | |||
| 411 | void StoreData::SetDeviceChecksum() { | ||
| 412 | const auto device_id = MiiUtil::GetDeviceId(); | ||
| 413 | device_crc = MiiUtil::CalculateDeviceCrc16(device_id, sizeof(StoreData)); | ||
| 414 | } | ||
| 415 | |||
| 383 | Common::UUID StoreData::GetCreateId() const { | 416 | Common::UUID StoreData::GetCreateId() const { |
| 384 | return create_id; | 417 | return create_id; |
| 385 | } | 418 | } |
| @@ -585,7 +618,7 @@ Nickname StoreData::GetNickname() const { | |||
| 585 | } | 618 | } |
| 586 | 619 | ||
| 587 | bool StoreData::operator==(const StoreData& data) { | 620 | bool StoreData::operator==(const StoreData& data) { |
| 588 | bool is_identical = data.core_data.IsValid() == 0; | 621 | bool is_identical = data.core_data.IsValid() == ValidationResult::NoErrors; |
| 589 | is_identical &= core_data.GetNickname().data == data.core_data.GetNickname().data; | 622 | is_identical &= core_data.GetNickname().data == data.core_data.GetNickname().data; |
| 590 | is_identical &= GetCreateId() == data.GetCreateId(); | 623 | is_identical &= GetCreateId() == data.GetCreateId(); |
| 591 | is_identical &= GetFontRegion() == data.GetFontRegion(); | 624 | is_identical &= GetFontRegion() == data.GetFontRegion(); |
diff --git a/src/core/hle/service/mii/types/store_data.h b/src/core/hle/service/mii/types/store_data.h index 224c32cf8..38f534d26 100644 --- a/src/core/hle/service/mii/types/store_data.h +++ b/src/core/hle/service/mii/types/store_data.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/result.h" | ||
| 6 | #include "core/hle/service/mii/mii_types.h" | 7 | #include "core/hle/service/mii/mii_types.h" |
| 7 | #include "core/hle/service/mii/types/core_data.h" | 8 | #include "core/hle/service/mii/types/core_data.h" |
| 8 | 9 | ||
| @@ -10,17 +11,16 @@ namespace Service::Mii { | |||
| 10 | 11 | ||
| 11 | class StoreData { | 12 | class StoreData { |
| 12 | public: | 13 | public: |
| 13 | // nn::mii::detail::StoreDataRaw::BuildDefault | ||
| 14 | void BuildDefault(u32 mii_index); | 14 | void BuildDefault(u32 mii_index); |
| 15 | // nn::mii::detail::StoreDataRaw::BuildDefault | ||
| 16 | |||
| 17 | void BuildBase(Gender gender); | 15 | void BuildBase(Gender gender); |
| 18 | // nn::mii::detail::StoreDataRaw::BuildRandom | ||
| 19 | void BuildRandom(Age age, Gender gender, Race race); | 16 | void BuildRandom(Age age, Gender gender, Race race); |
| 17 | void BuildWithCharInfo(const CharInfo& char_info); | ||
| 18 | void BuildWithCoreData(const CoreData& in_core_data); | ||
| 19 | Result Restore(); | ||
| 20 | 20 | ||
| 21 | bool IsSpecial() const; | 21 | ValidationResult IsValid() const; |
| 22 | 22 | ||
| 23 | u32 IsValid() const; | 23 | bool IsSpecial() const; |
| 24 | 24 | ||
| 25 | void SetFontRegion(FontRegion value); | 25 | void SetFontRegion(FontRegion value); |
| 26 | void SetFavoriteColor(FavoriteColor value); | 26 | void SetFavoriteColor(FavoriteColor value); |
| @@ -53,7 +53,7 @@ public: | |||
| 53 | void SetNoseType(NoseType value); | 53 | void SetNoseType(NoseType value); |
| 54 | void SetNoseScale(u8 value); | 54 | void SetNoseScale(u8 value); |
| 55 | void SetNoseY(u8 value); | 55 | void SetNoseY(u8 value); |
| 56 | void SetMouthType(u8 value); | 56 | void SetMouthType(MouthType value); |
| 57 | void SetMouthColor(CommonColor value); | 57 | void SetMouthColor(CommonColor value); |
| 58 | void SetMouthScale(u8 value); | 58 | void SetMouthScale(u8 value); |
| 59 | void SetMouthAspect(u8 value); | 59 | void SetMouthAspect(u8 value); |
| @@ -73,6 +73,9 @@ public: | |||
| 73 | void SetMoleY(u8 value); | 73 | void SetMoleY(u8 value); |
| 74 | void SetNickname(Nickname nickname); | 74 | void SetNickname(Nickname nickname); |
| 75 | void SetInvalidName(); | 75 | void SetInvalidName(); |
| 76 | void SetChecksum(); | ||
| 77 | void SetDataChecksum(); | ||
| 78 | void SetDeviceChecksum(); | ||
| 76 | 79 | ||
| 77 | Common::UUID GetCreateId() const; | 80 | Common::UUID GetCreateId() const; |
| 78 | FontRegion GetFontRegion() const; | 81 | FontRegion GetFontRegion() const; |
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 1c28e0b1b..a019cc9f7 100644 --- a/src/core/hle/service/mii/types/ver3_store_data.cpp +++ b/src/core/hle/service/mii/types/ver3_store_data.cpp | |||
| @@ -22,12 +22,6 @@ void NfpStoreDataExtension::SetFromStoreData(const StoreData& store_data) { | |||
| 22 | void Ver3StoreData::BuildToStoreData(StoreData& out_store_data) const { | 22 | void Ver3StoreData::BuildToStoreData(StoreData& out_store_data) const { |
| 23 | out_store_data.BuildBase(Gender::Male); | 23 | out_store_data.BuildBase(Gender::Male); |
| 24 | 24 | ||
| 25 | if (!IsValid()) { | ||
| 26 | return; | ||
| 27 | } | ||
| 28 | |||
| 29 | // TODO: We are ignoring a bunch of data from the mii_v3 | ||
| 30 | |||
| 31 | out_store_data.SetGender(static_cast<Gender>(mii_information.gender.Value())); | 25 | out_store_data.SetGender(static_cast<Gender>(mii_information.gender.Value())); |
| 32 | out_store_data.SetFavoriteColor( | 26 | out_store_data.SetFavoriteColor( |
| 33 | static_cast<FavoriteColor>(mii_information.favorite_color.Value())); | 27 | static_cast<FavoriteColor>(mii_information.favorite_color.Value())); |
| @@ -36,65 +30,71 @@ void Ver3StoreData::BuildToStoreData(StoreData& out_store_data) const { | |||
| 36 | 30 | ||
| 37 | out_store_data.SetNickname(mii_name); | 31 | out_store_data.SetNickname(mii_name); |
| 38 | out_store_data.SetFontRegion( | 32 | out_store_data.SetFontRegion( |
| 39 | static_cast<FontRegion>(static_cast<u8>(region_information.font_region))); | 33 | static_cast<FontRegion>(static_cast<u8>(region_information.font_region.Value()))); |
| 40 | 34 | ||
| 41 | out_store_data.SetFacelineType( | 35 | out_store_data.SetFacelineType( |
| 42 | static_cast<FacelineType>(appearance_bits1.faceline_type.Value())); | 36 | static_cast<FacelineType>(appearance_bits1.faceline_type.Value())); |
| 43 | out_store_data.SetFacelineColor( | 37 | out_store_data.SetFacelineColor( |
| 44 | static_cast<FacelineColor>(appearance_bits1.faceline_color.Value())); | 38 | RawData::GetFacelineColorFromVer3(appearance_bits1.faceline_color.Value())); |
| 45 | out_store_data.SetFacelineWrinkle( | 39 | out_store_data.SetFacelineWrinkle( |
| 46 | static_cast<FacelineWrinkle>(appearance_bits2.faceline_wrinkle.Value())); | 40 | static_cast<FacelineWrinkle>(appearance_bits2.faceline_wrinkle.Value())); |
| 47 | out_store_data.SetFacelineMake( | 41 | out_store_data.SetFacelineMake( |
| 48 | static_cast<FacelineMake>(appearance_bits2.faceline_make.Value())); | 42 | static_cast<FacelineMake>(appearance_bits2.faceline_make.Value())); |
| 49 | 43 | ||
| 50 | out_store_data.SetHairType(static_cast<HairType>(hair_type)); | 44 | out_store_data.SetHairType(static_cast<HairType>(hair_type)); |
| 51 | out_store_data.SetHairColor(static_cast<CommonColor>(appearance_bits3.hair_color.Value())); | 45 | out_store_data.SetHairColor(RawData::GetHairColorFromVer3(appearance_bits3.hair_color.Value())); |
| 52 | out_store_data.SetHairFlip(static_cast<HairFlip>(appearance_bits3.hair_flip.Value())); | 46 | out_store_data.SetHairFlip(static_cast<HairFlip>(appearance_bits3.hair_flip.Value())); |
| 53 | 47 | ||
| 54 | out_store_data.SetEyeType(static_cast<EyeType>(appearance_bits4.eye_type.Value())); | 48 | out_store_data.SetEyeType(static_cast<EyeType>(appearance_bits4.eye_type.Value())); |
| 55 | out_store_data.SetEyeColor(static_cast<CommonColor>(appearance_bits4.eye_color.Value())); | 49 | out_store_data.SetEyeColor(RawData::GetEyeColorFromVer3(appearance_bits4.eye_color.Value())); |
| 56 | out_store_data.SetEyeScale(static_cast<u8>(appearance_bits4.eye_scale)); | 50 | out_store_data.SetEyeScale(static_cast<u8>(appearance_bits4.eye_scale.Value())); |
| 57 | out_store_data.SetEyeAspect(static_cast<u8>(appearance_bits4.eye_aspect)); | 51 | out_store_data.SetEyeAspect(static_cast<u8>(appearance_bits4.eye_aspect.Value())); |
| 58 | out_store_data.SetEyeRotate(static_cast<u8>(appearance_bits4.eye_rotate)); | 52 | out_store_data.SetEyeRotate(static_cast<u8>(appearance_bits4.eye_rotate.Value())); |
| 59 | out_store_data.SetEyeX(static_cast<u8>(appearance_bits4.eye_x)); | 53 | out_store_data.SetEyeX(static_cast<u8>(appearance_bits4.eye_x.Value())); |
| 60 | out_store_data.SetEyeY(static_cast<u8>(appearance_bits4.eye_y)); | 54 | out_store_data.SetEyeY(static_cast<u8>(appearance_bits4.eye_y.Value())); |
| 61 | 55 | ||
| 62 | out_store_data.SetEyebrowType(static_cast<EyebrowType>(appearance_bits5.eyebrow_type.Value())); | 56 | out_store_data.SetEyebrowType(static_cast<EyebrowType>(appearance_bits5.eyebrow_type.Value())); |
| 63 | out_store_data.SetEyebrowColor( | 57 | out_store_data.SetEyebrowColor( |
| 64 | static_cast<CommonColor>(appearance_bits5.eyebrow_color.Value())); | 58 | RawData::GetHairColorFromVer3(appearance_bits5.eyebrow_color.Value())); |
| 65 | out_store_data.SetEyebrowScale(static_cast<u8>(appearance_bits5.eyebrow_scale)); | 59 | out_store_data.SetEyebrowScale(static_cast<u8>(appearance_bits5.eyebrow_scale.Value())); |
| 66 | out_store_data.SetEyebrowAspect(static_cast<u8>(appearance_bits5.eyebrow_aspect)); | 60 | out_store_data.SetEyebrowAspect(static_cast<u8>(appearance_bits5.eyebrow_aspect.Value())); |
| 67 | out_store_data.SetEyebrowRotate(static_cast<u8>(appearance_bits5.eyebrow_rotate)); | 61 | out_store_data.SetEyebrowRotate(static_cast<u8>(appearance_bits5.eyebrow_rotate.Value())); |
| 68 | out_store_data.SetEyebrowX(static_cast<u8>(appearance_bits5.eyebrow_x)); | 62 | out_store_data.SetEyebrowX(static_cast<u8>(appearance_bits5.eyebrow_x.Value())); |
| 69 | out_store_data.SetEyebrowY(static_cast<u8>(appearance_bits5.eyebrow_y)); | 63 | out_store_data.SetEyebrowY(static_cast<u8>(appearance_bits5.eyebrow_y.Value() - 3)); |
| 70 | 64 | ||
| 71 | out_store_data.SetNoseType(static_cast<NoseType>(appearance_bits6.nose_type.Value())); | 65 | out_store_data.SetNoseType(static_cast<NoseType>(appearance_bits6.nose_type.Value())); |
| 72 | out_store_data.SetNoseScale(static_cast<u8>(appearance_bits6.nose_scale)); | 66 | out_store_data.SetNoseScale(static_cast<u8>(appearance_bits6.nose_scale.Value())); |
| 73 | out_store_data.SetNoseY(static_cast<u8>(appearance_bits6.nose_y)); | 67 | out_store_data.SetNoseY(static_cast<u8>(appearance_bits6.nose_y.Value())); |
| 74 | 68 | ||
| 75 | out_store_data.SetMouthType(static_cast<u8>(appearance_bits7.mouth_type)); | 69 | out_store_data.SetMouthType(static_cast<MouthType>(appearance_bits7.mouth_type.Value())); |
| 76 | out_store_data.SetMouthColor(static_cast<CommonColor>(appearance_bits7.mouth_color.Value())); | 70 | out_store_data.SetMouthColor( |
| 77 | out_store_data.SetMouthScale(static_cast<u8>(appearance_bits7.mouth_scale)); | 71 | RawData::GetMouthColorFromVer3(appearance_bits7.mouth_color.Value())); |
| 78 | out_store_data.SetMouthAspect(static_cast<u8>(appearance_bits7.mouth_aspect)); | 72 | out_store_data.SetMouthScale(static_cast<u8>(appearance_bits7.mouth_scale.Value())); |
| 79 | out_store_data.SetMouthY(static_cast<u8>(appearance_bits8.mouth_y)); | 73 | out_store_data.SetMouthAspect(static_cast<u8>(appearance_bits7.mouth_aspect.Value())); |
| 74 | out_store_data.SetMouthY(static_cast<u8>(appearance_bits8.mouth_y.Value())); | ||
| 80 | 75 | ||
| 81 | out_store_data.SetMustacheType( | 76 | out_store_data.SetMustacheType( |
| 82 | static_cast<MustacheType>(appearance_bits8.mustache_type.Value())); | 77 | static_cast<MustacheType>(appearance_bits8.mustache_type.Value())); |
| 83 | out_store_data.SetMustacheScale(static_cast<u8>(appearance_bits9.mustache_scale)); | 78 | out_store_data.SetMustacheScale(static_cast<u8>(appearance_bits9.mustache_scale.Value())); |
| 84 | out_store_data.SetMustacheY(static_cast<u8>(appearance_bits9.mustache_y)); | 79 | out_store_data.SetMustacheY(static_cast<u8>(appearance_bits9.mustache_y.Value())); |
| 85 | 80 | ||
| 86 | out_store_data.SetBeardType(static_cast<BeardType>(appearance_bits9.beard_type.Value())); | 81 | out_store_data.SetBeardType(static_cast<BeardType>(appearance_bits9.beard_type.Value())); |
| 87 | out_store_data.SetBeardColor(static_cast<CommonColor>(appearance_bits9.beard_color.Value())); | 82 | out_store_data.SetBeardColor( |
| 83 | RawData::GetHairColorFromVer3(appearance_bits9.beard_color.Value())); | ||
| 88 | 84 | ||
| 85 | // Glass type is compatible as it is. It doesn't need a table | ||
| 89 | out_store_data.SetGlassType(static_cast<GlassType>(appearance_bits10.glass_type.Value())); | 86 | out_store_data.SetGlassType(static_cast<GlassType>(appearance_bits10.glass_type.Value())); |
| 90 | out_store_data.SetGlassColor(static_cast<CommonColor>(appearance_bits10.glass_color.Value())); | 87 | out_store_data.SetGlassColor( |
| 91 | out_store_data.SetGlassScale(static_cast<u8>(appearance_bits10.glass_scale)); | 88 | RawData::GetGlassColorFromVer3(appearance_bits10.glass_color.Value())); |
| 92 | out_store_data.SetGlassY(static_cast<u8>(appearance_bits10.glass_y)); | 89 | out_store_data.SetGlassScale(static_cast<u8>(appearance_bits10.glass_scale.Value())); |
| 90 | out_store_data.SetGlassY(static_cast<u8>(appearance_bits10.glass_y.Value())); | ||
| 93 | 91 | ||
| 94 | out_store_data.SetMoleType(static_cast<MoleType>(appearance_bits11.mole_type.Value())); | 92 | out_store_data.SetMoleType(static_cast<MoleType>(appearance_bits11.mole_type.Value())); |
| 95 | out_store_data.SetMoleScale(static_cast<u8>(appearance_bits11.mole_scale)); | 93 | out_store_data.SetMoleScale(static_cast<u8>(appearance_bits11.mole_scale.Value())); |
| 96 | out_store_data.SetMoleX(static_cast<u8>(appearance_bits11.mole_x)); | 94 | out_store_data.SetMoleX(static_cast<u8>(appearance_bits11.mole_x.Value())); |
| 97 | out_store_data.SetMoleY(static_cast<u8>(appearance_bits11.mole_y)); | 95 | out_store_data.SetMoleY(static_cast<u8>(appearance_bits11.mole_y.Value())); |
| 96 | |||
| 97 | out_store_data.SetChecksum(); | ||
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | void Ver3StoreData::BuildFromStoreData(const StoreData& store_data) { | 100 | void Ver3StoreData::BuildFromStoreData(const StoreData& store_data) { |
| @@ -220,7 +220,7 @@ u32 Ver3StoreData::IsValid() const { | |||
| 220 | 220 | ||
| 221 | is_valid = is_valid && (appearance_bits8.mustache_type <= static_cast<u8>(MustacheType::Max)); | 221 | is_valid = is_valid && (appearance_bits8.mustache_type <= static_cast<u8>(MustacheType::Max)); |
| 222 | is_valid = is_valid && (appearance_bits9.mustache_scale < MaxMustacheScale); | 222 | is_valid = is_valid && (appearance_bits9.mustache_scale < MaxMustacheScale); |
| 223 | is_valid = is_valid && (appearance_bits9.mustache_y <= MasMustacheY); | 223 | is_valid = is_valid && (appearance_bits9.mustache_y <= MaxMustacheY); |
| 224 | 224 | ||
| 225 | is_valid = is_valid && (appearance_bits9.beard_type <= static_cast<u8>(BeardType::Max)); | 225 | is_valid = is_valid && (appearance_bits9.beard_type <= static_cast<u8>(BeardType::Max)); |
| 226 | is_valid = is_valid && (appearance_bits9.beard_color <= MaxVer3CommonColor); | 226 | is_valid = is_valid && (appearance_bits9.beard_color <= MaxVer3CommonColor); |
| @@ -228,7 +228,7 @@ u32 Ver3StoreData::IsValid() const { | |||
| 228 | is_valid = is_valid && (appearance_bits10.glass_type <= MaxVer3GlassType); | 228 | is_valid = is_valid && (appearance_bits10.glass_type <= MaxVer3GlassType); |
| 229 | is_valid = is_valid && (appearance_bits10.glass_color <= MaxVer3CommonColor - 2); | 229 | is_valid = is_valid && (appearance_bits10.glass_color <= MaxVer3CommonColor - 2); |
| 230 | is_valid = is_valid && (appearance_bits10.glass_scale <= MaxGlassScale); | 230 | is_valid = is_valid && (appearance_bits10.glass_scale <= MaxGlassScale); |
| 231 | is_valid = is_valid && (appearance_bits10.glass_y <= MaxGlassScale); | 231 | is_valid = is_valid && (appearance_bits10.glass_y <= MaxGlassY); |
| 232 | 232 | ||
| 233 | is_valid = is_valid && (appearance_bits11.mole_type <= static_cast<u8>(MoleType::Max)); | 233 | is_valid = is_valid && (appearance_bits11.mole_type <= static_cast<u8>(MoleType::Max)); |
| 234 | is_valid = is_valid && (appearance_bits11.mole_scale <= MaxMoleScale); | 234 | is_valid = is_valid && (appearance_bits11.mole_scale <= MaxMoleScale); |