Used effolkronium/random for PRNG

This commit is contained in:
2022-11-27 14:36:04 +02:00
parent d188b4d53f
commit 3a74dac29e
55 changed files with 434 additions and 518 deletions

View File

@ -345,42 +345,6 @@ int MINMAX(int min, int value, int max)
return (max < tv) ? max : tv;
}
DWORD thecore_random()
{
#ifdef __WIN32__
return rand();
#else
return random();
#endif
}
int number_ex(int from, int to, const char *file, int line)
{
if (from > to)
{
int tmp = from;
sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line);
from = to;
to = tmp;
}
int returnValue = 0;
if ((to - from + 1) != 0)
returnValue = ((thecore_random() % (to - from + 1)) + from);
else
sys_err("number(): devided by 0");
return returnValue;
}
float fnumber(float from, float to)
{
return (((float)thecore_random() / (float)RAND_MAX) * (to - from)) + from;
}
#ifndef __WIN32__
void thecore_sleep(struct timeval* timeout)
{