mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
service: ac: Replace intances of ProfileData with UserData
This commit is contained in:
parent
802bbb2263
commit
32b522b1fd
|
@ -290,7 +290,7 @@ protected:
|
||||||
void Get(Kernel::HLERequestContext& ctx) {
|
void Get(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
LOG_DEBUG(Service_ACC, "called user_id=0x{}", user_id.RawString());
|
||||||
ProfileBase profile_base{};
|
ProfileBase profile_base{};
|
||||||
ProfileData data{};
|
UserData data{};
|
||||||
if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) {
|
if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) {
|
||||||
ctx.WriteBuffer(data);
|
ctx.WriteBuffer(data);
|
||||||
IPC::ResponseBuilder rb{ctx, 16};
|
IPC::ResponseBuilder rb{ctx, 16};
|
||||||
|
@ -373,18 +373,18 @@ protected:
|
||||||
reinterpret_cast<const char*>(base.username.data()), base.username.size()),
|
reinterpret_cast<const char*>(base.username.data()), base.username.size()),
|
||||||
base.timestamp, base.user_uuid.RawString());
|
base.timestamp, base.user_uuid.RawString());
|
||||||
|
|
||||||
if (user_data.size() < sizeof(ProfileData)) {
|
if (user_data.size() < sizeof(UserData)) {
|
||||||
LOG_ERROR(Service_ACC, "ProfileData buffer too small!");
|
LOG_ERROR(Service_ACC, "UserData buffer too small!");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ERR_INVALID_BUFFER);
|
rb.Push(ERR_INVALID_BUFFER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileData data;
|
UserData data;
|
||||||
std::memcpy(&data, user_data.data(), sizeof(ProfileData));
|
std::memcpy(&data, user_data.data(), sizeof(UserData));
|
||||||
|
|
||||||
if (!profile_manager.SetProfileBaseAndData(user_id, base, data)) {
|
if (!profile_manager.SetProfileBaseAndData(user_id, base, data)) {
|
||||||
LOG_ERROR(Service_ACC, "Failed to update profile data and base!");
|
LOG_ERROR(Service_ACC, "Failed to update user data and base!");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ERR_FAILED_SAVE_DATA);
|
rb.Push(ERR_FAILED_SAVE_DATA);
|
||||||
return;
|
return;
|
||||||
|
@ -406,15 +406,15 @@ protected:
|
||||||
reinterpret_cast<const char*>(base.username.data()), base.username.size()),
|
reinterpret_cast<const char*>(base.username.data()), base.username.size()),
|
||||||
base.timestamp, base.user_uuid.RawString());
|
base.timestamp, base.user_uuid.RawString());
|
||||||
|
|
||||||
if (user_data.size() < sizeof(ProfileData)) {
|
if (user_data.size() < sizeof(UserData)) {
|
||||||
LOG_ERROR(Service_ACC, "ProfileData buffer too small!");
|
LOG_ERROR(Service_ACC, "UserData buffer too small!");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ERR_INVALID_BUFFER);
|
rb.Push(ERR_INVALID_BUFFER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileData data;
|
UserData data;
|
||||||
std::memcpy(&data, user_data.data(), sizeof(ProfileData));
|
std::memcpy(&data, user_data.data(), sizeof(UserData));
|
||||||
|
|
||||||
Common::FS::IOFile image(GetImagePath(user_id), Common::FS::FileAccessMode::Write,
|
Common::FS::IOFile image(GetImagePath(user_id), Common::FS::FileAccessMode::Write,
|
||||||
Common::FS::FileType::BinaryFile);
|
Common::FS::FileType::BinaryFile);
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct UserRaw {
|
||||||
UUID uuid2{};
|
UUID uuid2{};
|
||||||
u64 timestamp{};
|
u64 timestamp{};
|
||||||
ProfileUsername username{};
|
ProfileUsername username{};
|
||||||
ProfileData extra_data{};
|
UserData extra_data{};
|
||||||
};
|
};
|
||||||
static_assert(sizeof(UserRaw) == 0xC8, "UserRaw has incorrect size.");
|
static_assert(sizeof(UserRaw) == 0xC8, "UserRaw has incorrect size.");
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ UUID ProfileManager::GetLastOpenedUser() const {
|
||||||
|
|
||||||
/// Return the users profile base and the unknown arbitary data.
|
/// Return the users profile base and the unknown arbitary data.
|
||||||
bool ProfileManager::GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile,
|
bool ProfileManager::GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile,
|
||||||
ProfileData& data) const {
|
UserData& data) const {
|
||||||
if (GetProfileBase(index, profile)) {
|
if (GetProfileBase(index, profile)) {
|
||||||
data = profiles[*index].data;
|
data = profiles[*index].data;
|
||||||
return true;
|
return true;
|
||||||
|
@ -272,15 +272,14 @@ bool ProfileManager::GetProfileBaseAndData(std::optional<std::size_t> index, Pro
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the users profile base and the unknown arbitary data.
|
/// Return the users profile base and the unknown arbitary data.
|
||||||
bool ProfileManager::GetProfileBaseAndData(UUID uuid, ProfileBase& profile,
|
bool ProfileManager::GetProfileBaseAndData(UUID uuid, ProfileBase& profile, UserData& data) const {
|
||||||
ProfileData& data) const {
|
|
||||||
const auto idx = GetUserIndex(uuid);
|
const auto idx = GetUserIndex(uuid);
|
||||||
return GetProfileBaseAndData(idx, profile, data);
|
return GetProfileBaseAndData(idx, profile, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the users profile base and the unknown arbitary data.
|
/// Return the users profile base and the unknown arbitary data.
|
||||||
bool ProfileManager::GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile,
|
bool ProfileManager::GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile,
|
||||||
ProfileData& data) const {
|
UserData& data) const {
|
||||||
return GetProfileBaseAndData(user.user_uuid, profile, data);
|
return GetProfileBaseAndData(user.user_uuid, profile, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +317,7 @@ bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileManager::SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& profile_new,
|
bool ProfileManager::SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& profile_new,
|
||||||
const ProfileData& data_new) {
|
const UserData& data_new) {
|
||||||
const auto index = GetUserIndex(uuid);
|
const auto index = GetUserIndex(uuid);
|
||||||
if (index.has_value() && SetProfileBase(uuid, profile_new)) {
|
if (index.has_value() && SetProfileBase(uuid, profile_new)) {
|
||||||
profiles[*index].data = data_new;
|
profiles[*index].data = data_new;
|
||||||
|
|
|
@ -22,7 +22,7 @@ using UserIDArray = std::array<Common::UUID, MAX_USERS>;
|
||||||
|
|
||||||
/// Contains extra data related to a user.
|
/// Contains extra data related to a user.
|
||||||
/// TODO: RE this structure
|
/// TODO: RE this structure
|
||||||
struct ProfileData {
|
struct UserData {
|
||||||
INSERT_PADDING_WORDS_NOINIT(1);
|
INSERT_PADDING_WORDS_NOINIT(1);
|
||||||
u32 icon_id;
|
u32 icon_id;
|
||||||
u8 bg_color_id;
|
u8 bg_color_id;
|
||||||
|
@ -30,7 +30,7 @@ struct ProfileData {
|
||||||
INSERT_PADDING_BYTES_NOINIT(0x10);
|
INSERT_PADDING_BYTES_NOINIT(0x10);
|
||||||
INSERT_PADDING_BYTES_NOINIT(0x60);
|
INSERT_PADDING_BYTES_NOINIT(0x60);
|
||||||
};
|
};
|
||||||
static_assert(sizeof(ProfileData) == 0x80, "ProfileData structure has incorrect size");
|
static_assert(sizeof(UserData) == 0x80, "UserData structure has incorrect size");
|
||||||
|
|
||||||
/// This holds general information about a users profile. This is where we store all the information
|
/// This holds general information about a users profile. This is where we store all the information
|
||||||
/// based on a specific user
|
/// based on a specific user
|
||||||
|
@ -38,7 +38,7 @@ struct ProfileInfo {
|
||||||
Common::UUID user_uuid{};
|
Common::UUID user_uuid{};
|
||||||
ProfileUsername username{};
|
ProfileUsername username{};
|
||||||
u64 creation_time{};
|
u64 creation_time{};
|
||||||
ProfileData data{}; // TODO(ognik): Work out what this is
|
UserData data{}; // TODO(ognik): Work out what this is
|
||||||
bool is_open{};
|
bool is_open{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,10 +74,9 @@ public:
|
||||||
bool GetProfileBase(Common::UUID uuid, ProfileBase& profile) const;
|
bool GetProfileBase(Common::UUID uuid, ProfileBase& profile) const;
|
||||||
bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const;
|
bool GetProfileBase(const ProfileInfo& user, ProfileBase& profile) const;
|
||||||
bool GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile,
|
bool GetProfileBaseAndData(std::optional<std::size_t> index, ProfileBase& profile,
|
||||||
ProfileData& data) const;
|
UserData& data) const;
|
||||||
bool GetProfileBaseAndData(Common::UUID uuid, ProfileBase& profile, ProfileData& data) const;
|
bool GetProfileBaseAndData(Common::UUID uuid, ProfileBase& profile, UserData& data) const;
|
||||||
bool GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile,
|
bool GetProfileBaseAndData(const ProfileInfo& user, ProfileBase& profile, UserData& data) const;
|
||||||
ProfileData& data) const;
|
|
||||||
std::size_t GetUserCount() const;
|
std::size_t GetUserCount() const;
|
||||||
std::size_t GetOpenUserCount() const;
|
std::size_t GetOpenUserCount() const;
|
||||||
bool UserExists(Common::UUID uuid) const;
|
bool UserExists(Common::UUID uuid) const;
|
||||||
|
@ -93,7 +92,7 @@ public:
|
||||||
bool RemoveUser(Common::UUID uuid);
|
bool RemoveUser(Common::UUID uuid);
|
||||||
bool SetProfileBase(Common::UUID uuid, const ProfileBase& profile_new);
|
bool SetProfileBase(Common::UUID uuid, const ProfileBase& profile_new);
|
||||||
bool SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& profile_new,
|
bool SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& profile_new,
|
||||||
const ProfileData& data_new);
|
const UserData& data_new);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseUserSaveFile();
|
void ParseUserSaveFile();
|
||||||
|
|
Loading…
Reference in a new issue