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={}",
|
||||
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};
|
||||
rb.Push(ResultSuccess);
|
||||
|
@ -304,7 +304,6 @@ private:
|
|||
new_index);
|
||||
|
||||
Result result = ResultSuccess;
|
||||
|
||||
if (!is_system) {
|
||||
result = ResultPermissionDenied;
|
||||
}
|
||||
|
@ -366,7 +365,7 @@ private:
|
|||
|
||||
void DestroyFile(HLERequestContext& ctx) {
|
||||
// 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);
|
||||
|
||||
|
@ -386,7 +385,7 @@ private:
|
|||
|
||||
void DeleteFile(HLERequestContext& ctx) {
|
||||
// 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);
|
||||
|
||||
|
@ -406,7 +405,7 @@ private:
|
|||
|
||||
void Format(HLERequestContext& ctx) {
|
||||
// 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);
|
||||
|
||||
|
@ -427,7 +426,7 @@ private:
|
|||
void IsBrokenDatabaseWithClearFlag(HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_Mii, "called");
|
||||
|
||||
bool is_broken_with_clear_flag{};
|
||||
bool is_broken_with_clear_flag = false;
|
||||
Result result = ResultSuccess;
|
||||
|
||||
if (!is_system) {
|
||||
|
@ -547,7 +546,7 @@ private:
|
|||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IDatabaseService>(system, is_system);
|
||||
|
||||
LOG_CRITICAL(Service_Mii, "called");
|
||||
LOG_DEBUG(Service_Mii, "called");
|
||||
}
|
||||
|
||||
bool is_system{};
|
||||
|
@ -580,14 +579,14 @@ public:
|
|||
|
||||
private:
|
||||
void Initialize(HLERequestContext& ctx) {
|
||||
LOG_CRITICAL(Service_Mii, "called");
|
||||
LOG_INFO(Service_Mii, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void GetCount(HLERequestContext& ctx) {
|
||||
LOG_CRITICAL(Service_Mii, "called");
|
||||
LOG_DEBUG(Service_Mii, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
|
@ -606,4 +605,4 @@ void LoopProcess(Core::System& system) {
|
|||
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 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();
|
||||
|
||||
return store_data;
|
||||
|
@ -60,13 +60,13 @@ Result NintendoFigurineDatabase::Move(u32 current_index, u32 new_index) {
|
|||
const StoreData store_data = miis[current_index];
|
||||
|
||||
if (new_index > current_index) {
|
||||
// shift left
|
||||
// Shift left
|
||||
const u32 index_diff = new_index - current_index;
|
||||
for (std::size_t i = 0; i < index_diff; i++) {
|
||||
miis[current_index + i] = miis[current_index + i + 1];
|
||||
}
|
||||
} else {
|
||||
// shift right
|
||||
// Shift right
|
||||
const u32 index_diff = current_index - new_index;
|
||||
for (std::size_t i = 0; i < index_diff; i++) {
|
||||
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) {
|
||||
// shift left
|
||||
s32 new_database_size = database_length - 1;
|
||||
// Shift left
|
||||
const s32 new_database_size = database_length - 1;
|
||||
if (static_cast<s32>(index) < new_database_size) {
|
||||
for (std::size_t i = index; i < static_cast<std::size_t>(new_database_size); i++) {
|
||||
miis[i] = miis[i + 1];
|
||||
|
@ -103,7 +103,7 @@ void NintendoFigurineDatabase::Delete(u32 index) {
|
|||
}
|
||||
|
||||
void NintendoFigurineDatabase::CleanDatabase() {
|
||||
memset(miis.data(), 0, sizeof(miis));
|
||||
miis = {};
|
||||
version = 1;
|
||||
magic = DatabaseMagic;
|
||||
database_length = 0;
|
||||
|
|
|
@ -17,13 +17,13 @@ public:
|
|||
/// Returns the total mii count.
|
||||
u8 GetDatabaseLength() const;
|
||||
|
||||
/// Returns full if database is full.
|
||||
/// Returns true if database is full.
|
||||
bool IsFull() const;
|
||||
|
||||
/// Returns the mii of the specified index.
|
||||
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;
|
||||
|
||||
/// 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"
|
||||
|
||||
namespace Service::Mii {
|
||||
constexpr std::string DbFileName = "MiiDatabase.dat";
|
||||
const char* DbFileName = "MiiDatabase.dat";
|
||||
|
||||
DatabaseManager::DatabaseManager() {}
|
||||
|
||||
|
@ -371,7 +371,7 @@ Result DatabaseManager::DestroyFile(DatabaseSessionMetadata& metadata) {
|
|||
|
||||
Result DatabaseManager::DeleteFile() {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
namespace Service::Mii {
|
||||
|
||||
constexpr std::size_t MaxNameSize = 10;
|
||||
constexpr u8 MaxHeight = 127;
|
||||
constexpr u8 MaxBuild = 127;
|
||||
constexpr u8 MaxType = 1;
|
||||
|
@ -604,8 +605,7 @@ enum class ValidationResult : u32 {
|
|||
};
|
||||
|
||||
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
|
||||
bool IsValid() const {
|
||||
|
|
|
@ -214,5 +214,6 @@ private:
|
|||
Nickname name{};
|
||||
};
|
||||
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
|
||||
|
|
|
@ -138,6 +138,8 @@ private:
|
|||
u16 device_crc{};
|
||||
};
|
||||
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 {
|
||||
StoreData store_data{};
|
||||
|
|
Loading…
Reference in a new issue