summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-20 17:24:13 -0400
committerGravatar Lioncash2018-08-20 19:48:53 -0400
commitf13a66b963d4ecd53dda7866e947bc3230566d63 (patch)
tree66326dddaf3d61b4cc991323d70ee0cfa9fc38f6 /src/core
parentprofile_manager: Remove unnecessary std::move in AddToProfiles() and CreateNe... (diff)
downloadyuzu-f13a66b963d4ecd53dda7866e947bc3230566d63.tar.gz
yuzu-f13a66b963d4ecd53dda7866e947bc3230566d63.tar.xz
yuzu-f13a66b963d4ecd53dda7866e947bc3230566d63.zip
profile_manager: Move UUID generation function to the cpp file
This avoids needing to dump the contents of <random> into other files that include the profile manager header.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/acc/profile_manager.cpp10
-rw-r--r--src/core/hle/service/acc/profile_manager.h12
2 files changed, 12 insertions, 10 deletions
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp
index fe9921fb6..9440dc555 100644
--- a/src/core/hle/service/acc/profile_manager.cpp
+++ b/src/core/hle/service/acc/profile_manager.cpp
@@ -2,6 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <random>
5#include <boost/optional.hpp> 6#include <boost/optional.hpp>
6#include "core/hle/service/acc/profile_manager.h" 7#include "core/hle/service/acc/profile_manager.h"
7#include "core/settings.h" 8#include "core/settings.h"
@@ -12,6 +13,15 @@ constexpr ResultCode ERROR_TOO_MANY_USERS(ErrorModule::Account, -1);
12constexpr ResultCode ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, -2); 13constexpr ResultCode ERROR_USER_ALREADY_EXISTS(ErrorModule::Account, -2);
13constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20); 14constexpr ResultCode ERROR_ARGUMENT_IS_NULL(ErrorModule::Account, 20);
14 15
16const UUID& UUID::Generate() {
17 std::random_device device;
18 std::mt19937 gen(device());
19 std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
20 uuid[0] = distribution(gen);
21 uuid[1] = distribution(gen);
22 return *this;
23}
24
15ProfileManager::ProfileManager() { 25ProfileManager::ProfileManager() {
16 // TODO(ogniK): Create the default user we have for now until loading/saving users is added 26 // TODO(ogniK): Create the default user we have for now until loading/saving users is added
17 auto user_uuid = UUID{1, 0}; 27 auto user_uuid = UUID{1, 0};
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h
index 314bccbf9..91f6f03a9 100644
--- a/src/core/hle/service/acc/profile_manager.h
+++ b/src/core/hle/service/acc/profile_manager.h
@@ -5,7 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <random> 8
9#include "boost/optional.hpp" 9#include "boost/optional.hpp"
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "common/swap.h" 11#include "common/swap.h"
@@ -38,15 +38,7 @@ struct UUID {
38 } 38 }
39 39
40 // TODO(ogniK): Properly generate uuids based on RFC-4122 40 // TODO(ogniK): Properly generate uuids based on RFC-4122
41 const UUID& Generate() { 41 const UUID& Generate();
42 std::random_device device;
43 std::mt19937 gen(device());
44 std::uniform_int_distribution<uint64_t> distribution(1,
45 std::numeric_limits<uint64_t>::max());
46 uuid[0] = distribution(gen);
47 uuid[1] = distribution(gen);
48 return *this;
49 }
50 42
51 // Set the UUID to {0,0} to be considered an invalid user 43 // Set the UUID to {0,0} to be considered an invalid user
52 void Invalidate() { 44 void Invalidate() {