summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar David Marcec2018-08-11 18:46:42 +1000
committerGravatar David Marcec2018-08-11 18:46:42 +1000
commitacff9227626ce0903efbcdf91d1a12b695889d59 (patch)
treea6f7efa2d473e72b11f3bba3d05f8e0310108033 /src
parentSecond round of account changes (diff)
downloadyuzu-acff9227626ce0903efbcdf91d1a12b695889d59.tar.gz
yuzu-acff9227626ce0903efbcdf91d1a12b695889d59.tar.xz
yuzu-acff9227626ce0903efbcdf91d1a12b695889d59.zip
If statement style change
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/acc/profile_manager.cpp30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp
index 14d65ff1b..8f3dab6a0 100644
--- a/src/core/hle/service/acc/profile_manager.cpp
+++ b/src/core/hle/service/acc/profile_manager.cpp
@@ -26,10 +26,12 @@ size_t ProfileManager::AddToProfiles(const ProfileInfo& user) {
26} 26}
27 27
28bool ProfileManager::RemoveProfileAtIdx(size_t index) { 28bool ProfileManager::RemoveProfileAtIdx(size_t index) {
29 if (index >= MAX_USERS || index >= user_count) 29 if (index >= MAX_USERS || index >= user_count) {
30 return false; 30 return false;
31 if (index < user_count - 1) 31 }
32 if (index < user_count - 1) {
32 std::rotate(profiles.begin() + index, profiles.begin() + index + 1, profiles.end()); 33 std::rotate(profiles.begin() + index, profiles.begin() + index + 1, profiles.end());
34 }
33 profiles.back() = {}; 35 profiles.back() = {};
34 user_count--; 36 user_count--;
35 return true; 37 return true;
@@ -43,12 +45,15 @@ ResultCode ProfileManager::AddUser(ProfileInfo user) {
43} 45}
44 46
45ResultCode ProfileManager::CreateNewUser(UUID uuid, std::array<u8, 0x20>& username) { 47ResultCode ProfileManager::CreateNewUser(UUID uuid, std::array<u8, 0x20>& username) {
46 if (user_count == MAX_USERS) 48 if (user_count == MAX_USERS) {
47 return ERROR_TOO_MANY_USERS; 49 return ERROR_TOO_MANY_USERS;
48 if (!uuid) 50 }
51 if (!uuid) {
49 return ERROR_ARGUMENT_IS_NULL; 52 return ERROR_ARGUMENT_IS_NULL;
50 if (username[0] == 0x0) 53 }
54 if (username[0] == 0x0) {
51 return ERROR_ARGUMENT_IS_NULL; 55 return ERROR_ARGUMENT_IS_NULL;
56 }
52 if (std::any_of(profiles.begin(), profiles.end(), 57 if (std::any_of(profiles.begin(), profiles.end(),
53 [&uuid](const ProfileInfo& profile) { return uuid == profile.user_uuid; })) { 58 [&uuid](const ProfileInfo& profile) { return uuid == profile.user_uuid; })) {
54 return ERROR_USER_ALREADY_EXISTS; 59 return ERROR_USER_ALREADY_EXISTS;
@@ -64,17 +69,18 @@ ResultCode ProfileManager::CreateNewUser(UUID uuid, std::array<u8, 0x20>& userna
64 69
65ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username) { 70ResultCode ProfileManager::CreateNewUser(UUID uuid, const std::string& username) {
66 std::array<u8, 0x20> username_output; 71 std::array<u8, 0x20> username_output;
67 if (username.size() > username_output.size()) 72 if (username.size() > username_output.size()) {
68 std::copy_n(username.begin(), username_output.size(), username_output.begin()); 73 std::copy_n(username.begin(), username_output.size(), username_output.begin());
69 else 74 } else {
70 std::copy(username.begin(), username.end(), username_output.begin()); 75 std::copy(username.begin(), username.end(), username_output.begin());
76 }
71 return CreateNewUser(uuid, username_output); 77 return CreateNewUser(uuid, username_output);
72} 78}
73 79
74size_t ProfileManager::GetUserIndex(const UUID& uuid) const { 80size_t ProfileManager::GetUserIndex(const UUID& uuid) const {
75 if (!uuid) 81 if (!uuid) {
76 return std::numeric_limits<size_t>::max(); 82 return std::numeric_limits<size_t>::max();
77 83 }
78 auto iter = std::find_if(profiles.begin(), profiles.end(), 84 auto iter = std::find_if(profiles.begin(), profiles.end(),
79 [&uuid](const ProfileInfo& p) { return p.user_uuid == uuid; }); 85 [&uuid](const ProfileInfo& p) { return p.user_uuid == uuid; });
80 if (iter == profiles.end()) { 86 if (iter == profiles.end()) {
@@ -118,16 +124,18 @@ bool ProfileManager::UserExists(UUID uuid) const {
118 124
119void ProfileManager::OpenUser(UUID uuid) { 125void ProfileManager::OpenUser(UUID uuid) {
120 auto idx = GetUserIndex(uuid); 126 auto idx = GetUserIndex(uuid);
121 if (idx == std::numeric_limits<size_t>::max()) 127 if (idx == std::numeric_limits<size_t>::max()) {
122 return; 128 return;
129 }
123 profiles[idx].is_open = true; 130 profiles[idx].is_open = true;
124 last_opened_user = uuid; 131 last_opened_user = uuid;
125} 132}
126 133
127void ProfileManager::CloseUser(UUID uuid) { 134void ProfileManager::CloseUser(UUID uuid) {
128 auto idx = GetUserIndex(uuid); 135 auto idx = GetUserIndex(uuid);
129 if (idx == std::numeric_limits<size_t>::max()) 136 if (idx == std::numeric_limits<size_t>::max()) {
130 return; 137 return;
138 }
131 profiles[idx].is_open = false; 139 profiles[idx].is_open = false;
132} 140}
133 141