Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-06-30 00:53:17 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-06-30 00:53:17 +0400
commitd5f4b3620f19e816415fcf22dda6479d00986eea (patch)
treecd742ddeca4f2f123b59808b391665026cd32267 /intern/moto
parent4b59a4bea0d84330cc9b925e8f95a63eb384bd54 (diff)
Fix for bug #8680: GameLogic.getRandomFloat() returns very small
values on 64 bit, instead of range 0..1. Also a warning fix.
Diffstat (limited to 'intern/moto')
-rw-r--r--intern/moto/include/MT_random.h6
-rw-r--r--intern/moto/intern/MT_random.cpp10
2 files changed, 8 insertions, 8 deletions
diff --git a/intern/moto/include/MT_random.h b/intern/moto/include/MT_random.h
index d7da546cf03..3afe1dd1662 100644
--- a/intern/moto/include/MT_random.h
+++ b/intern/moto/include/MT_random.h
@@ -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
diff --git a/intern/moto/intern/MT_random.cpp b/intern/moto/intern/MT_random.cpp
index 96cb394d3da..b8302e093ca 100644
--- a/intern/moto/intern/MT_random.cpp
+++ b/intern/moto/intern/MT_random.cpp
@@ -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;