mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-23 06:10:42 +02:00
mii: Fix BuildRandomStoreData & Cleanup raw_data
Cleaned up mii raw data to reflect the underlying values instead of just a chunk of bytes. Fixed BuildRandomStoreData not actually generating random miis properly. "values" should be a u32, not a u8.
This commit is contained in:
parent
4cd8b2f1f7
commit
5b8bc56e65
@ -21,7 +21,7 @@ namespace {
|
||||
|
||||
constexpr ResultCode ERROR_CANNOT_FIND_ENTRY{ErrorModule::Mii, 4};
|
||||
|
||||
constexpr std::size_t DefaultMiiCount{sizeof(RawData::DefaultMii) / sizeof(DefaultMii)};
|
||||
constexpr std::size_t DefaultMiiCount{RawData::DefaultMii.size()};
|
||||
|
||||
constexpr MiiStoreData::Name DefaultMiiName{u'y', u'u', u'z', u'u'};
|
||||
constexpr std::array<u8, 8> HairColorLookup{8, 1, 2, 3, 4, 5, 6, 7};
|
||||
@ -141,13 +141,6 @@ T GetRandomValue(T max) {
|
||||
return GetRandomValue<T>({}, max);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T GetArrayValue(const u8* data, std::size_t index) {
|
||||
T result{};
|
||||
std::memcpy(&result, &data[index * sizeof(T)], sizeof(T));
|
||||
return result;
|
||||
}
|
||||
|
||||
MiiStoreData BuildRandomStoreData(Age age, Gender gender, Race race, const Common::UUID& user_id) {
|
||||
MiiStoreBitFields bf{};
|
||||
|
||||
@ -193,32 +186,20 @@ MiiStoreData BuildRandomStoreData(Age age, Gender gender, Race race, const Commo
|
||||
const std::size_t index{3 * static_cast<std::size_t>(age) +
|
||||
9 * static_cast<std::size_t>(gender) + static_cast<std::size_t>(race)};
|
||||
|
||||
const auto faceline_type_info{
|
||||
GetArrayValue<RandomMiiData4>(&RawData::RandomMiiFaceline[0], index)};
|
||||
const auto faceline_color_info{GetArrayValue<RandomMiiData3>(
|
||||
RawData::RandomMiiFacelineColor.data(),
|
||||
const auto faceline_type_info{RawData::RandomMiiFaceline.at(index)};
|
||||
const auto faceline_color_info{RawData::RandomMiiFacelineColor.at(
|
||||
3 * static_cast<std::size_t>(gender) + static_cast<std::size_t>(race))};
|
||||
const auto faceline_wrinkle_info{
|
||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiFacelineWrinkle.data(), index)};
|
||||
const auto faceline_makeup_info{
|
||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiFacelineMakeup.data(), index)};
|
||||
const auto hair_type_info{
|
||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiHairType.data(), index)};
|
||||
const auto hair_color_info{GetArrayValue<RandomMiiData3>(RawData::RandomMiiHairColor.data(),
|
||||
3 * static_cast<std::size_t>(race) +
|
||||
static_cast<std::size_t>(age))};
|
||||
const auto eye_type_info{
|
||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiEyeType.data(), index)};
|
||||
const auto eye_color_info{GetArrayValue<RandomMiiData2>(RawData::RandomMiiEyeColor.data(),
|
||||
static_cast<std::size_t>(race))};
|
||||
const auto eyebrow_type_info{
|
||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiEyebrowType.data(), index)};
|
||||
const auto nose_type_info{
|
||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiNoseType.data(), index)};
|
||||
const auto mouth_type_info{
|
||||
GetArrayValue<RandomMiiData4>(RawData::RandomMiiMouthType.data(), index)};
|
||||
const auto glasses_type_info{GetArrayValue<RandomMiiData2>(RawData::RandomMiiGlassType.data(),
|
||||
const auto faceline_wrinkle_info{RawData::RandomMiiFacelineWrinkle.at(index)};
|
||||
const auto faceline_makeup_info{RawData::RandomMiiFacelineMakeup.at(index)};
|
||||
const auto hair_type_info{RawData::RandomMiiHairType.at(index)};
|
||||
const auto hair_color_info{RawData::RandomMiiHairColor.at(3 * static_cast<std::size_t>(race) +
|
||||
static_cast<std::size_t>(age))};
|
||||
const auto eye_type_info{RawData::RandomMiiEyeType.at(index)};
|
||||
const auto eye_color_info{RawData::RandomMiiEyeColor.at(static_cast<std::size_t>(race))};
|
||||
const auto eyebrow_type_info{RawData::RandomMiiEyebrowType.at(index)};
|
||||
const auto nose_type_info{RawData::RandomMiiNoseType.at(index)};
|
||||
const auto mouth_type_info{RawData::RandomMiiMouthType.at(index)};
|
||||
const auto glasses_type_info{RawData::RandomMiiGlassType.at(static_cast<std::size_t>(age))};
|
||||
|
||||
bf.faceline_type.Assign(
|
||||
faceline_type_info.values[GetRandomValue<std::size_t>(faceline_type_info.values_count)]);
|
||||
@ -455,8 +436,7 @@ MiiInfo MiiManager::BuildRandom(Age age, Gender gender, Race race) {
|
||||
}
|
||||
|
||||
MiiInfo MiiManager::BuildDefault(std::size_t index) {
|
||||
return ConvertStoreDataToInfo(BuildDefaultStoreData(
|
||||
GetArrayValue<DefaultMii>(RawData::DefaultMii.data(), index), user_id));
|
||||
return ConvertStoreDataToInfo(BuildDefaultStoreData(RawData::DefaultMii.at(index), user_id));
|
||||
}
|
||||
|
||||
ResultVal<std::vector<MiiInfoElement>> MiiManager::GetDefault(SourceFlag source_flag) {
|
||||
|
@ -233,7 +233,7 @@ struct RandomMiiData4 {
|
||||
Age age{};
|
||||
Race race{};
|
||||
u32 values_count{};
|
||||
std::array<u8, 0xbc> values{};
|
||||
std::array<u32, 47> values{};
|
||||
};
|
||||
static_assert(sizeof(RandomMiiData4) == 0xcc, "RandomMiiData4 has incorrect size.");
|
||||
|
||||
@ -241,14 +241,14 @@ struct RandomMiiData3 {
|
||||
u32 arg_1;
|
||||
u32 arg_2;
|
||||
u32 values_count;
|
||||
std::array<u8, 0xbc> values{};
|
||||
std::array<u32, 47> values{};
|
||||
};
|
||||
static_assert(sizeof(RandomMiiData3) == 0xc8, "RandomMiiData3 has incorrect size.");
|
||||
|
||||
struct RandomMiiData2 {
|
||||
u32 arg_1;
|
||||
u32 values_count;
|
||||
std::array<u8, 0xbc> values{};
|
||||
std::array<u32, 47> values{};
|
||||
};
|
||||
static_assert(sizeof(RandomMiiData2) == 0xc4, "RandomMiiData2 has incorrect size.");
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,21 +7,22 @@
|
||||
#include <array>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/mii/manager.h"
|
||||
|
||||
namespace Service::Mii::RawData {
|
||||
|
||||
extern const std::array<u8, 1728> DefaultMii;
|
||||
extern const std::array<u8, 3672> RandomMiiFaceline;
|
||||
extern const std::array<u8, 1200> RandomMiiFacelineColor;
|
||||
extern const std::array<u8, 3672> RandomMiiFacelineWrinkle;
|
||||
extern const std::array<u8, 3672> RandomMiiFacelineMakeup;
|
||||
extern const std::array<u8, 3672> RandomMiiHairType;
|
||||
extern const std::array<u8, 1800> RandomMiiHairColor;
|
||||
extern const std::array<u8, 3672> RandomMiiEyeType;
|
||||
extern const std::array<u8, 588> RandomMiiEyeColor;
|
||||
extern const std::array<u8, 3672> RandomMiiEyebrowType;
|
||||
extern const std::array<u8, 3672> RandomMiiNoseType;
|
||||
extern const std::array<u8, 3672> RandomMiiMouthType;
|
||||
extern const std::array<u8, 588> RandomMiiGlassType;
|
||||
extern const std::array<Service::Mii::DefaultMii, 8> DefaultMii;
|
||||
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiFaceline;
|
||||
extern const std::array<Service::Mii::RandomMiiData3, 6> RandomMiiFacelineColor;
|
||||
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiFacelineWrinkle;
|
||||
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiFacelineMakeup;
|
||||
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiHairType;
|
||||
extern const std::array<Service::Mii::RandomMiiData3, 9> RandomMiiHairColor;
|
||||
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiEyeType;
|
||||
extern const std::array<Service::Mii::RandomMiiData2, 3> RandomMiiEyeColor;
|
||||
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiEyebrowType;
|
||||
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiNoseType;
|
||||
extern const std::array<Service::Mii::RandomMiiData4, 18> RandomMiiMouthType;
|
||||
extern const std::array<Service::Mii::RandomMiiData2, 3> RandomMiiGlassType;
|
||||
|
||||
} // namespace Service::Mii::RawData
|
||||
|
Loading…
Reference in New Issue
Block a user