mirror of
https://github.com/minetest/minetest.git
synced 2024-12-27 16:37:30 +01:00
Convert usages of PseudoRandom to PcgRandom for ore and deco placement
In addition to being a better random, this fixes #3228
This commit is contained in:
parent
c3e179f256
commit
f3ac2517ea
@ -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*)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user