summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorDavid Marcec <dmarcecguzman@gmail.com>2018-08-08 17:09:12 +0200
committerDavid Marcec <dmarcecguzman@gmail.com>2018-08-08 17:09:12 +0200
commit75169c75708d9f54297537b387182bee10ada9ab (patch)
tree474dc8046e64ed4eeb57a10e99e93be835918e5b /src/core
parentGetProfileBase and GetProfileBaseAndData added (diff)
downloadyuzu-75169c75708d9f54297537b387182bee10ada9ab.tar
yuzu-75169c75708d9f54297537b387182bee10ada9ab.tar.gz
yuzu-75169c75708d9f54297537b387182bee10ada9ab.tar.bz2
yuzu-75169c75708d9f54297537b387182bee10ada9ab.tar.lz
yuzu-75169c75708d9f54297537b387182bee10ada9ab.tar.xz
yuzu-75169c75708d9f54297537b387182bee10ada9ab.tar.zst
yuzu-75169c75708d9f54297537b387182bee10ada9ab.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/acc/acc.cpp11
-rw-r--r--src/core/hle/service/acc/profile_manager.cpp18
-rw-r--r--src/core/hle/service/acc/profile_manager.h5
3 files changed, 22 insertions, 12 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index 92141f61c..7c62d99f6 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -48,13 +48,6 @@ private:
LOG_INFO(Service_ACC, "called user_id={}", user_id.Format());
ProfileBase profile_base{};
std::array<u8, MAX_DATA> data{};
- /*if (Settings::values.username.size() > profile_base.username.size()) {
- std::copy_n(Settings::values.username.begin(), profile_base.username.size(),
- profile_base.username.begin());
- } else {
- std::copy(Settings::values.username.begin(), Settings::values.username.end(),
- profile_base.username.begin());
- }*/
if (profile_manager.GetProfileBaseAndData(user_id, profile_base, data)) {
ctx.WriteBuffer(data);
IPC::ResponseBuilder rb{ctx, 16};
@@ -177,7 +170,9 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo
}
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
- : ServiceFramework(name), module(std::move(module)) {}
+ : ServiceFramework(name), module(std::move(module)) {
+ profile_manager = std::make_unique<ProfileManager>();
+}
void InstallInterfaces(SM::ServiceManager& service_manager) {
auto module = std::make_shared<Module>();
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp
index 925022018..1633d5d48 100644
--- a/src/core/hle/service/acc/profile_manager.cpp
+++ b/src/core/hle/service/acc/profile_manager.cpp
@@ -1,3 +1,4 @@
+#include "core/settings.h"
#include "profile_manager.h"
namespace Service::Account {
@@ -5,6 +6,10 @@ namespace Service::Account {
constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, -1);
constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20);
+ProfileManager::ProfileManager() {
+ CreateNewUser(UUID{1, 0}, Settings::values.username);
+}
+
size_t ProfileManager::AddToProfiles(const ProfileInfo& user) {
if (user_count >= MAX_USERS) {
return -1;
@@ -39,14 +44,23 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, std::array<u8, 0x20> usernam
if (username[0] == 0x0)
return ERROR_ARGUMENT_IS_NULL;
ProfileInfo prof_inf;
- prof_inf.user_uuid = uuid;
- prof_inf.username = username;
+ prof_inf.user_uuid = std::move(uuid);
+ prof_inf.username = std::move(username);
prof_inf.data = std::array<u8, MAX_DATA>();
prof_inf.creation_time = 0x0;
prof_inf.is_open = false;
return AddUser(prof_inf);
}
+ResultCode ProfileManager::CreateNewUser(UUID uuid, std::string username) {
+ std::array<u8, 0x20> username_output;
+ if (username.size() > username_output.size())
+ std::copy_n(username.begin(), username_output.size(), username_output.begin());
+ else
+ std::copy(username.begin(), username.end(), username_output.begin());
+ return CreateNewUser(uuid, std::move(username_output));
+}
+
size_t ProfileManager::GetUserIndex(UUID uuid) {
if (!uuid)
return -1;
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h
index cb6239cc1..130041994 100644
--- a/src/core/hle/service/acc/profile_manager.h
+++ b/src/core/hle/service/acc/profile_manager.h
@@ -21,7 +21,7 @@ struct UUID {
uuid[1] = hi;
};
operator bool() const {
- return uuid[0] != 0x0 && uuid[1] != 0x0;
+ return uuid[0] != 0x0 || uuid[1] != 0x0;
}
bool operator==(const UUID& rhs) {
@@ -76,9 +76,10 @@ static_assert(sizeof(ProfileBase) == 0x38, "ProfileBase is an invalid size");
/// objects
class ProfileManager {
public:
- ProfileManager() = default; // TODO(ogniK): Load from system save
+ ProfileManager(); // TODO(ogniK): Load from system save
ResultCode AddUser(ProfileInfo user);
ResultCode CreateNewUser(UUID uuid, std::array<u8, 0x20> username);
+ ResultCode CreateNewUser(UUID uuid, std::string username);
size_t GetUserIndex(UUID uuid);
size_t GetUserIndex(ProfileInfo user);
bool GetProfileBase(size_t index, ProfileBase& profile);