Util/Random: Add randtime(Milliseconds const&, Milliseconds const&) to supersede urandms(uint32,uint32) for scripts being ported to std::chrono.

(cherry picked from commit 224b42c53a)
This commit is contained in:
treeston
2016-03-01 23:09:25 +01:00
committed by Shauren
parent 3b67e57e0e
commit cf7436b644
2 changed files with 12 additions and 0 deletions

View File

@@ -61,6 +61,14 @@ float frand(float min, float max)
return float(GetRng()->Random() * (max - min) + min);
}
Milliseconds randtime(Milliseconds const& min, Milliseconds const& max)
{
long long diff = max.count() - min.count();
ASSERT(diff >= 0);
ASSERT(diff <= (uint32)-1);
return min + Milliseconds(urand(0, diff));
}
uint32 rand32()
{
return GetRng()->BRandom();