Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2025-06-28 10:46:23 +08:00
63 changed files with 998 additions and 449 deletions

View File

@@ -69,6 +69,14 @@ Milliseconds randtime(Milliseconds min, Milliseconds max)
return min + Milliseconds(urand(0, diff));
}
Seconds randtime(Seconds min, Seconds max)
{
long long diff = max.count() - min.count();
ASSERT(diff >= 0);
ASSERT(diff <= (uint32) - 1);
return min + Seconds(urand(0, diff));
}
uint32 rand32()
{
return GetRng()->RandomUInt32();

View File

@@ -38,6 +38,9 @@ AC_COMMON_API uint32 rand32();
/* Return a random time in the range min..max (up to millisecond precision). Only works for values where millisecond difference is a valid uint32. */
AC_COMMON_API Milliseconds randtime(Milliseconds min, Milliseconds max);
/* Return a random time in the range min..max (up to second precision). */
AC_COMMON_API Seconds randtime(Seconds min, Seconds max);
/* Return a random number in the range min..max */
AC_COMMON_API float frand(float min, float max);