forked from suyu/suyu
am: mii_edit: Implement DB operations
This commit is contained in:
parent
9e9cb28471
commit
a57ca3fb66
8 changed files with 139 additions and 73 deletions
|
@ -7,7 +7,9 @@
|
||||||
#include "core/frontend/applets/mii_edit.h"
|
#include "core/frontend/applets/mii_edit.h"
|
||||||
#include "core/hle/service/am/am.h"
|
#include "core/hle/service/am/am.h"
|
||||||
#include "core/hle/service/am/applets/applet_mii_edit.h"
|
#include "core/hle/service/am/applets/applet_mii_edit.h"
|
||||||
|
#include "core/hle/service/mii/mii.h"
|
||||||
#include "core/hle/service/mii/mii_manager.h"
|
#include "core/hle/service/mii/mii_manager.h"
|
||||||
|
#include "core/hle/service/sm/sm.h"
|
||||||
|
|
||||||
namespace Service::AM::Applets {
|
namespace Service::AM::Applets {
|
||||||
|
|
||||||
|
@ -56,6 +58,12 @@ void MiiEdit::Initialize() {
|
||||||
sizeof(MiiEditAppletInputV4));
|
sizeof(MiiEditAppletInputV4));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manager = system.ServiceManager().GetService<Mii::MiiDBModule>("mii:e")->GetMiiManager();
|
||||||
|
if (manager == nullptr) {
|
||||||
|
manager = std::make_shared<Mii::MiiManager>();
|
||||||
|
}
|
||||||
|
manager->Initialize(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MiiEdit::TransactionComplete() const {
|
bool MiiEdit::TransactionComplete() const {
|
||||||
|
@ -78,22 +86,46 @@ void MiiEdit::Execute() {
|
||||||
// This is a default stub for each of the MiiEdit applet modes.
|
// This is a default stub for each of the MiiEdit applet modes.
|
||||||
switch (applet_input_common.applet_mode) {
|
switch (applet_input_common.applet_mode) {
|
||||||
case MiiEditAppletMode::ShowMiiEdit:
|
case MiiEditAppletMode::ShowMiiEdit:
|
||||||
case MiiEditAppletMode::AppendMii:
|
|
||||||
case MiiEditAppletMode::AppendMiiImage:
|
case MiiEditAppletMode::AppendMiiImage:
|
||||||
case MiiEditAppletMode::UpdateMiiImage:
|
case MiiEditAppletMode::UpdateMiiImage:
|
||||||
MiiEditOutput(MiiEditResult::Success, 0);
|
MiiEditOutput(MiiEditResult::Success, 0);
|
||||||
break;
|
break;
|
||||||
case MiiEditAppletMode::CreateMii:
|
case MiiEditAppletMode::AppendMii: {
|
||||||
case MiiEditAppletMode::EditMii: {
|
|
||||||
Mii::CharInfo char_info{};
|
|
||||||
Mii::StoreData store_data{};
|
Mii::StoreData store_data{};
|
||||||
store_data.BuildBase(Mii::Gender::Male);
|
store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All);
|
||||||
char_info.SetFromStoreData(store_data);
|
store_data.SetNickname({u'y', u'u', u'z', u'u'});
|
||||||
|
store_data.SetChecksum();
|
||||||
|
const auto result = manager->AddOrReplace(metadata, store_data);
|
||||||
|
|
||||||
|
if (result.IsError()) {
|
||||||
|
MiiEditOutput(MiiEditResult::Cancel, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 index = manager->FindIndex(store_data.GetCreateId(), false);
|
||||||
|
|
||||||
|
if (index == -1) {
|
||||||
|
MiiEditOutput(MiiEditResult::Cancel, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MiiEditOutput(MiiEditResult::Success, index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MiiEditAppletMode::CreateMii: {
|
||||||
|
Mii::CharInfo char_info{};
|
||||||
|
manager->BuildRandom(char_info, Mii::Age::All, Mii::Gender::All, Mii::Race::All);
|
||||||
|
|
||||||
const MiiEditCharInfo edit_char_info{
|
const MiiEditCharInfo edit_char_info{
|
||||||
.mii_info{applet_input_common.applet_mode == MiiEditAppletMode::EditMii
|
.mii_info{char_info},
|
||||||
? applet_input_v4.char_info.mii_info
|
};
|
||||||
: char_info},
|
|
||||||
|
MiiEditOutputForCharInfoEditing(MiiEditResult::Success, edit_char_info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MiiEditAppletMode::EditMii: {
|
||||||
|
const MiiEditCharInfo edit_char_info{
|
||||||
|
.mii_info{applet_input_v4.char_info.mii_info},
|
||||||
};
|
};
|
||||||
|
|
||||||
MiiEditOutputForCharInfoEditing(MiiEditResult::Success, edit_char_info);
|
MiiEditOutputForCharInfoEditing(MiiEditResult::Success, edit_char_info);
|
||||||
|
|
|
@ -11,6 +11,11 @@ namespace Core {
|
||||||
class System;
|
class System;
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
|
namespace Service::Mii {
|
||||||
|
struct DatabaseSessionMetadata;
|
||||||
|
class MiiManager;
|
||||||
|
} // namespace Service::Mii
|
||||||
|
|
||||||
namespace Service::AM::Applets {
|
namespace Service::AM::Applets {
|
||||||
|
|
||||||
class MiiEdit final : public Applet {
|
class MiiEdit final : public Applet {
|
||||||
|
@ -40,6 +45,8 @@ private:
|
||||||
MiiEditAppletInputV4 applet_input_v4{};
|
MiiEditAppletInputV4 applet_input_v4{};
|
||||||
|
|
||||||
bool is_complete{false};
|
bool is_complete{false};
|
||||||
|
std::shared_ptr<Mii::MiiManager> manager = nullptr;
|
||||||
|
Mii::DatabaseSessionMetadata metadata{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::AM::Applets
|
} // namespace Service::AM::Applets
|
||||||
|
|
|
@ -18,8 +18,10 @@ namespace Service::Mii {
|
||||||
|
|
||||||
class IDatabaseService final : public ServiceFramework<IDatabaseService> {
|
class IDatabaseService final : public ServiceFramework<IDatabaseService> {
|
||||||
public:
|
public:
|
||||||
explicit IDatabaseService(Core::System& system_, bool is_system_)
|
explicit IDatabaseService(Core::System& system_, std::shared_ptr<MiiManager> mii_manager,
|
||||||
: ServiceFramework{system_, "IDatabaseService"}, is_system{is_system_} {
|
bool is_system_)
|
||||||
|
: ServiceFramework{system_, "IDatabaseService"}, manager{mii_manager}, is_system{
|
||||||
|
is_system_} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IDatabaseService::IsUpdated, "IsUpdated"},
|
{0, &IDatabaseService::IsUpdated, "IsUpdated"},
|
||||||
|
@ -54,7 +56,7 @@ public:
|
||||||
|
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
manager.Initialize(metadata);
|
manager->Initialize(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -64,7 +66,7 @@ private:
|
||||||
|
|
||||||
LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag);
|
LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag);
|
||||||
|
|
||||||
const bool is_updated = manager.IsUpdated(metadata, source_flag);
|
const bool is_updated = manager->IsUpdated(metadata, source_flag);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -74,7 +76,7 @@ private:
|
||||||
void IsFullDatabase(HLERequestContext& ctx) {
|
void IsFullDatabase(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
|
||||||
const bool is_full_database = manager.IsFullDatabase();
|
const bool is_full_database = manager->IsFullDatabase();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -85,7 +87,7 @@ private:
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
const auto source_flag{rp.PopRaw<SourceFlag>()};
|
||||||
|
|
||||||
const u32 mii_count = manager.GetCount(metadata, source_flag);
|
const u32 mii_count = manager->GetCount(metadata, source_flag);
|
||||||
|
|
||||||
LOG_DEBUG(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, mii_count);
|
LOG_DEBUG(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, mii_count);
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ private:
|
||||||
|
|
||||||
u32 mii_count{};
|
u32 mii_count{};
|
||||||
std::vector<CharInfoElement> char_info_elements(output_size);
|
std::vector<CharInfoElement> char_info_elements(output_size);
|
||||||
const auto result = manager.Get(metadata, char_info_elements, mii_count, source_flag);
|
const auto result = manager->Get(metadata, char_info_elements, mii_count, source_flag);
|
||||||
|
|
||||||
if (mii_count != 0) {
|
if (mii_count != 0) {
|
||||||
ctx.WriteBuffer(char_info_elements);
|
ctx.WriteBuffer(char_info_elements);
|
||||||
|
@ -122,7 +124,7 @@ private:
|
||||||
|
|
||||||
u32 mii_count{};
|
u32 mii_count{};
|
||||||
std::vector<CharInfo> char_info(output_size);
|
std::vector<CharInfo> char_info(output_size);
|
||||||
const auto result = manager.Get(metadata, char_info, mii_count, source_flag);
|
const auto result = manager->Get(metadata, char_info, mii_count, source_flag);
|
||||||
|
|
||||||
if (mii_count != 0) {
|
if (mii_count != 0) {
|
||||||
ctx.WriteBuffer(char_info);
|
ctx.WriteBuffer(char_info);
|
||||||
|
@ -144,7 +146,7 @@ private:
|
||||||
LOG_INFO(Service_Mii, "called with source_flag={}", source_flag);
|
LOG_INFO(Service_Mii, "called with source_flag={}", source_flag);
|
||||||
|
|
||||||
CharInfo new_char_info{};
|
CharInfo new_char_info{};
|
||||||
const auto result = manager.UpdateLatest(metadata, new_char_info, char_info, source_flag);
|
const auto result = manager->UpdateLatest(metadata, new_char_info, char_info, source_flag);
|
||||||
if (result.IsFailure()) {
|
if (result.IsFailure()) {
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(result);
|
rb.Push(result);
|
||||||
|
@ -183,7 +185,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
CharInfo char_info{};
|
CharInfo char_info{};
|
||||||
manager.BuildRandom(char_info, age, gender, race);
|
manager->BuildRandom(char_info, age, gender, race);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -203,7 +205,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
CharInfo char_info{};
|
CharInfo char_info{};
|
||||||
manager.BuildDefault(char_info, index);
|
manager->BuildDefault(char_info, index);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -217,7 +219,7 @@ private:
|
||||||
|
|
||||||
u32 mii_count{};
|
u32 mii_count{};
|
||||||
std::vector<StoreDataElement> store_data_elements(output_size);
|
std::vector<StoreDataElement> store_data_elements(output_size);
|
||||||
const auto result = manager.Get(metadata, store_data_elements, mii_count, source_flag);
|
const auto result = manager->Get(metadata, store_data_elements, mii_count, source_flag);
|
||||||
|
|
||||||
if (mii_count != 0) {
|
if (mii_count != 0) {
|
||||||
ctx.WriteBuffer(store_data_elements);
|
ctx.WriteBuffer(store_data_elements);
|
||||||
|
@ -238,7 +240,7 @@ private:
|
||||||
|
|
||||||
u32 mii_count{};
|
u32 mii_count{};
|
||||||
std::vector<StoreData> store_data(output_size);
|
std::vector<StoreData> store_data(output_size);
|
||||||
const auto result = manager.Get(metadata, store_data, mii_count, source_flag);
|
const auto result = manager->Get(metadata, store_data, mii_count, source_flag);
|
||||||
|
|
||||||
if (mii_count != 0) {
|
if (mii_count != 0) {
|
||||||
ctx.WriteBuffer(store_data);
|
ctx.WriteBuffer(store_data);
|
||||||
|
@ -266,7 +268,7 @@ private:
|
||||||
|
|
||||||
StoreData new_store_data{};
|
StoreData new_store_data{};
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
result = manager.UpdateLatest(metadata, new_store_data, store_data, source_flag);
|
result = manager->UpdateLatest(metadata, new_store_data, store_data, source_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsFailure()) {
|
if (result.IsFailure()) {
|
||||||
|
@ -288,7 +290,7 @@ private:
|
||||||
LOG_INFO(Service_Mii, "called with create_id={}, is_special={}",
|
LOG_INFO(Service_Mii, "called with create_id={}, is_special={}",
|
||||||
create_id.FormattedString(), is_special);
|
create_id.FormattedString(), is_special);
|
||||||
|
|
||||||
const s32 index = manager.FindIndex(create_id, is_special);
|
const s32 index = manager->FindIndex(create_id, is_special);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -309,14 +311,14 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
const u32 count = manager.GetCount(metadata, SourceFlag::Database);
|
const u32 count = manager->GetCount(metadata, SourceFlag::Database);
|
||||||
if (new_index < 0 || new_index >= static_cast<s32>(count)) {
|
if (new_index < 0 || new_index >= static_cast<s32>(count)) {
|
||||||
result = ResultInvalidArgument;
|
result = ResultInvalidArgument;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
result = manager.Move(metadata, new_index, create_id);
|
result = manager->Move(metadata, new_index, create_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
@ -336,7 +338,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
result = manager.AddOrReplace(metadata, store_data);
|
result = manager->AddOrReplace(metadata, store_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
@ -356,7 +358,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
result = manager.Delete(metadata, create_id);
|
result = manager->Delete(metadata, create_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
@ -376,7 +378,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
result = manager.DestroyFile(metadata);
|
result = manager->DestroyFile(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
@ -396,7 +398,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
result = manager.DeleteFile();
|
result = manager->DeleteFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
@ -416,7 +418,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
result = manager.Format(metadata);
|
result = manager->Format(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
@ -434,7 +436,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
is_broken_with_clear_flag = manager.IsBrokenWithClearFlag(metadata);
|
is_broken_with_clear_flag = manager->IsBrokenWithClearFlag(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
@ -449,7 +451,7 @@ private:
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
|
||||||
s32 index{};
|
s32 index{};
|
||||||
const auto result = manager.GetIndex(metadata, info, index);
|
const auto result = manager->GetIndex(metadata, info, index);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(result);
|
rb.Push(result);
|
||||||
|
@ -462,7 +464,7 @@ private:
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called, interface_version={:08X}", interface_version);
|
LOG_INFO(Service_Mii, "called, interface_version={:08X}", interface_version);
|
||||||
|
|
||||||
manager.SetInterfaceVersion(metadata, interface_version);
|
manager->SetInterfaceVersion(metadata, interface_version);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -475,7 +477,7 @@ private:
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
CharInfo char_info{};
|
CharInfo char_info{};
|
||||||
const auto result = manager.ConvertV3ToCharInfo(char_info, mii_v3);
|
const auto result = manager->ConvertV3ToCharInfo(char_info, mii_v3);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
||||||
rb.Push(result);
|
rb.Push(result);
|
||||||
|
@ -489,7 +491,7 @@ private:
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
CharInfo char_info{};
|
CharInfo char_info{};
|
||||||
const auto result = manager.ConvertCoreDataToCharInfo(char_info, core_data);
|
const auto result = manager->ConvertCoreDataToCharInfo(char_info, core_data);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)};
|
||||||
rb.Push(result);
|
rb.Push(result);
|
||||||
|
@ -503,7 +505,7 @@ private:
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
CoreData core_data{};
|
CoreData core_data{};
|
||||||
const auto result = manager.ConvertCharInfoToCoreData(core_data, char_info);
|
const auto result = manager->ConvertCharInfoToCoreData(core_data, char_info);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CoreData) / sizeof(u32)};
|
IPC::ResponseBuilder rb{ctx, 2 + sizeof(CoreData) / sizeof(u32)};
|
||||||
rb.Push(result);
|
rb.Push(result);
|
||||||
|
@ -516,41 +518,46 @@ private:
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
const auto result = manager.Append(metadata, char_info);
|
const auto result = manager->Append(metadata, char_info);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(result);
|
rb.Push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
MiiManager manager{};
|
std::shared_ptr<MiiManager> manager = nullptr;
|
||||||
DatabaseSessionMetadata metadata{};
|
DatabaseSessionMetadata metadata{};
|
||||||
bool is_system{};
|
bool is_system{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class MiiDBModule final : public ServiceFramework<MiiDBModule> {
|
MiiDBModule::MiiDBModule(Core::System& system_, const char* name_,
|
||||||
public:
|
std::shared_ptr<MiiManager> mii_manager, bool is_system_)
|
||||||
explicit MiiDBModule(Core::System& system_, const char* name_, bool is_system_)
|
: ServiceFramework{system_, name_}, manager{mii_manager}, is_system{is_system_} {
|
||||||
: ServiceFramework{system_, name_}, is_system{is_system_} {
|
// clang-format off
|
||||||
// clang-format off
|
static const FunctionInfo functions[] = {
|
||||||
static const FunctionInfo functions[] = {
|
{0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"},
|
||||||
{0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"},
|
};
|
||||||
};
|
// clang-format on
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
|
if (manager == nullptr) {
|
||||||
|
manager = std::make_shared<MiiManager>();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
MiiDBModule::~MiiDBModule() = default;
|
||||||
void GetDatabaseService(HLERequestContext& ctx) {
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.PushIpcInterface<IDatabaseService>(system, is_system);
|
|
||||||
|
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
void MiiDBModule::GetDatabaseService(HLERequestContext& ctx) {
|
||||||
}
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
|
rb.Push(ResultSuccess);
|
||||||
|
rb.PushIpcInterface<IDatabaseService>(system, manager, is_system);
|
||||||
|
|
||||||
bool is_system{};
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
};
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<MiiManager> MiiDBModule::GetMiiManager() {
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
class MiiImg final : public ServiceFramework<MiiImg> {
|
class MiiImg final : public ServiceFramework<MiiImg> {
|
||||||
public:
|
public:
|
||||||
|
@ -596,11 +603,12 @@ private:
|
||||||
|
|
||||||
void LoopProcess(Core::System& system) {
|
void LoopProcess(Core::System& system) {
|
||||||
auto server_manager = std::make_unique<ServerManager>(system);
|
auto server_manager = std::make_unique<ServerManager>(system);
|
||||||
|
std::shared_ptr<MiiManager> manager = nullptr;
|
||||||
|
|
||||||
server_manager->RegisterNamedService("mii:e",
|
server_manager->RegisterNamedService(
|
||||||
std::make_shared<MiiDBModule>(system, "mii:e", true));
|
"mii:e", std::make_shared<MiiDBModule>(system, "mii:e", manager, true));
|
||||||
server_manager->RegisterNamedService("mii:u",
|
server_manager->RegisterNamedService(
|
||||||
std::make_shared<MiiDBModule>(system, "mii:u", false));
|
"mii:u", std::make_shared<MiiDBModule>(system, "mii:u", manager, false));
|
||||||
server_manager->RegisterNamedService("miiimg", std::make_shared<MiiImg>(system));
|
server_manager->RegisterNamedService("miiimg", std::make_shared<MiiImg>(system));
|
||||||
ServerManager::RunServer(std::move(server_manager));
|
ServerManager::RunServer(std::move(server_manager));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,29 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class System;
|
class System;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Service::Mii {
|
namespace Service::Mii {
|
||||||
|
class MiiManager;
|
||||||
|
|
||||||
|
class MiiDBModule final : public ServiceFramework<MiiDBModule> {
|
||||||
|
public:
|
||||||
|
explicit MiiDBModule(Core::System& system_, const char* name_,
|
||||||
|
std::shared_ptr<MiiManager> mii_manager, bool is_system_);
|
||||||
|
~MiiDBModule() override;
|
||||||
|
|
||||||
|
std::shared_ptr<MiiManager> GetMiiManager();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GetDatabaseService(HLERequestContext& ctx);
|
||||||
|
|
||||||
|
std::shared_ptr<MiiManager> manager = nullptr;
|
||||||
|
bool is_system{};
|
||||||
|
};
|
||||||
|
|
||||||
void LoopProcess(Core::System& system);
|
void LoopProcess(Core::System& system);
|
||||||
|
|
||||||
|
|
|
@ -130,11 +130,11 @@ Result MiiManager::GetIndex(const DatabaseSessionMetadata& metadata, const CharI
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 index{};
|
s32 index{};
|
||||||
Result result = {};
|
const bool is_special = metadata.magic == MiiMagic;
|
||||||
// FindIndex(index);
|
const auto result = database_manager.FindIndex(index, char_info.GetCreateId(), is_special);
|
||||||
|
|
||||||
if (result.IsError()) {
|
if (result.IsError()) {
|
||||||
return ResultNotFound;
|
index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ void CharInfo::SetFromStoreData(const StoreData& store_data) {
|
||||||
eyebrow_aspect = store_data.GetEyebrowAspect();
|
eyebrow_aspect = store_data.GetEyebrowAspect();
|
||||||
eyebrow_rotate = store_data.GetEyebrowRotate();
|
eyebrow_rotate = store_data.GetEyebrowRotate();
|
||||||
eyebrow_x = store_data.GetEyebrowX();
|
eyebrow_x = store_data.GetEyebrowX();
|
||||||
eyebrow_y = store_data.GetEyebrowY() + 3;
|
eyebrow_y = store_data.GetEyebrowY();
|
||||||
nose_type = store_data.GetNoseType();
|
nose_type = store_data.GetNoseType();
|
||||||
nose_scale = store_data.GetNoseScale();
|
nose_scale = store_data.GetNoseScale();
|
||||||
nose_y = store_data.GetNoseY();
|
nose_y = store_data.GetNoseY();
|
||||||
|
|
|
@ -171,7 +171,7 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) {
|
||||||
u8 glasses_type{};
|
u8 glasses_type{};
|
||||||
while (glasses_type_start < glasses_type_info.values[glasses_type]) {
|
while (glasses_type_start < glasses_type_info.values[glasses_type]) {
|
||||||
if (++glasses_type >= glasses_type_info.values_count) {
|
if (++glasses_type >= glasses_type_info.values_count) {
|
||||||
ASSERT(false);
|
glasses_type = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,6 +179,7 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) {
|
||||||
SetGlassType(static_cast<GlassType>(glasses_type));
|
SetGlassType(static_cast<GlassType>(glasses_type));
|
||||||
SetGlassColor(RawData::GetGlassColorFromVer3(0));
|
SetGlassColor(RawData::GetGlassColorFromVer3(0));
|
||||||
SetGlassScale(4);
|
SetGlassScale(4);
|
||||||
|
SetGlassY(static_cast<u8>(axis_y + 10));
|
||||||
|
|
||||||
SetMoleType(MoleType::None);
|
SetMoleType(MoleType::None);
|
||||||
SetMoleScale(4);
|
SetMoleScale(4);
|
||||||
|
|
|
@ -1716,18 +1716,18 @@ const std::array<RandomMiiData4, 18> RandomMiiMouthType{
|
||||||
const std::array<RandomMiiData2, 3> RandomMiiGlassType{
|
const std::array<RandomMiiData2, 3> RandomMiiGlassType{
|
||||||
RandomMiiData2{
|
RandomMiiData2{
|
||||||
.arg_1 = 0,
|
.arg_1 = 0,
|
||||||
.values_count = 9,
|
.values_count = 4,
|
||||||
.values = {90, 94, 96, 100, 0, 0, 0, 0, 0},
|
.values = {90, 94, 96, 100},
|
||||||
},
|
},
|
||||||
RandomMiiData2{
|
RandomMiiData2{
|
||||||
.arg_1 = 1,
|
.arg_1 = 1,
|
||||||
.values_count = 9,
|
.values_count = 8,
|
||||||
.values = {83, 86, 90, 93, 94, 96, 98, 100, 0},
|
.values = {83, 86, 90, 93, 94, 96, 98, 100},
|
||||||
},
|
},
|
||||||
RandomMiiData2{
|
RandomMiiData2{
|
||||||
.arg_1 = 2,
|
.arg_1 = 2,
|
||||||
.values_count = 9,
|
.values_count = 8,
|
||||||
.values = {78, 83, 0, 93, 0, 0, 98, 100, 0},
|
.values = {78, 83, 0, 93, 0, 0, 98, 100},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue