Slightly better randomness when shuffling

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4922 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2004-07-23 10:45:16 +00:00
parent dd0b12c9ac
commit 12bf7f39b1

View file

@ -721,7 +721,7 @@ static int randomise_playlist(struct playlist_info* playlist,
for(count = playlist->amount - 1; count >= 0; count--)
{
/* the rand is from 0 to RAND_MAX, so adjust to our value range */
candidate = rand() % (count + 1);
candidate = rand() / (RAND_MAX / (count + 1));
/* now swap the values at the 'count' and 'candidate' positions */
store = playlist->indices[candidate];