1
0
Fork 0
cuberite-2a/src/FastRandom.cpp

36 lines
426 B
C++
Raw Normal View History

// FastRandom.cpp
#include "Globals.h"
#include "FastRandom.h"
2017-06-13 19:35:30 +00:00
MTRand & GetRandomProvider()
{
thread_local MTRand Random = []
{
cRandomDeviceSeeder Seeder;
return MTRand(Seeder);
}();
return Random;
}
2017-06-13 19:35:30 +00:00
UInt32 Detail::GetRandomSeed()
{
thread_local UInt32 SeedCounter = []
{
std::random_device rd;
std::uniform_int_distribution<UInt32> dist;
return dist(rd);
}();
2017-06-13 19:35:30 +00:00
return ++SeedCounter;
}