Преглед на файлове

Merge pull request #1409 from Azaezel/LinuxLongLoopiness

U32 MRandomLCG::randI() was using longs
Areloch преди 10 години
родител
ревизия
70c7a67456
променени са 2 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 2 2
      Engine/source/math/mRandom.cpp
  2. 1 1
      Engine/source/math/mRandom.h

+ 2 - 2
Engine/source/math/mRandom.cpp

@@ -88,13 +88,13 @@ void MRandomLCG::setSeed(S32 s)
 U32 MRandomLCG::randI()
 U32 MRandomLCG::randI()
 {
 {
    if ( mSeed <= msQuotient )
    if ( mSeed <= msQuotient )
-      mSeed = (mSeed * 16807L) % S32_MAX;
+      mSeed = (mSeed * 16807) % S32_MAX;
    else
    else
    {
    {
       S32 high_part = mSeed / msQuotient;
       S32 high_part = mSeed / msQuotient;
       S32 low_part  = mSeed % msQuotient;
       S32 low_part  = mSeed % msQuotient;
 
 
-      S32 test = (16807L * low_part) - (msRemainder * high_part);
+      S32 test = (16807 * low_part) - (msRemainder * high_part);
 
 
       if ( test > 0 )
       if ( test > 0 )
          mSeed = test;
          mSeed = test;

+ 1 - 1
Engine/source/math/mRandom.h

@@ -54,7 +54,7 @@ public:
 inline F32 MRandomGenerator::randF()
 inline F32 MRandomGenerator::randF()
 {
 {
    // default: multiply by 1/(2^31)
    // default: multiply by 1/(2^31)
-   return  F32(randI()) * (1.0f/2147483647.0f);
+   return F32(randI()) * (1.0f / S32_MAX);
 }
 }
 
 
 inline S32 MRandomGenerator::randI(S32 i, S32 n)
 inline S32 MRandomGenerator::randI(S32 i, S32 n)