forked from metin2/server
Used effolkronium/random for PRNG
This commit is contained in:
@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user