Skip to content

Commit 8c98f49

Browse files
committedDec 28, 2014
PseudoRandom: Expose constant PSEUDORANDOM_MAX
1 parent 8334100 commit 8c98f49

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎src/noise.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "irr_v3d.h"
3131
#include "util/string.h"
3232

33+
#define PSEUDORANDOM_MAX 32767
Has a conversation. Original line has a conversation.
34+
3335
extern FlagDesc flagdesc_noiseparams[];
3436

3537
class PseudoRandom
@@ -45,15 +47,15 @@ class PseudoRandom
4547
{
4648
m_next = seed;
4749
}
48-
// Returns 0...32767
50+
// Returns 0...PSEUDORANDOM_MAX
4951
int next()
5052
{
5153
m_next = m_next * 1103515245 + 12345;
52-
return((unsigned)(m_next/65536) % 32768);
54+
return((unsigned)(m_next/65536) % (PSEUDORANDOM_MAX + 1));
5355
}
5456
int range(int min, int max)
5557
{
56-
if(max-min > 32768/10)
58+
if (max-min > (PSEUDORANDOM_MAX + 1) / 10)
5759
{
5860
//dstream<<"WARNING: PseudoRandom::range: max > 32767"<<std::endl;
5961
assert(0);

0 commit comments

Comments
 (0)
Please sign in to comment.