service/cfg: Make GenerateConsoleUniqueId() return a pair (#5321)
Same behavior, but allows the use of structured bindings.
This commit is contained in:
parent
41abdb505c
commit
30414eeb4b
|
@ -439,9 +439,7 @@ void ConfigureSystem::RefreshConsoleID() {
|
|||
return;
|
||||
}
|
||||
|
||||
u32 random_number;
|
||||
u64 console_id;
|
||||
cfg->GenerateConsoleUniqueId(random_number, console_id);
|
||||
const auto [random_number, console_id] = cfg->GenerateConsoleUniqueId();
|
||||
cfg->SetConsoleUniqueId(random_number, console_id);
|
||||
cfg->UpdateConfigNANDSavegame();
|
||||
ui->label_console_id->setText(
|
||||
|
|
|
@ -465,9 +465,7 @@ ResultCode Module::FormatConfig() {
|
|||
if (!res.IsSuccess())
|
||||
return res;
|
||||
|
||||
u32 random_number;
|
||||
u64 console_id;
|
||||
GenerateConsoleUniqueId(random_number, console_id);
|
||||
const auto [random_number, console_id] = GenerateConsoleUniqueId();
|
||||
|
||||
u64_le console_id_le = console_id;
|
||||
res = CreateConfigInfoBlk(ConsoleUniqueID1BlockID, sizeof(console_id_le), 0xE, &console_id_le);
|
||||
|
@ -727,13 +725,18 @@ u8 Module::GetCountryCode() {
|
|||
return block.country_code;
|
||||
}
|
||||
|
||||
void Module::GenerateConsoleUniqueId(u32& random_number, u64& console_id) {
|
||||
std::pair<u32, u64> Module::GenerateConsoleUniqueId() const {
|
||||
CryptoPP::AutoSeededRandomPool rng;
|
||||
random_number = rng.GenerateWord32(0, 0xFFFF);
|
||||
const u32 random_number = rng.GenerateWord32(0, 0xFFFF);
|
||||
|
||||
u64_le local_friend_code_seed;
|
||||
rng.GenerateBlock(reinterpret_cast<CryptoPP::byte*>(&local_friend_code_seed),
|
||||
sizeof(local_friend_code_seed));
|
||||
console_id = (local_friend_code_seed & 0x3FFFFFFFF) | (static_cast<u64>(random_number) << 48);
|
||||
|
||||
const u64 console_id =
|
||||
(local_friend_code_seed & 0x3FFFFFFFF) | (static_cast<u64>(random_number) << 48);
|
||||
|
||||
return std::make_pair(random_number, console_id);
|
||||
}
|
||||
|
||||
ResultCode Module::SetConsoleUniqueId(u32 random_number, u64 console_id) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <array>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
@ -383,12 +384,13 @@ public:
|
|||
|
||||
/**
|
||||
* Generates a new random console unique id.
|
||||
* @param random_number a random generated 16bit number stored at 0x90002, used for generating
|
||||
* the
|
||||
* console_id
|
||||
* @param console_id the randomly created console id
|
||||
*
|
||||
* @returns A pair containing a random number and a random console ID.
|
||||
*
|
||||
* @note The random number is a random generated 16bit number stored at 0x90002, used for
|
||||
* generating the console ID.
|
||||
*/
|
||||
void GenerateConsoleUniqueId(u32& random_number, u64& console_id);
|
||||
std::pair<u32, u64> GenerateConsoleUniqueId() const;
|
||||
|
||||
/**
|
||||
* Sets the random_number and the console unique id in the config savegame.
|
||||
|
|
Reference in New Issue