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;
}
+1 -1
View File
@@ -160,7 +160,7 @@ inline uint16_t Swap16LE( uint16_t n ) { return Swap16( n ); }
extern int randseed;
float RandomFloat( int &seed );
float RandomFloat( int &seed ); // between 0.0f and 1.0f
inline float RandomFloat()
{