mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
service: mii: Address review comments
This commit is contained in:
parent
2fb71aecb0
commit
dca36ebb87
@ -288,7 +288,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);
|
||||||
|
|
||||||
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);
|
||||||
@ -304,7 +304,6 @@ private:
|
|||||||
new_index);
|
new_index);
|
||||||
|
|
||||||
Result result = ResultSuccess;
|
Result result = ResultSuccess;
|
||||||
|
|
||||||
if (!is_system) {
|
if (!is_system) {
|
||||||
result = ResultPermissionDenied;
|
result = ResultPermissionDenied;
|
||||||
}
|
}
|
||||||
@ -366,7 +365,7 @@ private:
|
|||||||
|
|
||||||
void DestroyFile(HLERequestContext& ctx) {
|
void DestroyFile(HLERequestContext& ctx) {
|
||||||
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
||||||
bool is_db_test_mode_enabled = false;
|
const bool is_db_test_mode_enabled = false;
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
||||||
|
|
||||||
@ -386,7 +385,7 @@ private:
|
|||||||
|
|
||||||
void DeleteFile(HLERequestContext& ctx) {
|
void DeleteFile(HLERequestContext& ctx) {
|
||||||
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
||||||
bool is_db_test_mode_enabled = false;
|
const bool is_db_test_mode_enabled = false;
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
||||||
|
|
||||||
@ -406,7 +405,7 @@ private:
|
|||||||
|
|
||||||
void Format(HLERequestContext& ctx) {
|
void Format(HLERequestContext& ctx) {
|
||||||
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
// This calls nn::settings::fwdbg::GetSettingsItemValue("is_db_test_mode_enabled");
|
||||||
bool is_db_test_mode_enabled = false;
|
const bool is_db_test_mode_enabled = false;
|
||||||
|
|
||||||
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled);
|
||||||
|
|
||||||
@ -427,7 +426,7 @@ private:
|
|||||||
void IsBrokenDatabaseWithClearFlag(HLERequestContext& ctx) {
|
void IsBrokenDatabaseWithClearFlag(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
|
||||||
bool is_broken_with_clear_flag{};
|
bool is_broken_with_clear_flag = false;
|
||||||
Result result = ResultSuccess;
|
Result result = ResultSuccess;
|
||||||
|
|
||||||
if (!is_system) {
|
if (!is_system) {
|
||||||
@ -547,7 +546,7 @@ private:
|
|||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushIpcInterface<IDatabaseService>(system, is_system);
|
rb.PushIpcInterface<IDatabaseService>(system, is_system);
|
||||||
|
|
||||||
LOG_CRITICAL(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_system{};
|
bool is_system{};
|
||||||
@ -580,14 +579,14 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Initialize(HLERequestContext& ctx) {
|
void Initialize(HLERequestContext& ctx) {
|
||||||
LOG_CRITICAL(Service_Mii, "called");
|
LOG_INFO(Service_Mii, "called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetCount(HLERequestContext& ctx) {
|
void GetCount(HLERequestContext& ctx) {
|
||||||
LOG_CRITICAL(Service_Mii, "called");
|
LOG_DEBUG(Service_Mii, "called");
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
@ -606,4 +605,4 @@ void LoopProcess(Core::System& system) {
|
|||||||
ServerManager::RunServer(std::move(server_manager));
|
ServerManager::RunServer(std::move(server_manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::Mii
|
} // namespace Service::Mii
|
||||||
|
@ -18,7 +18,7 @@ bool NintendoFigurineDatabase::IsFull() const {
|
|||||||
StoreData NintendoFigurineDatabase::Get(std::size_t index) const {
|
StoreData NintendoFigurineDatabase::Get(std::size_t index) const {
|
||||||
StoreData store_data = miis.at(index);
|
StoreData store_data = miis.at(index);
|
||||||
|
|
||||||
// This hack is to make external database dump compatible
|
// This hack is to make external database dumps compatible
|
||||||
store_data.SetDeviceChecksum();
|
store_data.SetDeviceChecksum();
|
||||||
|
|
||||||
return store_data;
|
return store_data;
|
||||||
@ -60,13 +60,13 @@ Result NintendoFigurineDatabase::Move(u32 current_index, u32 new_index) {
|
|||||||
const StoreData store_data = miis[current_index];
|
const StoreData store_data = miis[current_index];
|
||||||
|
|
||||||
if (new_index > current_index) {
|
if (new_index > current_index) {
|
||||||
// shift left
|
// Shift left
|
||||||
const u32 index_diff = new_index - current_index;
|
const u32 index_diff = new_index - current_index;
|
||||||
for (std::size_t i = 0; i < index_diff; i++) {
|
for (std::size_t i = 0; i < index_diff; i++) {
|
||||||
miis[current_index + i] = miis[current_index + i + 1];
|
miis[current_index + i] = miis[current_index + i + 1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// shift right
|
// Shift right
|
||||||
const u32 index_diff = current_index - new_index;
|
const u32 index_diff = current_index - new_index;
|
||||||
for (std::size_t i = 0; i < index_diff; i++) {
|
for (std::size_t i = 0; i < index_diff; i++) {
|
||||||
miis[current_index - i] = miis[current_index - i - 1];
|
miis[current_index - i] = miis[current_index - i - 1];
|
||||||
@ -90,8 +90,8 @@ void NintendoFigurineDatabase::Add(const StoreData& store_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NintendoFigurineDatabase::Delete(u32 index) {
|
void NintendoFigurineDatabase::Delete(u32 index) {
|
||||||
// shift left
|
// Shift left
|
||||||
s32 new_database_size = database_length - 1;
|
const s32 new_database_size = database_length - 1;
|
||||||
if (static_cast<s32>(index) < new_database_size) {
|
if (static_cast<s32>(index) < new_database_size) {
|
||||||
for (std::size_t i = index; i < static_cast<std::size_t>(new_database_size); i++) {
|
for (std::size_t i = index; i < static_cast<std::size_t>(new_database_size); i++) {
|
||||||
miis[i] = miis[i + 1];
|
miis[i] = miis[i + 1];
|
||||||
@ -103,7 +103,7 @@ void NintendoFigurineDatabase::Delete(u32 index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NintendoFigurineDatabase::CleanDatabase() {
|
void NintendoFigurineDatabase::CleanDatabase() {
|
||||||
memset(miis.data(), 0, sizeof(miis));
|
miis = {};
|
||||||
version = 1;
|
version = 1;
|
||||||
magic = DatabaseMagic;
|
magic = DatabaseMagic;
|
||||||
database_length = 0;
|
database_length = 0;
|
||||||
|
@ -17,13 +17,13 @@ public:
|
|||||||
/// Returns the total mii count.
|
/// Returns the total mii count.
|
||||||
u8 GetDatabaseLength() const;
|
u8 GetDatabaseLength() const;
|
||||||
|
|
||||||
/// Returns full if database is full.
|
/// Returns true if database is full.
|
||||||
bool IsFull() const;
|
bool IsFull() const;
|
||||||
|
|
||||||
/// Returns the mii of the specified index.
|
/// Returns the mii of the specified index.
|
||||||
StoreData Get(std::size_t index) const;
|
StoreData Get(std::size_t index) const;
|
||||||
|
|
||||||
/// Returns the total mii count. Ignoring special mii.
|
/// Returns the total mii count. Ignoring special mii.
|
||||||
u32 GetCount(const DatabaseSessionMetadata& metadata) const;
|
u32 GetCount(const DatabaseSessionMetadata& metadata) const;
|
||||||
|
|
||||||
/// Returns the index of a mii. If the mii isn't found returns false.
|
/// Returns the index of a mii. If the mii isn't found returns false.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include "core/hle/service/mii/types/store_data.h"
|
#include "core/hle/service/mii/types/store_data.h"
|
||||||
|
|
||||||
namespace Service::Mii {
|
namespace Service::Mii {
|
||||||
constexpr std::string DbFileName = "MiiDatabase.dat";
|
const char* DbFileName = "MiiDatabase.dat";
|
||||||
|
|
||||||
DatabaseManager::DatabaseManager() {}
|
DatabaseManager::DatabaseManager() {}
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ Result DatabaseManager::DestroyFile(DatabaseSessionMetadata& metadata) {
|
|||||||
|
|
||||||
Result DatabaseManager::DeleteFile() {
|
Result DatabaseManager::DeleteFile() {
|
||||||
const bool result = Common::FS::RemoveFile(system_save_dir / DbFileName);
|
const bool result = Common::FS::RemoveFile(system_save_dir / DbFileName);
|
||||||
// Return proper FS error here
|
// TODO: Return proper FS error here
|
||||||
return result ? ResultSuccess : ResultUnknown;
|
return result ? ResultSuccess : ResultUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
namespace Service::Mii {
|
namespace Service::Mii {
|
||||||
|
|
||||||
|
constexpr std::size_t MaxNameSize = 10;
|
||||||
constexpr u8 MaxHeight = 127;
|
constexpr u8 MaxHeight = 127;
|
||||||
constexpr u8 MaxBuild = 127;
|
constexpr u8 MaxBuild = 127;
|
||||||
constexpr u8 MaxType = 1;
|
constexpr u8 MaxType = 1;
|
||||||
@ -604,8 +605,7 @@ enum class ValidationResult : u32 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Nickname {
|
struct Nickname {
|
||||||
static constexpr std::size_t MaxNameSize = 10;
|
std::array<char16_t, MaxNameSize> data{};
|
||||||
std::array<char16_t, MaxNameSize> data;
|
|
||||||
|
|
||||||
// Checks for null or dirty strings
|
// Checks for null or dirty strings
|
||||||
bool IsValid() const {
|
bool IsValid() const {
|
||||||
|
@ -214,5 +214,6 @@ private:
|
|||||||
Nickname name{};
|
Nickname name{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CoreData) == 0x30, "CoreData has incorrect size.");
|
static_assert(sizeof(CoreData) == 0x30, "CoreData has incorrect size.");
|
||||||
|
static_assert(std::is_trivially_copyable_v<CoreData>, "CoreData type must be trivially copyable.");
|
||||||
|
|
||||||
}; // namespace Service::Mii
|
}; // namespace Service::Mii
|
||||||
|
@ -138,6 +138,8 @@ private:
|
|||||||
u16 device_crc{};
|
u16 device_crc{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(StoreData) == 0x44, "StoreData has incorrect size.");
|
static_assert(sizeof(StoreData) == 0x44, "StoreData has incorrect size.");
|
||||||
|
static_assert(std::is_trivially_copyable_v<StoreData>,
|
||||||
|
"StoreData type must be trivially copyable.");
|
||||||
|
|
||||||
struct StoreDataElement {
|
struct StoreDataElement {
|
||||||
StoreData store_data{};
|
StoreData store_data{};
|
||||||
|
Loading…
Reference in New Issue
Block a user