aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen/mg_biome.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2020-04-26 18:33:50 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2020-05-05 19:26:59 +0200
commitf3e87c53a5afc264e657acd99d3a39fbec3b63c9 (patch)
tree90925213a903f81fd3e537f8b6bec79fe035179f /src/mapgen/mg_biome.cpp
parentab06880525eea98011341fbcaec31a0bd7517df5 (diff)
downloadminetest-f3e87c53a5afc264e657acd99d3a39fbec3b63c9.tar.gz
minetest-f3e87c53a5afc264e657acd99d3a39fbec3b63c9.tar.bz2
minetest-f3e87c53a5afc264e657acd99d3a39fbec3b63c9.zip
Fix thread safety of PcgRandom use in BiomeGen
Diffstat (limited to 'src/mapgen/mg_biome.cpp')
-rw-r--r--src/mapgen/mg_biome.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mapgen/mg_biome.cpp b/src/mapgen/mg_biome.cpp
index 8c59ac9e6..610c38594 100644
--- a/src/mapgen/mg_biome.cpp
+++ b/src/mapgen/mg_biome.cpp
@@ -154,9 +154,11 @@ const Biome *BiomeManager::getBiomeFromNoiseOriginal(float heat,
}
}
- mysrand(pos.Y + (heat + humidity) * 0.9f);
+ const u64 seed = pos.Y + (heat + humidity) * 0.9f;
+ PcgRandom rng(seed);
+
if (biome_closest_blend && dist_min_blend <= dist_min &&
- myrand_range(0, biome_closest_blend->vertical_blend) >=
+ rng.range(0, biome_closest_blend->vertical_blend) >=
pos.Y - biome_closest_blend->max_pos.Y)
return biome_closest_blend;
@@ -319,10 +321,11 @@ Biome *BiomeGenOriginal::calcBiomeFromNoise(float heat, float humidity, v3s16 po
// Carefully tune pseudorandom seed variation to avoid single node dither
// and create larger scale blending patterns similar to horizontal biome
// blend.
- mysrand(pos.Y + (heat + humidity) * 0.9f);
+ const u64 seed = pos.Y + (heat + humidity) * 0.9f;
+ PcgRandom rng(seed);
if (biome_closest_blend && dist_min_blend <= dist_min &&
- myrand_range(0, biome_closest_blend->vertical_blend) >=
+ rng.range(0, biome_closest_blend->vertical_blend) >=
pos.Y - biome_closest_blend->max_pos.Y)
return biome_closest_blend;