mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-02 00:45:58 +00:00
Hack to fix Random
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
Random::Random (const int64 seedValue) noexcept
|
Random::Random (const int64 seedValue) noexcept
|
||||||
: seed (seedValue)
|
: seed (seedValue)
|
||||||
{
|
{
|
||||||
|
nextInt (); // fixes a bug where the first int is always 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Random::Random()
|
Random::Random()
|
||||||
@@ -39,6 +40,8 @@ Random::~Random() noexcept
|
|||||||
void Random::setSeed (const int64 newSeed) noexcept
|
void Random::setSeed (const int64 newSeed) noexcept
|
||||||
{
|
{
|
||||||
seed = newSeed;
|
seed = newSeed;
|
||||||
|
|
||||||
|
nextInt (); // fixes a bug where the first int is always 0
|
||||||
}
|
}
|
||||||
|
|
||||||
void Random::combineSeed (const int64 seedValue) noexcept
|
void Random::combineSeed (const int64 seedValue) noexcept
|
||||||
@@ -56,6 +59,8 @@ void Random::setSeedRandomly()
|
|||||||
combineSeed (Time::getHighResolutionTicksPerSecond());
|
combineSeed (Time::getHighResolutionTicksPerSecond());
|
||||||
combineSeed (Time::currentTimeMillis());
|
combineSeed (Time::currentTimeMillis());
|
||||||
globalSeed ^= seed;
|
globalSeed ^= seed;
|
||||||
|
|
||||||
|
nextInt (); // fixes a bug where the first int is always 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Random& Random::getSystemRandom() noexcept
|
Random& Random::getSystemRandom() noexcept
|
||||||
|
|||||||
Reference in New Issue
Block a user