diff options
author | kwolekr <kwolekr@minetest.net> | 2015-11-08 23:40:18 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-11-09 01:32:39 -0500 |
commit | f3ac2517ea585d31d176070be25adf8a68624c87 (patch) | |
tree | 570c9c870424da3b12296576658f96f15377264a | |
parent | c3e179f256246b4b5a86cd908dfc567a7ec454ee (diff) | |
download | minetest-f3ac2517ea585d31d176070be25adf8a68624c87.tar.gz minetest-f3ac2517ea585d31d176070be25adf8a68624c87.tar.bz2 minetest-f3ac2517ea585d31d176070be25adf8a68624c87.zip |
Convert usages of PseudoRandom to PcgRandom for ore and deco placement
In addition to being a better random, this fixes #3228
-rw-r--r-- | src/mg_decoration.cpp | 8 | ||||
-rw-r--r-- | src/mg_decoration.h | 8 | ||||
-rw-r--r-- | src/mg_ore.cpp | 10 |
3 files changed, 13 insertions, 13 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp index 846d6130b..1e50ba0de 100644 --- a/src/mg_decoration.cpp +++ b/src/mg_decoration.cpp @@ -87,7 +87,7 @@ void Decoration::resolveNodeNames() size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { - PseudoRandom ps(blockseed + 53); + PcgRandom ps(blockseed + 53); int carea_size = nmax.X - nmin.X + 1; // Divide area into parts @@ -170,7 +170,7 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) #if 0 void Decoration::placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { - PseudoRandom pr(blockseed + 53); + PcgRandom pr(blockseed + 53); std::vector<CutoffData> handled_cutoffs; // Copy over the cutoffs we're interested in so we don't needlessly hold a lock @@ -286,7 +286,7 @@ bool DecoSimple::canPlaceDecoration(MMVManip *vm, v3s16 p) } -size_t DecoSimple::generate(MMVManip *vm, PseudoRandom *pr, v3s16 p) +size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p) { if (!canPlaceDecoration(vm, p)) return 0; @@ -327,7 +327,7 @@ DecoSchematic::DecoSchematic() } -size_t DecoSchematic::generate(MMVManip *vm, PseudoRandom *pr, v3s16 p) +size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p) { // Schematic could have been unloaded but not the decoration // In this case generate() does nothing (but doesn't *fail*) diff --git a/src/mg_decoration.h b/src/mg_decoration.h index 16af02a1a..ba3e9d3b2 100644 --- a/src/mg_decoration.h +++ b/src/mg_decoration.h @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., class Mapgen; class MMVManip; -class PseudoRandom; +class PcgRandom; class Schematic; enum DecorationType { @@ -71,7 +71,7 @@ public: size_t placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); //size_t placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); - virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p) = 0; + virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p) = 0; virtual int getHeight() = 0; u32 flags; @@ -90,7 +90,7 @@ public: class DecoSimple : public Decoration { public: - virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p); + virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p); bool canPlaceDecoration(MMVManip *vm, v3s16 p); virtual int getHeight(); @@ -107,7 +107,7 @@ class DecoSchematic : public Decoration { public: DecoSchematic(); - virtual size_t generate(MMVManip *vm, PseudoRandom *pr, v3s16 p); + virtual size_t generate(MMVManip *vm, PcgRandom *pr, v3s16 p); virtual int getHeight(); Rotation rotation; diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp index 16d97685a..6b6e0d7a7 100644 --- a/src/mg_ore.cpp +++ b/src/mg_ore.cpp @@ -126,7 +126,7 @@ size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) void OreScatter::generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, u8 *biomemap) { - PseudoRandom pr(blockseed); + PcgRandom pr(blockseed); MapNode n_ore(c_ore, 0, ore_param2); u32 sizex = (nmax.X - nmin.X + 1); @@ -175,7 +175,7 @@ void OreScatter::generate(MMVManip *vm, int mapseed, u32 blockseed, void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, u8 *biomemap) { - PseudoRandom pr(blockseed + 4234); + PcgRandom pr(blockseed + 4234); MapNode n_ore(c_ore, 0, ore_param2); u16 max_height = column_height_max; @@ -240,7 +240,7 @@ OrePuff::~OrePuff() void OrePuff::generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, u8 *biomemap) { - PseudoRandom pr(blockseed + 4234); + PcgRandom pr(blockseed + 4234); MapNode n_ore(c_ore, 0, ore_param2); int y_start = pr.range(nmin.Y, nmax.Y); @@ -313,7 +313,7 @@ void OrePuff::generate(MMVManip *vm, int mapseed, u32 blockseed, void OreBlob::generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, u8 *biomemap) { - PseudoRandom pr(blockseed + 2404); + PcgRandom pr(blockseed + 2404); MapNode n_ore(c_ore, 0, ore_param2); u32 sizex = (nmax.X - nmin.X + 1); @@ -391,7 +391,7 @@ OreVein::~OreVein() void OreVein::generate(MMVManip *vm, int mapseed, u32 blockseed, v3s16 nmin, v3s16 nmax, u8 *biomemap) { - PseudoRandom pr(blockseed + 520); + PcgRandom pr(blockseed + 520); MapNode n_ore(c_ore, 0, ore_param2); u32 sizex = (nmax.X - nmin.X + 1); |