Batch #15471 by youko: 0 byte-identical, 1 confirmed by peer review. - fn_04427 utility::FillRandomBytes: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, Yommy, alisonrag Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
30 lines
709 B
C++
30 lines
709 B
C++
#include "Utility/Random/RandomBytes.h"
|
|
|
|
#include <random>
|
|
|
|
namespace {
|
|
struct RandomByteSource {
|
|
/* 0000 */ std::mt19937 m_engine;
|
|
/* 1388 */ std::uniform_int_distribution<int> m_distribution;
|
|
|
|
// INLINED
|
|
explicit RandomByteSource(unsigned int seed) : m_engine(seed), m_distribution(0, 255) {
|
|
}
|
|
|
|
// INLINED
|
|
std::uint8_t Next() {
|
|
return static_cast<std::uint8_t>(this->m_distribution(this->m_engine));
|
|
}
|
|
};
|
|
}
|
|
|
|
namespace utility {
|
|
// OFFSET: 0x0061CBE0
|
|
// FUNCTION: fn_04427
|
|
void FillRandomBytes(std::span<std::uint8_t> bytes, unsigned int seed) {
|
|
RandomByteSource source(seed);
|
|
for (std::uint8_t& byte : bytes) {
|
|
byte = source.Next();
|
|
}
|
|
}
|
|
}
|