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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user