mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-04 05:51:19 +12:00
Replace std::uniform_int_distribution with boost::random::uniform_int_distribution
This commit is contained in:
parent
7cfc4a042d
commit
1f2f21588e
3 changed files with 2 additions and 23 deletions
|
@ -3,15 +3,12 @@
|
||||||
#include "gui/CemuApp.h"
|
#include "gui/CemuApp.h"
|
||||||
#include "util/helpers/SystemException.h"
|
#include "util/helpers/SystemException.h"
|
||||||
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
#include "config/ActiveSettings.h"
|
#include "config/ActiveSettings.h"
|
||||||
#include "Cafe/IOSU/legacy/iosu_crypto.h"
|
#include "Cafe/IOSU/legacy/iosu_crypto.h"
|
||||||
#include "Common/filestream.h"
|
#include "Common/filestream.h"
|
||||||
|
|
||||||
#ifndef __clang__
|
#include <random>
|
||||||
#include <boost/random/uniform_int.hpp>
|
#include <boost/random/uniform_int.hpp>
|
||||||
#endif
|
|
||||||
|
|
||||||
std::vector<Account> Account::s_account_list;
|
std::vector<Account> Account::s_account_list;
|
||||||
|
|
||||||
|
@ -71,12 +68,7 @@ Account::Account(uint32 persistent_id, std::wstring_view mii_name)
|
||||||
static std::mt19937 s_mte(s_random_device());
|
static std::mt19937 s_mte(s_random_device());
|
||||||
|
|
||||||
//Use boost library to escape static asserts in Linux Builds
|
//Use boost library to escape static asserts in Linux Builds
|
||||||
//TODO: Look for fix in libstdc++
|
|
||||||
#ifdef __clang__
|
|
||||||
boost::random::uniform_int_distribution<uint16> dist(std::numeric_limits<uint8>::min(), std::numeric_limits<uint8>::max());
|
boost::random::uniform_int_distribution<uint16> dist(std::numeric_limits<uint8>::min(), std::numeric_limits<uint8>::max());
|
||||||
#else
|
|
||||||
std::uniform_int_distribution<uint16> dist(std::numeric_limits<uint8>::min(), std::numeric_limits<uint8>::max());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::generate(m_uuid.begin(), m_uuid.end(), [&]() { return (uint8)dist(s_mte); });
|
std::generate(m_uuid.begin(), m_uuid.end(), [&]() { return (uint8)dist(s_mte); });
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
#include<bitset>
|
#include<bitset>
|
||||||
#include<random>
|
#include<random>
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#include <boost/random/uniform_int.hpp>
|
#include <boost/random/uniform_int.hpp>
|
||||||
#endif
|
|
||||||
|
|
||||||
void swap(unsigned char *a, unsigned char *b)
|
void swap(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
|
@ -116,12 +114,7 @@ void releasePRUDPPort(uint16 port)
|
||||||
|
|
||||||
std::mt19937_64 prudpRG(GetTickCount());
|
std::mt19937_64 prudpRG(GetTickCount());
|
||||||
//Workaround for static asserts when using uniform_int_distribution
|
//Workaround for static asserts when using uniform_int_distribution
|
||||||
//TODO: Look for fix in libstdc++
|
|
||||||
#ifndef __clang__
|
|
||||||
std::uniform_int_distribution<int> prudpDis8(0, 0xFF);
|
|
||||||
#else
|
|
||||||
boost::random::uniform_int_distribution<int> prudpDis8(0, 0xFF);
|
boost::random::uniform_int_distribution<int> prudpDis8(0, 0xFF);
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8 prudp_generateRandomU8()
|
uint8 prudp_generateRandomU8()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
|
|
||||||
#include "config/ActiveSettings.h"
|
#include "config/ActiveSettings.h"
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#include <boost/random/uniform_int.hpp>
|
#include <boost/random/uniform_int.hpp>
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if BOOST_OS_WINDOWS
|
#if BOOST_OS_WINDOWS
|
||||||
|
@ -431,13 +429,9 @@ std::string GenerateRandomString(size_t length, std::string_view characters)
|
||||||
|
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937 gen(rd());
|
std::mt19937 gen(rd());
|
||||||
|
|
||||||
//Workaround for static asserts using boost
|
//Workaround for static asserts using boost
|
||||||
//TODO: Wait for fix in libstdc++
|
|
||||||
#ifndef __clang__
|
|
||||||
std::uniform_int_distribution<decltype(characters.size())> index_dist(0, characters.size() - 1);
|
|
||||||
#else
|
|
||||||
boost::random::uniform_int_distribution<decltype(characters.size())> index_dist(0, characters.size() - 1);
|
boost::random::uniform_int_distribution<decltype(characters.size())> index_dist(0, characters.size() - 1);
|
||||||
#endif
|
|
||||||
for (uint32_t i = 0; i < length; ++i)
|
for (uint32_t i = 0; i < length; ++i)
|
||||||
{
|
{
|
||||||
result << characters[index_dist(gen)];
|
result << characters[index_dist(gen)];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue