summaryrefslogtreecommitdiff
path: root/src/noise.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-03-22 02:58:47 -0400
committerkwolekr <kwolekr@minetest.net>2015-03-22 02:58:54 -0400
commit761b127060b924a43a79c72d5488dbe9c186acc0 (patch)
tree6e5df86dcd0969fe0d6bcb6f70d73cda628ab261 /src/noise.cpp
parent3993093f51544d4eb44efb57c973e29107ea2f7a (diff)
downloadminetest-761b127060b924a43a79c72d5488dbe9c186acc0.tar.gz
minetest-761b127060b924a43a79c72d5488dbe9c186acc0.tar.bz2
minetest-761b127060b924a43a79c72d5488dbe9c186acc0.zip
Fix some loose ends from 3993093f
Diffstat (limited to 'src/noise.cpp')
-rw-r--r--src/noise.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/noise.cpp b/src/noise.cpp
index e6a9b7395..c36b33db8 100644
--- a/src/noise.cpp
+++ b/src/noise.cpp
@@ -106,7 +106,8 @@ u32 PcgRandom::range(u32 bound)
u32 threshhold = -bound % bound;
u32 r;
- while ((r = next()) < threshhold);
+ while ((r = next()) < threshhold)
+ ;
return r % bound;
}
@@ -127,6 +128,7 @@ void PcgRandom::bytes(void *out, size_t len)
size_t len_alignment = (uintptr_t)out % sizeof(u32);
if (len_alignment) {
+ len -= len_alignment;
r = next();
while (len_alignment--) {
*outb = r & 0xFF;
@@ -156,7 +158,7 @@ void PcgRandom::bytes(void *out, size_t len)
s32 PcgRandom::randNormalDist(s32 min, s32 max, int num_trials)
{
- u32 accum = 0;
+ s32 accum = 0;
for (int i = 0; i != num_trials; i++)
accum += range(min, max);
return ((float)accum / num_trials) + 0.5f;