Add comments for LoadRandomSequence
This commit is contained in:
parent
9634c84e1c
commit
680f3ac768
|
|
@ -1726,26 +1726,29 @@ int *LoadRandomSequence(unsigned int count, int min, int max)
|
||||||
values = rprand_load_sequence(count, min, max);
|
values = rprand_load_sequence(count, min, max);
|
||||||
#else
|
#else
|
||||||
if (count > (abs(max - min) + 1)) return values;
|
if (count > (abs(max - min) + 1)) return values;
|
||||||
|
|
||||||
|
// Allocate array for putting random values into it.
|
||||||
values = (int *)RL_CALLOC(count, sizeof(int));
|
values = (int *)RL_CALLOC(count, sizeof(int));
|
||||||
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
bool dupValue = false;
|
bool dupValue = false;
|
||||||
|
|
||||||
for (int i = 0; i < count;)
|
for (int i = 0; i < count;)
|
||||||
{
|
{
|
||||||
|
// Generate random value with max and min
|
||||||
value = (rand()%(abs(max - min) + 1) + min);
|
value = (rand()%(abs(max - min) + 1) + min);
|
||||||
dupValue = false;
|
dupValue = false;
|
||||||
|
|
||||||
for (int j = 0; j < i; j++)
|
for (int j = 0; j < i; j++)
|
||||||
{
|
{
|
||||||
if (values[j] == value)
|
if (values[j] == value) // Check for value duplication
|
||||||
{
|
{
|
||||||
dupValue = true;
|
dupValue = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't add same the value
|
||||||
if (!dupValue)
|
if (!dupValue)
|
||||||
{
|
{
|
||||||
values[i] = value;
|
values[i] = value;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user