summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/mii/mii.cpp19
-rw-r--r--src/core/hle/service/mii/mii_database.cpp12
-rw-r--r--src/core/hle/service/mii/mii_database.h4
-rw-r--r--src/core/hle/service/mii/mii_database_manager.cpp4
-rw-r--r--src/core/hle/service/mii/mii_types.h4
-rw-r--r--src/core/hle/service/mii/types/core_data.h1
-rw-r--r--src/core/hle/service/mii/types/store_data.h2
7 files changed, 24 insertions, 22 deletions
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp
index dae95ea68..8de806cfb 100644
--- a/src/core/hle/service/mii/mii.cpp
+++ b/src/core/hle/service/mii/mii.cpp
@@ -288,7 +288,7 @@ private:
288 LOG_INFO(Service_Mii, "called with create_id={}, is_special={}", 288 LOG_INFO(Service_Mii, "called with create_id={}, is_special={}",
289 create_id.FormattedString(), is_special); 289 create_id.FormattedString(), is_special);
290 290
291 s32 index = manager.FindIndex(create_id, is_special); 291 const s32 index = manager.FindIndex(create_id, is_special);
292 292
293 IPC::ResponseBuilder rb{ctx, 3}; 293 IPC::ResponseBuilder rb{ctx, 3};
294 rb.Push(ResultSuccess); 294 rb.Push(ResultSuccess);
@@ -304,7 +304,6 @@ private:
304 new_index); 304 new_index);
305 305
306 Result result = ResultSuccess; 306 Result result = ResultSuccess;
307
308 if (!is_system) { 307 if (!is_system) {
309 result = ResultPermissionDenied; 308 result = ResultPermissionDenied;
310 } 309 }
@@ -366,7 +365,7 @@ private:
366 365
367 void DestroyFile(HLERequestContext& ctx) { 366 void DestroyFile(HLERequestContext& ctx) {
368 // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled"); 367 // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
369 bool is_db_test_mode_enabled = false; 368 const bool is_db_test_mode_enabled = false;
370 369
371 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); 370 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
372 371
@@ -386,7 +385,7 @@ private:
386 385
387 void DeleteFile(HLERequestContext& ctx) { 386 void DeleteFile(HLERequestContext& ctx) {
388 // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled"); 387 // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
389 bool is_db_test_mode_enabled = false; 388 const bool is_db_test_mode_enabled = false;
390 389
391 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); 390 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
392 391
@@ -406,7 +405,7 @@ private:
406 405
407 void Format(HLERequestContext& ctx) { 406 void Format(HLERequestContext& ctx) {
408 // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled"); 407 // This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
409 bool is_db_test_mode_enabled = false; 408 const bool is_db_test_mode_enabled = false;
410 409
411 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); 410 LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
412 411
@@ -427,7 +426,7 @@ private:
427 void IsBrokenDatabaseWithClearFlag(HLERequestContext& ctx) { 426 void IsBrokenDatabaseWithClearFlag(HLERequestContext& ctx) {
428 LOG_DEBUG(Service_Mii, "called"); 427 LOG_DEBUG(Service_Mii, "called");
429 428
430 bool is_broken_with_clear_flag{}; 429 bool is_broken_with_clear_flag = false;
431 Result result = ResultSuccess; 430 Result result = ResultSuccess;
432 431
433 if (!is_system) { 432 if (!is_system) {
@@ -547,7 +546,7 @@ private:
547 rb.Push(ResultSuccess); 546 rb.Push(ResultSuccess);
548 rb.PushIpcInterface<IDatabaseService>(system, is_system); 547 rb.PushIpcInterface<IDatabaseService>(system, is_system);
549 548
550 LOG_CRITICAL(Service_Mii, "called"); 549 LOG_DEBUG(Service_Mii, "called");
551 } 550 }
552 551
553 bool is_system{}; 552 bool is_system{};
@@ -580,14 +579,14 @@ public:
580 579
581private: 580private:
582 void Initialize(HLERequestContext& ctx) { 581 void Initialize(HLERequestContext& ctx) {
583 LOG_CRITICAL(Service_Mii, "called"); 582 LOG_INFO(Service_Mii, "called");
584 583
585 IPC::ResponseBuilder rb{ctx, 2}; 584 IPC::ResponseBuilder rb{ctx, 2};
586 rb.Push(ResultSuccess); 585 rb.Push(ResultSuccess);
587 } 586 }
588 587
589 void GetCount(HLERequestContext& ctx) { 588 void GetCount(HLERequestContext& ctx) {
590 LOG_CRITICAL(Service_Mii, "called"); 589 LOG_DEBUG(Service_Mii, "called");
591 590
592 IPC::ResponseBuilder rb{ctx, 3}; 591 IPC::ResponseBuilder rb{ctx, 3};
593 rb.Push(ResultSuccess); 592 rb.Push(ResultSuccess);
@@ -606,4 +605,4 @@ void LoopProcess(Core::System& system) {
606 ServerManager::RunServer(std::move(server_manager)); 605 ServerManager::RunServer(std::move(server_manager));
607} 606}
608 607
609} // namespace Service::Mii \ No newline at end of file 608} // namespace Service::Mii
diff --git a/src/core/hle/service/mii/mii_database.cpp b/src/core/hle/service/mii/mii_database.cpp
index 0899f0b45..3803e58e2 100644
--- a/src/core/hle/service/mii/mii_database.cpp
+++ b/src/core/hle/service/mii/mii_database.cpp
@@ -18,7 +18,7 @@ bool NintendoFigurineDatabase::IsFull() const {
18StoreData NintendoFigurineDatabase::Get(std::size_t index) const { 18StoreData NintendoFigurineDatabase::Get(std::size_t index) const {
19 StoreData store_data = miis.at(index); 19 StoreData store_data = miis.at(index);
20 20
21 // This hack is to make external database dump compatible 21 // This hack is to make external database dumps compatible
22 store_data.SetDeviceChecksum(); 22 store_data.SetDeviceChecksum();
23 23
24 return store_data; 24 return store_data;
@@ -60,13 +60,13 @@ Result NintendoFigurineDatabase::Move(u32 current_index, u32 new_index) {
60 const StoreData store_data = miis[current_index]; 60 const StoreData store_data = miis[current_index];
61 61
62 if (new_index > current_index) { 62 if (new_index > current_index) {
63 // shift left 63 // Shift left
64 const u32 index_diff = new_index - current_index; 64 const u32 index_diff = new_index - current_index;
65 for (std::size_t i = 0; i < index_diff; i++) { 65 for (std::size_t i = 0; i < index_diff; i++) {
66 miis[current_index + i] = miis[current_index + i + 1]; 66 miis[current_index + i] = miis[current_index + i + 1];
67 } 67 }
68 } else { 68 } else {
69 // shift right 69 // Shift right
70 const u32 index_diff = current_index - new_index; 70 const u32 index_diff = current_index - new_index;
71 for (std::size_t i = 0; i < index_diff; i++) { 71 for (std::size_t i = 0; i < index_diff; i++) {
72 miis[current_index - i] = miis[current_index - i - 1]; 72 miis[current_index - i] = miis[current_index - i - 1];
@@ -90,8 +90,8 @@ void NintendoFigurineDatabase::Add(const StoreData& store_data) {
90} 90}
91 91
92void NintendoFigurineDatabase::Delete(u32 index) { 92void NintendoFigurineDatabase::Delete(u32 index) {
93 // shift left 93 // Shift left
94 s32 new_database_size = database_length - 1; 94 const s32 new_database_size = database_length - 1;
95 if (static_cast<s32>(index) < new_database_size) { 95 if (static_cast<s32>(index) < new_database_size) {
96 for (std::size_t i = index; i < static_cast<std::size_t>(new_database_size); i++) { 96 for (std::size_t i = index; i < static_cast<std::size_t>(new_database_size); i++) {
97 miis[i] = miis[i + 1]; 97 miis[i] = miis[i + 1];
@@ -103,7 +103,7 @@ void NintendoFigurineDatabase::Delete(u32 index) {
103} 103}
104 104
105void NintendoFigurineDatabase::CleanDatabase() { 105void NintendoFigurineDatabase::CleanDatabase() {
106 memset(miis.data(), 0, sizeof(miis)); 106 miis = {};
107 version = 1; 107 version = 1;
108 magic = DatabaseMagic; 108 magic = DatabaseMagic;
109 database_length = 0; 109 database_length = 0;
diff --git a/src/core/hle/service/mii/mii_database.h b/src/core/hle/service/mii/mii_database.h
index 01764999f..3bd240f93 100644
--- a/src/core/hle/service/mii/mii_database.h
+++ b/src/core/hle/service/mii/mii_database.h
@@ -17,13 +17,13 @@ public:
17 /// Returns the total mii count. 17 /// Returns the total mii count.
18 u8 GetDatabaseLength() const; 18 u8 GetDatabaseLength() const;
19 19
20 /// Returns full if database is full. 20 /// Returns true if database is full.
21 bool IsFull() const; 21 bool IsFull() const;
22 22
23 /// Returns the mii of the specified index. 23 /// Returns the mii of the specified index.
24 StoreData Get(std::size_t index) const; 24 StoreData Get(std::size_t index) const;
25 25
26 /// Returns the total mii count. Ignoring special mii. 26 /// Returns the total mii count. Ignoring special mii.
27 u32 GetCount(const DatabaseSessionMetadata& metadata) const; 27 u32 GetCount(const DatabaseSessionMetadata& metadata) const;
28 28
29 /// Returns the index of a mii. If the mii isn't found returns false. 29 /// Returns the index of a mii. If the mii isn't found returns false.
diff --git a/src/core/hle/service/mii/mii_database_manager.cpp b/src/core/hle/service/mii/mii_database_manager.cpp
index 63c411690..c39898594 100644
--- a/src/core/hle/service/mii/mii_database_manager.cpp
+++ b/src/core/hle/service/mii/mii_database_manager.cpp
@@ -15,7 +15,7 @@
15#include "core/hle/service/mii/types/store_data.h" 15#include "core/hle/service/mii/types/store_data.h"
16 16
17namespace Service::Mii { 17namespace Service::Mii {
18constexpr std::string DbFileName = "MiiDatabase.dat"; 18const char* DbFileName = "MiiDatabase.dat";
19 19
20DatabaseManager::DatabaseManager() {} 20DatabaseManager::DatabaseManager() {}
21 21
@@ -371,7 +371,7 @@ Result DatabaseManager::DestroyFile(DatabaseSessionMetadata& metadata) {
371 371
372Result DatabaseManager::DeleteFile() { 372Result DatabaseManager::DeleteFile() {
373 const bool result = Common::FS::RemoveFile(system_save_dir / DbFileName); 373 const bool result = Common::FS::RemoveFile(system_save_dir / DbFileName);
374 // Return proper FS error here 374 // TODO: Return proper FS error here
375 return result ? ResultSuccess : ResultUnknown; 375 return result ? ResultSuccess : ResultUnknown;
376} 376}
377 377
diff --git a/src/core/hle/service/mii/mii_types.h b/src/core/hle/service/mii/mii_types.h
index 9efe6c915..f43efd83c 100644
--- a/src/core/hle/service/mii/mii_types.h
+++ b/src/core/hle/service/mii/mii_types.h
@@ -13,6 +13,7 @@
13 13
14namespace Service::Mii { 14namespace Service::Mii {
15 15
16constexpr std::size_t MaxNameSize = 10;
16constexpr u8 MaxHeight = 127; 17constexpr u8 MaxHeight = 127;
17constexpr u8 MaxBuild = 127; 18constexpr u8 MaxBuild = 127;
18constexpr u8 MaxType = 1; 19constexpr u8 MaxType = 1;
@@ -604,8 +605,7 @@ enum class ValidationResult : u32 {
604}; 605};
605 606
606struct Nickname { 607struct Nickname {
607 static constexpr std::size_t MaxNameSize = 10; 608 std::array<char16_t, MaxNameSize> data{};
608 std::array<char16_t, MaxNameSize> data;
609 609
610 // Checks for null or dirty strings 610 // Checks for null or dirty strings
611 bool IsValid() const { 611 bool IsValid() const {
diff --git a/src/core/hle/service/mii/types/core_data.h b/src/core/hle/service/mii/types/core_data.h
index e6398f68f..8897e4f3b 100644
--- a/src/core/hle/service/mii/types/core_data.h
+++ b/src/core/hle/service/mii/types/core_data.h
@@ -214,5 +214,6 @@ private:
214 Nickname name{}; 214 Nickname name{};
215}; 215};
216static_assert(sizeof(CoreData) == 0x30, "CoreData has incorrect size."); 216static_assert(sizeof(CoreData) == 0x30, "CoreData has incorrect size.");
217static_assert(std::is_trivially_copyable_v<CoreData>, "CoreData type must be trivially copyable.");
217 218
218}; // namespace Service::Mii 219}; // namespace Service::Mii
diff --git a/src/core/hle/service/mii/types/store_data.h b/src/core/hle/service/mii/types/store_data.h
index 38f534d26..ed5dfb949 100644
--- a/src/core/hle/service/mii/types/store_data.h
+++ b/src/core/hle/service/mii/types/store_data.h
@@ -138,6 +138,8 @@ private:
138 u16 device_crc{}; 138 u16 device_crc{};
139}; 139};
140static_assert(sizeof(StoreData) == 0x44, "StoreData has incorrect size."); 140static_assert(sizeof(StoreData) == 0x44, "StoreData has incorrect size.");
141static_assert(std::is_trivially_copyable_v<StoreData>,
142 "StoreData type must be trivially copyable.");
141 143
142struct StoreDataElement { 144struct StoreDataElement {
143 StoreData store_data{}; 145 StoreData store_data{};