Fix for bug #8680: GameLogic.getRandomFloat() returns very small

values on 64 bit, instead of range 0..1. Also a warning fix.
This commit is contained in:
Brecht Van Lommel 2008-06-29 20:53:17 +00:00
parent 4b59a4bea0
commit d5f4b3620f
3 changed files with 9 additions and 9 deletions

@ -74,7 +74,7 @@ public:
virtual bool PositionTask() const { return false; }
virtual void Scale(float scale) {}
virtual void Scale(float) {}
protected:
int m_id;

@ -31,10 +31,10 @@
#include <limits.h>
#define MT_RAND_MAX ULONG_MAX
#define MT_RAND_MAX UINT_MAX
extern void MT_srand(unsigned long);
extern unsigned long MT_rand();
extern void MT_srand(unsigned int);
extern unsigned int MT_rand();
#endif

@ -76,11 +76,11 @@
#define TEMPERING_SHIFT_T(y) (y << 15)
#define TEMPERING_SHIFT_L(y) (y >> 18)
static unsigned long mt[N]; /* the array for the state vector */
static unsigned int mt[N]; /* the array for the state vector */
static int mti = N+1; /* mti==N+1 means mt[N] is not initialized */
/* initializing the array with a NONZERO seed */
void MT_srand(unsigned long seed)
void MT_srand(unsigned int seed)
{
/* setting initial seeds to mt[N] using */
/* the generator Line 25 of Table 1 in */
@ -91,12 +91,12 @@ void MT_srand(unsigned long seed)
mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
}
unsigned long MT_rand()
unsigned int MT_rand()
{
static unsigned long mag01[2] = { 0x0, MATRIX_A };
static unsigned int mag01[2] = { 0x0, MATRIX_A };
/* mag01[x] = x * MATRIX_A for x=0,1 */
unsigned long y;
unsigned int y;
if (mti >= N) { /* generate N words at one time */
int kk;