Batch #17832 by eAthena: 1 byte-identical, 0 confirmed by peer review. - fn_04427 utility::FillRandomBytes: byte-identical (already on main) Merged automatically: every function is byte-identical to the original.
32 lines
806 B
C++
32 lines
806 B
C++
#include "Utility/Random/RandomBytes.h"
|
|
|
|
#include <random>
|
|
|
|
template __declspec(noinline) std::mt19937::mersenne_twister_engine(std::mt19937::result_type);
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|