fix RandomGen off by 1. Was retruning.[0,max), not [0,max]. (Caused random courseEntries to never pick the last song in the list)

This commit is contained in:
Chris Danford
2006-03-27 21:55:34 +00:00
parent ab84dffa0f
commit 6d865d4762
2 changed files with 5 additions and 2 deletions
+4 -1
View File
@@ -48,7 +48,10 @@ RandomGen::RandomGen( unsigned long seed_ )
int RandomGen::operator() ( int maximum )
{
return int(RandomFloat( seed ) * maximum);
float f = RandomFloat(seed) * (maximum+1);
int ans = int(f);
CLAMP( ans, 0, maximum );
return ans;
}