aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2014-12-28 03:09:24 -0500
committerkwolekr <kwolekr@minetest.net>2014-12-28 03:09:32 -0500
commit8c98f497d957835803dd43a98a23a5d0eb98124c (patch)
treee112947d4067132f6adf22d72a37ca38007b5384 /src
parent8334100fe1b1bb40bfebff9ec9780c18fe3fd0c7 (diff)
downloadminetest-8c98f497d957835803dd43a98a23a5d0eb98124c.tar.gz
minetest-8c98f497d957835803dd43a98a23a5d0eb98124c.tar.bz2
minetest-8c98f497d957835803dd43a98a23a5d0eb98124c.zip
PseudoRandom: Expose constant PSEUDORANDOM_MAX
Diffstat (limited to 'src')
-rw-r--r--src/noise.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/noise.h b/src/noise.h
index f2df0ed5a..05c877b32 100644
--- a/src/noise.h
+++ b/src/noise.h
@@ -30,6 +30,8 @@
#include "irr_v3d.h"
#include "util/string.h"
+#define PSEUDORANDOM_MAX 32767
+
extern FlagDesc flagdesc_noiseparams[];
class PseudoRandom
@@ -45,15 +47,15 @@ public:
{
m_next = seed;
}
- // Returns 0...32767
+ // Returns 0...PSEUDORANDOM_MAX
int next()
{
m_next = m_next * 1103515245 + 12345;
- return((unsigned)(m_next/65536) % 32768);
+ return((unsigned)(m_next/65536) % (PSEUDORANDOM_MAX + 1));
}
int range(int min, int max)
{
- if(max-min > 32768/10)
+ if (max-min > (PSEUDORANDOM_MAX + 1) / 10)
{
//dstream<<"WARNING: PseudoRandom::range: max > 32767"<<std::endl;
assert(0);