summaryrefslogtreecommitdiff
path: root/src/noise.h
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-04-27 01:24:37 -0400
committerkwolekr <kwolekr@minetest.net>2015-04-27 01:24:37 -0400
commitcd1d625ab21e741e91be7d2190bb4fd59fab3200 (patch)
treecc11bc4b971be5712d3aaaf55d3b4697c4876f30 /src/noise.h
parent732eb72a0c4e2fb4632b0f42762d102e0d98dffa (diff)
downloadminetest-cd1d625ab21e741e91be7d2190bb4fd59fab3200.tar.gz
minetest-cd1d625ab21e741e91be7d2190bb4fd59fab3200.tar.bz2
minetest-cd1d625ab21e741e91be7d2190bb4fd59fab3200.zip
Replace PRNG assertions with PrngException
Diffstat (limited to 'src/noise.h')
-rw-r--r--src/noise.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/noise.h b/src/noise.h
index d2287835e..5757cbc99 100644
--- a/src/noise.h
+++ b/src/noise.h
@@ -26,8 +26,8 @@
#ifndef NOISE_HEADER
#define NOISE_HEADER
-#include "debug.h"
#include "irr_v3d.h"
+#include "exceptions.h"
#include "util/string.h"
extern FlagDesc flagdesc_noiseparams[];
@@ -56,14 +56,16 @@ public:
inline int range(int min, int max)
{
- assert(max >= min);
+ if (max < min)
+ throw PrngException("Invalid range (max < min)");
/*
Here, we ensure the range is not too large relative to RANDOM_MAX,
as otherwise the effects of bias would become noticable. Unlike
PcgRandom, we cannot modify this RNG's range as it would change the
output of this RNG for reverse compatibility.
*/
- assert((u32)(max - min) <= (RANDOM_RANGE + 1) / 10);
+ if ((u32)(max - min) > (RANDOM_RANGE + 1) / 10)
+ throw PrngException("Range too large");
return (next() % (max - min + 1)) + min;
}