Skip to content

Commit

Permalink
Convert usages of PseudoRandom to PcgRandom for ore and deco placement
Browse files Browse the repository at this point in the history
In addition to being a better random, this fixes #3228
  • Loading branch information
kwolekr committed Nov 9, 2015
1 parent c3e179f commit f3ac251
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/mg_decoration.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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*)
Expand Down
8 changes: 4 additions & 4 deletions src/mg_decoration.h
Expand Up @@ -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 {
Expand Down Expand Up @@ -71,7 +71,7 @@ class Decoration : public ObjDef, public NodeResolver {
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;
Expand All @@ -90,7 +90,7 @@ class Decoration : public ObjDef, public NodeResolver {

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();

Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/mg_ore.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f3ac251

Please sign in to comment.