diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/am/applets/applet_mii_edit.cpp | 50 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applet_mii_edit.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/mii/mii.cpp | 114 | ||||
| -rw-r--r-- | src/core/hle/service/mii/mii.h | 18 | ||||
| -rw-r--r-- | src/core/hle/service/mii/mii_manager.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/char_info.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/core_data.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/mii/types/raw_data.cpp | 12 |
8 files changed, 139 insertions, 73 deletions
diff --git a/src/core/hle/service/am/applets/applet_mii_edit.cpp b/src/core/hle/service/am/applets/applet_mii_edit.cpp index 350a90818..ff77830d2 100644 --- a/src/core/hle/service/am/applets/applet_mii_edit.cpp +++ b/src/core/hle/service/am/applets/applet_mii_edit.cpp | |||
| @@ -7,7 +7,9 @@ | |||
| 7 | #include "core/frontend/applets/mii_edit.h" | 7 | #include "core/frontend/applets/mii_edit.h" |
| 8 | #include "core/hle/service/am/am.h" | 8 | #include "core/hle/service/am/am.h" |
| 9 | #include "core/hle/service/am/applets/applet_mii_edit.h" | 9 | #include "core/hle/service/am/applets/applet_mii_edit.h" |
| 10 | #include "core/hle/service/mii/mii.h" | ||
| 10 | #include "core/hle/service/mii/mii_manager.h" | 11 | #include "core/hle/service/mii/mii_manager.h" |
| 12 | #include "core/hle/service/sm/sm.h" | ||
| 11 | 13 | ||
| 12 | namespace Service::AM::Applets { | 14 | namespace Service::AM::Applets { |
| 13 | 15 | ||
| @@ -56,6 +58,12 @@ void MiiEdit::Initialize() { | |||
| 56 | sizeof(MiiEditAppletInputV4)); | 58 | sizeof(MiiEditAppletInputV4)); |
| 57 | break; | 59 | break; |
| 58 | } | 60 | } |
| 61 | |||
| 62 | manager = system.ServiceManager().GetService<Mii::MiiDBModule>("mii:e")->GetMiiManager(); | ||
| 63 | if (manager == nullptr) { | ||
| 64 | manager = std::make_shared<Mii::MiiManager>(); | ||
| 65 | } | ||
| 66 | manager->Initialize(metadata); | ||
| 59 | } | 67 | } |
| 60 | 68 | ||
| 61 | bool MiiEdit::TransactionComplete() const { | 69 | bool MiiEdit::TransactionComplete() const { |
| @@ -78,22 +86,46 @@ void MiiEdit::Execute() { | |||
| 78 | // This is a default stub for each of the MiiEdit applet modes. | 86 | // This is a default stub for each of the MiiEdit applet modes. |
| 79 | switch (applet_input_common.applet_mode) { | 87 | switch (applet_input_common.applet_mode) { |
| 80 | case MiiEditAppletMode::ShowMiiEdit: | 88 | case MiiEditAppletMode::ShowMiiEdit: |
| 81 | case MiiEditAppletMode::AppendMii: | ||
| 82 | case MiiEditAppletMode::AppendMiiImage: | 89 | case MiiEditAppletMode::AppendMiiImage: |
| 83 | case MiiEditAppletMode::UpdateMiiImage: | 90 | case MiiEditAppletMode::UpdateMiiImage: |
| 84 | MiiEditOutput(MiiEditResult::Success, 0); | 91 | MiiEditOutput(MiiEditResult::Success, 0); |
| 85 | break; | 92 | break; |
| 86 | case MiiEditAppletMode::CreateMii: | 93 | case MiiEditAppletMode::AppendMii: { |
| 87 | case MiiEditAppletMode::EditMii: { | ||
| 88 | Mii::CharInfo char_info{}; | ||
| 89 | Mii::StoreData store_data{}; | 94 | Mii::StoreData store_data{}; |
| 90 | store_data.BuildBase(Mii::Gender::Male); | 95 | store_data.BuildRandom(Mii::Age::All, Mii::Gender::All, Mii::Race::All); |
| 91 | char_info.SetFromStoreData(store_data); | 96 | store_data.SetNickname({u'y', u'u', u'z', u'u'}); |
| 97 | store_data.SetChecksum(); | ||
| 98 | const auto result = manager->AddOrReplace(metadata, store_data); | ||
| 99 | |||
| 100 | if (result.IsError()) { | ||
| 101 | MiiEditOutput(MiiEditResult::Cancel, 0); | ||
| 102 | break; | ||
| 103 | } | ||
| 104 | |||
| 105 | s32 index = manager->FindIndex(store_data.GetCreateId(), false); | ||
| 106 | |||
| 107 | if (index == -1) { | ||
| 108 | MiiEditOutput(MiiEditResult::Cancel, 0); | ||
| 109 | break; | ||
| 110 | } | ||
| 111 | |||
| 112 | MiiEditOutput(MiiEditResult::Success, index); | ||
| 113 | break; | ||
| 114 | } | ||
| 115 | case MiiEditAppletMode::CreateMii: { | ||
| 116 | Mii::CharInfo char_info{}; | ||
| 117 | manager->BuildRandom(char_info, Mii::Age::All, Mii::Gender::All, Mii::Race::All); | ||
| 118 | |||
| 119 | const MiiEditCharInfo edit_char_info{ | ||
| 120 | .mii_info{char_info}, | ||
| 121 | }; | ||
| 92 | 122 | ||
| 123 | MiiEditOutputForCharInfoEditing(MiiEditResult::Success, edit_char_info); | ||
| 124 | break; | ||
| 125 | } | ||
| 126 | case MiiEditAppletMode::EditMii: { | ||
| 93 | const MiiEditCharInfo edit_char_info{ | 127 | const MiiEditCharInfo edit_char_info{ |
| 94 | .mii_info{applet_input_common.applet_mode == MiiEditAppletMode::EditMii | 128 | .mii_info{applet_input_v4.char_info.mii_info}, |
| 95 | ? applet_input_v4.char_info.mii_info | ||
| 96 | : char_info}, | ||
| 97 | }; | 129 | }; |
| 98 | 130 | ||
| 99 | MiiEditOutputForCharInfoEditing(MiiEditResult::Success, edit_char_info); | 131 | MiiEditOutputForCharInfoEditing(MiiEditResult::Success, edit_char_info); |
diff --git a/src/core/hle/service/am/applets/applet_mii_edit.h b/src/core/hle/service/am/applets/applet_mii_edit.h index 3f46fae1b..7ff34af49 100644 --- a/src/core/hle/service/am/applets/applet_mii_edit.h +++ b/src/core/hle/service/am/applets/applet_mii_edit.h | |||
| @@ -11,6 +11,11 @@ namespace Core { | |||
| 11 | class System; | 11 | class System; |
| 12 | } // namespace Core | 12 | } // namespace Core |
| 13 | 13 | ||
| 14 | namespace Service::Mii { | ||
| 15 | struct DatabaseSessionMetadata; | ||
| 16 | class MiiManager; | ||
| 17 | } // namespace Service::Mii | ||
| 18 | |||
| 14 | namespace Service::AM::Applets { | 19 | namespace Service::AM::Applets { |
| 15 | 20 | ||
| 16 | class MiiEdit final : public Applet { | 21 | class MiiEdit final : public Applet { |
| @@ -40,6 +45,8 @@ private: | |||
| 40 | MiiEditAppletInputV4 applet_input_v4{}; | 45 | MiiEditAppletInputV4 applet_input_v4{}; |
| 41 | 46 | ||
| 42 | bool is_complete{false}; | 47 | bool is_complete{false}; |
| 48 | std::shared_ptr<Mii::MiiManager> manager = nullptr; | ||
| 49 | Mii::DatabaseSessionMetadata metadata{}; | ||
| 43 | }; | 50 | }; |
| 44 | 51 | ||
| 45 | } // namespace Service::AM::Applets | 52 | } // namespace Service::AM::Applets |
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 8de806cfb..c28eed926 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp | |||
| @@ -18,8 +18,10 @@ namespace Service::Mii { | |||
| 18 | 18 | ||
| 19 | class IDatabaseService final : public ServiceFramework<IDatabaseService> { | 19 | class IDatabaseService final : public ServiceFramework<IDatabaseService> { |
| 20 | public: | 20 | public: |
| 21 | explicit IDatabaseService(Core::System& system_, bool is_system_) | 21 | explicit IDatabaseService(Core::System& system_, std::shared_ptr<MiiManager> mii_manager, |
| 22 | : ServiceFramework{system_, "IDatabaseService"}, is_system{is_system_} { | 22 | bool is_system_) |
| 23 | : ServiceFramework{system_, "IDatabaseService"}, manager{mii_manager}, is_system{ | ||
| 24 | is_system_} { | ||
| 23 | // clang-format off | 25 | // clang-format off |
| 24 | static const FunctionInfo functions[] = { | 26 | static const FunctionInfo functions[] = { |
| 25 | {0, &IDatabaseService::IsUpdated, "IsUpdated"}, | 27 | {0, &IDatabaseService::IsUpdated, "IsUpdated"}, |
| @@ -54,7 +56,7 @@ public: | |||
| 54 | 56 | ||
| 55 | RegisterHandlers(functions); | 57 | RegisterHandlers(functions); |
| 56 | 58 | ||
| 57 | manager.Initialize(metadata); | 59 | manager->Initialize(metadata); |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | private: | 62 | private: |
| @@ -64,7 +66,7 @@ private: | |||
| 64 | 66 | ||
| 65 | LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag); | 67 | LOG_DEBUG(Service_Mii, "called with source_flag={}", source_flag); |
| 66 | 68 | ||
| 67 | const bool is_updated = manager.IsUpdated(metadata, source_flag); | 69 | const bool is_updated = manager->IsUpdated(metadata, source_flag); |
| 68 | 70 | ||
| 69 | IPC::ResponseBuilder rb{ctx, 3}; | 71 | IPC::ResponseBuilder rb{ctx, 3}; |
| 70 | rb.Push(ResultSuccess); | 72 | rb.Push(ResultSuccess); |
| @@ -74,7 +76,7 @@ private: | |||
| 74 | void IsFullDatabase(HLERequestContext& ctx) { | 76 | void IsFullDatabase(HLERequestContext& ctx) { |
| 75 | LOG_DEBUG(Service_Mii, "called"); | 77 | LOG_DEBUG(Service_Mii, "called"); |
| 76 | 78 | ||
| 77 | const bool is_full_database = manager.IsFullDatabase(); | 79 | const bool is_full_database = manager->IsFullDatabase(); |
| 78 | 80 | ||
| 79 | IPC::ResponseBuilder rb{ctx, 3}; | 81 | IPC::ResponseBuilder rb{ctx, 3}; |
| 80 | rb.Push(ResultSuccess); | 82 | rb.Push(ResultSuccess); |
| @@ -85,7 +87,7 @@ private: | |||
| 85 | IPC::RequestParser rp{ctx}; | 87 | IPC::RequestParser rp{ctx}; |
| 86 | const auto source_flag{rp.PopRaw<SourceFlag>()}; | 88 | const auto source_flag{rp.PopRaw<SourceFlag>()}; |
| 87 | 89 | ||
| 88 | const u32 mii_count = manager.GetCount(metadata, source_flag); | 90 | const u32 mii_count = manager->GetCount(metadata, source_flag); |
| 89 | 91 | ||
| 90 | LOG_DEBUG(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, mii_count); | 92 | LOG_DEBUG(Service_Mii, "called with source_flag={}, mii_count={}", source_flag, mii_count); |
| 91 | 93 | ||
| @@ -101,7 +103,7 @@ private: | |||
| 101 | 103 | ||
| 102 | u32 mii_count{}; | 104 | u32 mii_count{}; |
| 103 | std::vector<CharInfoElement> char_info_elements(output_size); | 105 | std::vector<CharInfoElement> char_info_elements(output_size); |
| 104 | const auto result = manager.Get(metadata, char_info_elements, mii_count, source_flag); | 106 | const auto result = manager->Get(metadata, char_info_elements, mii_count, source_flag); |
| 105 | 107 | ||
| 106 | if (mii_count != 0) { | 108 | if (mii_count != 0) { |
| 107 | ctx.WriteBuffer(char_info_elements); | 109 | ctx.WriteBuffer(char_info_elements); |
| @@ -122,7 +124,7 @@ private: | |||
| 122 | 124 | ||
| 123 | u32 mii_count{}; | 125 | u32 mii_count{}; |
| 124 | std::vector<CharInfo> char_info(output_size); | 126 | std::vector<CharInfo> char_info(output_size); |
| 125 | const auto result = manager.Get(metadata, char_info, mii_count, source_flag); | 127 | const auto result = manager->Get(metadata, char_info, mii_count, source_flag); |
| 126 | 128 | ||
| 127 | if (mii_count != 0) { | 129 | if (mii_count != 0) { |
| 128 | ctx.WriteBuffer(char_info); | 130 | ctx.WriteBuffer(char_info); |
| @@ -144,7 +146,7 @@ private: | |||
| 144 | LOG_INFO(Service_Mii, "called with source_flag={}", source_flag); | 146 | LOG_INFO(Service_Mii, "called with source_flag={}", source_flag); |
| 145 | 147 | ||
| 146 | CharInfo new_char_info{}; | 148 | CharInfo new_char_info{}; |
| 147 | const auto result = manager.UpdateLatest(metadata, new_char_info, char_info, source_flag); | 149 | const auto result = manager->UpdateLatest(metadata, new_char_info, char_info, source_flag); |
| 148 | if (result.IsFailure()) { | 150 | if (result.IsFailure()) { |
| 149 | IPC::ResponseBuilder rb{ctx, 2}; | 151 | IPC::ResponseBuilder rb{ctx, 2}; |
| 150 | rb.Push(result); | 152 | rb.Push(result); |
| @@ -183,7 +185,7 @@ private: | |||
| 183 | } | 185 | } |
| 184 | 186 | ||
| 185 | CharInfo char_info{}; | 187 | CharInfo char_info{}; |
| 186 | manager.BuildRandom(char_info, age, gender, race); | 188 | manager->BuildRandom(char_info, age, gender, race); |
| 187 | 189 | ||
| 188 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; | 190 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; |
| 189 | rb.Push(ResultSuccess); | 191 | rb.Push(ResultSuccess); |
| @@ -203,7 +205,7 @@ private: | |||
| 203 | } | 205 | } |
| 204 | 206 | ||
| 205 | CharInfo char_info{}; | 207 | CharInfo char_info{}; |
| 206 | manager.BuildDefault(char_info, index); | 208 | manager->BuildDefault(char_info, index); |
| 207 | 209 | ||
| 208 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; | 210 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; |
| 209 | rb.Push(ResultSuccess); | 211 | rb.Push(ResultSuccess); |
| @@ -217,7 +219,7 @@ private: | |||
| 217 | 219 | ||
| 218 | u32 mii_count{}; | 220 | u32 mii_count{}; |
| 219 | std::vector<StoreDataElement> store_data_elements(output_size); | 221 | std::vector<StoreDataElement> store_data_elements(output_size); |
| 220 | const auto result = manager.Get(metadata, store_data_elements, mii_count, source_flag); | 222 | const auto result = manager->Get(metadata, store_data_elements, mii_count, source_flag); |
| 221 | 223 | ||
| 222 | if (mii_count != 0) { | 224 | if (mii_count != 0) { |
| 223 | ctx.WriteBuffer(store_data_elements); | 225 | ctx.WriteBuffer(store_data_elements); |
| @@ -238,7 +240,7 @@ private: | |||
| 238 | 240 | ||
| 239 | u32 mii_count{}; | 241 | u32 mii_count{}; |
| 240 | std::vector<StoreData> store_data(output_size); | 242 | std::vector<StoreData> store_data(output_size); |
| 241 | const auto result = manager.Get(metadata, store_data, mii_count, source_flag); | 243 | const auto result = manager->Get(metadata, store_data, mii_count, source_flag); |
| 242 | 244 | ||
| 243 | if (mii_count != 0) { | 245 | if (mii_count != 0) { |
| 244 | ctx.WriteBuffer(store_data); | 246 | ctx.WriteBuffer(store_data); |
| @@ -266,7 +268,7 @@ private: | |||
| 266 | 268 | ||
| 267 | StoreData new_store_data{}; | 269 | StoreData new_store_data{}; |
| 268 | if (result.IsSuccess()) { | 270 | if (result.IsSuccess()) { |
| 269 | result = manager.UpdateLatest(metadata, new_store_data, store_data, source_flag); | 271 | result = manager->UpdateLatest(metadata, new_store_data, store_data, source_flag); |
| 270 | } | 272 | } |
| 271 | 273 | ||
| 272 | if (result.IsFailure()) { | 274 | if (result.IsFailure()) { |
| @@ -288,7 +290,7 @@ private: | |||
| 288 | LOG_INFO(Service_Mii, "called with create_id={}, is_special={}", | 290 | LOG_INFO(Service_Mii, "called with create_id={}, is_special={}", |
| 289 | create_id.FormattedString(), is_special); | 291 | create_id.FormattedString(), is_special); |
| 290 | 292 | ||
| 291 | const s32 index = manager.FindIndex(create_id, is_special); | 293 | const s32 index = manager->FindIndex(create_id, is_special); |
| 292 | 294 | ||
| 293 | IPC::ResponseBuilder rb{ctx, 3}; | 295 | IPC::ResponseBuilder rb{ctx, 3}; |
| 294 | rb.Push(ResultSuccess); | 296 | rb.Push(ResultSuccess); |
| @@ -309,14 +311,14 @@ private: | |||
| 309 | } | 311 | } |
| 310 | 312 | ||
| 311 | if (result.IsSuccess()) { | 313 | if (result.IsSuccess()) { |
| 312 | const u32 count = manager.GetCount(metadata, SourceFlag::Database); | 314 | const u32 count = manager->GetCount(metadata, SourceFlag::Database); |
| 313 | if (new_index < 0 || new_index >= static_cast<s32>(count)) { | 315 | if (new_index < 0 || new_index >= static_cast<s32>(count)) { |
| 314 | result = ResultInvalidArgument; | 316 | result = ResultInvalidArgument; |
| 315 | } | 317 | } |
| 316 | } | 318 | } |
| 317 | 319 | ||
| 318 | if (result.IsSuccess()) { | 320 | if (result.IsSuccess()) { |
| 319 | result = manager.Move(metadata, new_index, create_id); | 321 | result = manager->Move(metadata, new_index, create_id); |
| 320 | } | 322 | } |
| 321 | 323 | ||
| 322 | IPC::ResponseBuilder rb{ctx, 2}; | 324 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -336,7 +338,7 @@ private: | |||
| 336 | } | 338 | } |
| 337 | 339 | ||
| 338 | if (result.IsSuccess()) { | 340 | if (result.IsSuccess()) { |
| 339 | result = manager.AddOrReplace(metadata, store_data); | 341 | result = manager->AddOrReplace(metadata, store_data); |
| 340 | } | 342 | } |
| 341 | 343 | ||
| 342 | IPC::ResponseBuilder rb{ctx, 2}; | 344 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -356,7 +358,7 @@ private: | |||
| 356 | } | 358 | } |
| 357 | 359 | ||
| 358 | if (result.IsSuccess()) { | 360 | if (result.IsSuccess()) { |
| 359 | result = manager.Delete(metadata, create_id); | 361 | result = manager->Delete(metadata, create_id); |
| 360 | } | 362 | } |
| 361 | 363 | ||
| 362 | IPC::ResponseBuilder rb{ctx, 2}; | 364 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -376,7 +378,7 @@ private: | |||
| 376 | } | 378 | } |
| 377 | 379 | ||
| 378 | if (result.IsSuccess()) { | 380 | if (result.IsSuccess()) { |
| 379 | result = manager.DestroyFile(metadata); | 381 | result = manager->DestroyFile(metadata); |
| 380 | } | 382 | } |
| 381 | 383 | ||
| 382 | IPC::ResponseBuilder rb{ctx, 2}; | 384 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -396,7 +398,7 @@ private: | |||
| 396 | } | 398 | } |
| 397 | 399 | ||
| 398 | if (result.IsSuccess()) { | 400 | if (result.IsSuccess()) { |
| 399 | result = manager.DeleteFile(); | 401 | result = manager->DeleteFile(); |
| 400 | } | 402 | } |
| 401 | 403 | ||
| 402 | IPC::ResponseBuilder rb{ctx, 2}; | 404 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -416,7 +418,7 @@ private: | |||
| 416 | } | 418 | } |
| 417 | 419 | ||
| 418 | if (result.IsSuccess()) { | 420 | if (result.IsSuccess()) { |
| 419 | result = manager.Format(metadata); | 421 | result = manager->Format(metadata); |
| 420 | } | 422 | } |
| 421 | 423 | ||
| 422 | IPC::ResponseBuilder rb{ctx, 2}; | 424 | IPC::ResponseBuilder rb{ctx, 2}; |
| @@ -434,7 +436,7 @@ private: | |||
| 434 | } | 436 | } |
| 435 | 437 | ||
| 436 | if (result.IsSuccess()) { | 438 | if (result.IsSuccess()) { |
| 437 | is_broken_with_clear_flag = manager.IsBrokenWithClearFlag(metadata); | 439 | is_broken_with_clear_flag = manager->IsBrokenWithClearFlag(metadata); |
| 438 | } | 440 | } |
| 439 | 441 | ||
| 440 | IPC::ResponseBuilder rb{ctx, 3}; | 442 | IPC::ResponseBuilder rb{ctx, 3}; |
| @@ -449,7 +451,7 @@ private: | |||
| 449 | LOG_DEBUG(Service_Mii, "called"); | 451 | LOG_DEBUG(Service_Mii, "called"); |
| 450 | 452 | ||
| 451 | s32 index{}; | 453 | s32 index{}; |
| 452 | const auto result = manager.GetIndex(metadata, info, index); | 454 | const auto result = manager->GetIndex(metadata, info, index); |
| 453 | 455 | ||
| 454 | IPC::ResponseBuilder rb{ctx, 3}; | 456 | IPC::ResponseBuilder rb{ctx, 3}; |
| 455 | rb.Push(result); | 457 | rb.Push(result); |
| @@ -462,7 +464,7 @@ private: | |||
| 462 | 464 | ||
| 463 | LOG_INFO(Service_Mii, "called, interface_version={:08X}", interface_version); | 465 | LOG_INFO(Service_Mii, "called, interface_version={:08X}", interface_version); |
| 464 | 466 | ||
| 465 | manager.SetInterfaceVersion(metadata, interface_version); | 467 | manager->SetInterfaceVersion(metadata, interface_version); |
| 466 | 468 | ||
| 467 | IPC::ResponseBuilder rb{ctx, 2}; | 469 | IPC::ResponseBuilder rb{ctx, 2}; |
| 468 | rb.Push(ResultSuccess); | 470 | rb.Push(ResultSuccess); |
| @@ -475,7 +477,7 @@ private: | |||
| 475 | LOG_INFO(Service_Mii, "called"); | 477 | LOG_INFO(Service_Mii, "called"); |
| 476 | 478 | ||
| 477 | CharInfo char_info{}; | 479 | CharInfo char_info{}; |
| 478 | const auto result = manager.ConvertV3ToCharInfo(char_info, mii_v3); | 480 | const auto result = manager->ConvertV3ToCharInfo(char_info, mii_v3); |
| 479 | 481 | ||
| 480 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; | 482 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; |
| 481 | rb.Push(result); | 483 | rb.Push(result); |
| @@ -489,7 +491,7 @@ private: | |||
| 489 | LOG_INFO(Service_Mii, "called"); | 491 | LOG_INFO(Service_Mii, "called"); |
| 490 | 492 | ||
| 491 | CharInfo char_info{}; | 493 | CharInfo char_info{}; |
| 492 | const auto result = manager.ConvertCoreDataToCharInfo(char_info, core_data); | 494 | const auto result = manager->ConvertCoreDataToCharInfo(char_info, core_data); |
| 493 | 495 | ||
| 494 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; | 496 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CharInfo) / sizeof(u32)}; |
| 495 | rb.Push(result); | 497 | rb.Push(result); |
| @@ -503,7 +505,7 @@ private: | |||
| 503 | LOG_INFO(Service_Mii, "called"); | 505 | LOG_INFO(Service_Mii, "called"); |
| 504 | 506 | ||
| 505 | CoreData core_data{}; | 507 | CoreData core_data{}; |
| 506 | const auto result = manager.ConvertCharInfoToCoreData(core_data, char_info); | 508 | const auto result = manager->ConvertCharInfoToCoreData(core_data, char_info); |
| 507 | 509 | ||
| 508 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CoreData) / sizeof(u32)}; | 510 | IPC::ResponseBuilder rb{ctx, 2 + sizeof(CoreData) / sizeof(u32)}; |
| 509 | rb.Push(result); | 511 | rb.Push(result); |
| @@ -516,41 +518,46 @@ private: | |||
| 516 | 518 | ||
| 517 | LOG_INFO(Service_Mii, "called"); | 519 | LOG_INFO(Service_Mii, "called"); |
| 518 | 520 | ||
| 519 | const auto result = manager.Append(metadata, char_info); | 521 | const auto result = manager->Append(metadata, char_info); |
| 520 | 522 | ||
| 521 | IPC::ResponseBuilder rb{ctx, 2}; | 523 | IPC::ResponseBuilder rb{ctx, 2}; |
| 522 | rb.Push(result); | 524 | rb.Push(result); |
| 523 | } | 525 | } |
| 524 | 526 | ||
| 525 | MiiManager manager{}; | 527 | std::shared_ptr<MiiManager> manager = nullptr; |
| 526 | DatabaseSessionMetadata metadata{}; | 528 | DatabaseSessionMetadata metadata{}; |
| 527 | bool is_system{}; | 529 | bool is_system{}; |
| 528 | }; | 530 | }; |
| 529 | 531 | ||
| 530 | class MiiDBModule final : public ServiceFramework<MiiDBModule> { | 532 | MiiDBModule::MiiDBModule(Core::System& system_, const char* name_, |
| 531 | public: | 533 | std::shared_ptr<MiiManager> mii_manager, bool is_system_) |
| 532 | explicit MiiDBModule(Core::System& system_, const char* name_, bool is_system_) | 534 | : ServiceFramework{system_, name_}, manager{mii_manager}, is_system{is_system_} { |
| 533 | : ServiceFramework{system_, name_}, is_system{is_system_} { | 535 | // clang-format off |
| 534 | // clang-format off | 536 | static const FunctionInfo functions[] = { |
| 535 | static const FunctionInfo functions[] = { | 537 | {0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"}, |
| 536 | {0, &MiiDBModule::GetDatabaseService, "GetDatabaseService"}, | 538 | }; |
| 537 | }; | 539 | // clang-format on |
| 538 | // clang-format on | ||
| 539 | 540 | ||
| 540 | RegisterHandlers(functions); | 541 | RegisterHandlers(functions); |
| 542 | |||
| 543 | if (manager == nullptr) { | ||
| 544 | manager = std::make_shared<MiiManager>(); | ||
| 541 | } | 545 | } |
| 546 | } | ||
| 542 | 547 | ||
| 543 | private: | 548 | MiiDBModule::~MiiDBModule() = default; |
| 544 | void GetDatabaseService(HLERequestContext& ctx) { | ||
| 545 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 546 | rb.Push(ResultSuccess); | ||
| 547 | rb.PushIpcInterface<IDatabaseService>(system, is_system); | ||
| 548 | 549 | ||
| 549 | LOG_DEBUG(Service_Mii, "called"); | 550 | void MiiDBModule::GetDatabaseService(HLERequestContext& ctx) { |
| 550 | } | 551 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 552 | rb.Push(ResultSuccess); | ||
| 553 | rb.PushIpcInterface<IDatabaseService>(system, manager, is_system); | ||
| 551 | 554 | ||
| 552 | bool is_system{}; | 555 | LOG_DEBUG(Service_Mii, "called"); |
| 553 | }; | 556 | } |
| 557 | |||
| 558 | std::shared_ptr<MiiManager> MiiDBModule::GetMiiManager() { | ||
| 559 | return manager; | ||
| 560 | } | ||
| 554 | 561 | ||
| 555 | class MiiImg final : public ServiceFramework<MiiImg> { | 562 | class MiiImg final : public ServiceFramework<MiiImg> { |
| 556 | public: | 563 | public: |
| @@ -596,11 +603,12 @@ private: | |||
| 596 | 603 | ||
| 597 | void LoopProcess(Core::System& system) { | 604 | void LoopProcess(Core::System& system) { |
| 598 | auto server_manager = std::make_unique<ServerManager>(system); | 605 | auto server_manager = std::make_unique<ServerManager>(system); |
| 606 | std::shared_ptr<MiiManager> manager = nullptr; | ||
| 599 | 607 | ||
| 600 | server_manager->RegisterNamedService("mii:e", | 608 | server_manager->RegisterNamedService( |
| 601 | std::make_shared<MiiDBModule>(system, "mii:e", true)); | 609 | "mii:e", std::make_shared<MiiDBModule>(system, "mii:e", manager, true)); |
| 602 | server_manager->RegisterNamedService("mii:u", | 610 | server_manager->RegisterNamedService( |
| 603 | std::make_shared<MiiDBModule>(system, "mii:u", false)); | 611 | "mii:u", std::make_shared<MiiDBModule>(system, "mii:u", manager, false)); |
| 604 | server_manager->RegisterNamedService("miiimg", std::make_shared<MiiImg>(system)); | 612 | server_manager->RegisterNamedService("miiimg", std::make_shared<MiiImg>(system)); |
| 605 | ServerManager::RunServer(std::move(server_manager)); | 613 | ServerManager::RunServer(std::move(server_manager)); |
| 606 | } | 614 | } |
diff --git a/src/core/hle/service/mii/mii.h b/src/core/hle/service/mii/mii.h index ed4e3f62b..9aa4426f6 100644 --- a/src/core/hle/service/mii/mii.h +++ b/src/core/hle/service/mii/mii.h | |||
| @@ -3,11 +3,29 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/hle/service/service.h" | ||
| 7 | |||
| 6 | namespace Core { | 8 | namespace Core { |
| 7 | class System; | 9 | class System; |
| 8 | } | 10 | } |
| 9 | 11 | ||
| 10 | namespace Service::Mii { | 12 | namespace Service::Mii { |
| 13 | class MiiManager; | ||
| 14 | |||
| 15 | class MiiDBModule final : public ServiceFramework<MiiDBModule> { | ||
| 16 | public: | ||
| 17 | explicit MiiDBModule(Core::System& system_, const char* name_, | ||
| 18 | std::shared_ptr<MiiManager> mii_manager, bool is_system_); | ||
| 19 | ~MiiDBModule() override; | ||
| 20 | |||
| 21 | std::shared_ptr<MiiManager> GetMiiManager(); | ||
| 22 | |||
| 23 | private: | ||
| 24 | void GetDatabaseService(HLERequestContext& ctx); | ||
| 25 | |||
| 26 | std::shared_ptr<MiiManager> manager = nullptr; | ||
| 27 | bool is_system{}; | ||
| 28 | }; | ||
| 11 | 29 | ||
| 12 | void LoopProcess(Core::System& system); | 30 | void LoopProcess(Core::System& system); |
| 13 | 31 | ||
diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index a5a2a9232..dcfd6b2e2 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp | |||
| @@ -130,11 +130,11 @@ Result MiiManager::GetIndex(const DatabaseSessionMetadata& metadata, const CharI | |||
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | s32 index{}; | 132 | s32 index{}; |
| 133 | Result result = {}; | 133 | const bool is_special = metadata.magic == MiiMagic; |
| 134 | // FindIndex(index); | 134 | const auto result = database_manager.FindIndex(index, char_info.GetCreateId(), is_special); |
| 135 | 135 | ||
| 136 | if (result.IsError()) { | 136 | if (result.IsError()) { |
| 137 | return ResultNotFound; | 137 | index = -1; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | if (index == -1) { | 140 | if (index == -1) { |
diff --git a/src/core/hle/service/mii/types/char_info.cpp b/src/core/hle/service/mii/types/char_info.cpp index e90124af4..c82186c73 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() + 3; | 40 | eyebrow_y = store_data.GetEyebrowY(); |
| 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(); |
diff --git a/src/core/hle/service/mii/types/core_data.cpp b/src/core/hle/service/mii/types/core_data.cpp index 465c6293a..1068031e3 100644 --- a/src/core/hle/service/mii/types/core_data.cpp +++ b/src/core/hle/service/mii/types/core_data.cpp | |||
| @@ -171,7 +171,7 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) { | |||
| 171 | u8 glasses_type{}; | 171 | u8 glasses_type{}; |
| 172 | while (glasses_type_start < glasses_type_info.values[glasses_type]) { | 172 | while (glasses_type_start < glasses_type_info.values[glasses_type]) { |
| 173 | if (++glasses_type >= glasses_type_info.values_count) { | 173 | if (++glasses_type >= glasses_type_info.values_count) { |
| 174 | ASSERT(false); | 174 | glasses_type = 0; |
| 175 | break; | 175 | break; |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| @@ -179,6 +179,7 @@ void CoreData::BuildRandom(Age age, Gender gender, Race race) { | |||
| 179 | SetGlassType(static_cast<GlassType>(glasses_type)); | 179 | SetGlassType(static_cast<GlassType>(glasses_type)); |
| 180 | SetGlassColor(RawData::GetGlassColorFromVer3(0)); | 180 | SetGlassColor(RawData::GetGlassColorFromVer3(0)); |
| 181 | SetGlassScale(4); | 181 | SetGlassScale(4); |
| 182 | SetGlassY(static_cast<u8>(axis_y + 10)); | ||
| 182 | 183 | ||
| 183 | SetMoleType(MoleType::None); | 184 | SetMoleType(MoleType::None); |
| 184 | SetMoleScale(4); | 185 | SetMoleScale(4); |
diff --git a/src/core/hle/service/mii/types/raw_data.cpp b/src/core/hle/service/mii/types/raw_data.cpp index 5143abcc8..0e1a07fd7 100644 --- a/src/core/hle/service/mii/types/raw_data.cpp +++ b/src/core/hle/service/mii/types/raw_data.cpp | |||
| @@ -1716,18 +1716,18 @@ const std::array<RandomMiiData4, 18> RandomMiiMouthType{ | |||
| 1716 | const std::array<RandomMiiData2, 3> RandomMiiGlassType{ | 1716 | const std::array<RandomMiiData2, 3> RandomMiiGlassType{ |
| 1717 | RandomMiiData2{ | 1717 | RandomMiiData2{ |
| 1718 | .arg_1 = 0, | 1718 | .arg_1 = 0, |
| 1719 | .values_count = 9, | 1719 | .values_count = 4, |
| 1720 | .values = {90, 94, 96, 100, 0, 0, 0, 0, 0}, | 1720 | .values = {90, 94, 96, 100}, |
| 1721 | }, | 1721 | }, |
| 1722 | RandomMiiData2{ | 1722 | RandomMiiData2{ |
| 1723 | .arg_1 = 1, | 1723 | .arg_1 = 1, |
| 1724 | .values_count = 9, | 1724 | .values_count = 8, |
| 1725 | .values = {83, 86, 90, 93, 94, 96, 98, 100, 0}, | 1725 | .values = {83, 86, 90, 93, 94, 96, 98, 100}, |
| 1726 | }, | 1726 | }, |
| 1727 | RandomMiiData2{ | 1727 | RandomMiiData2{ |
| 1728 | .arg_1 = 2, | 1728 | .arg_1 = 2, |
| 1729 | .values_count = 9, | 1729 | .values_count = 8, |
| 1730 | .values = {78, 83, 0, 93, 0, 0, 98, 100, 0}, | 1730 | .values = {78, 83, 0, 93, 0, 0, 98, 100}, |
| 1731 | }, | 1731 | }, |
| 1732 | }; | 1732 | }; |
| 1733 | 1733 | ||