Navigation Menu

Skip to content

Commit

Permalink
MgOre: Fix invalid field polymorphism (#10846)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Jan 21, 2021
1 parent 8ff209c commit 4fcd000
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
47 changes: 20 additions & 27 deletions src/mapgen/mg_ore.h
Expand Up @@ -52,7 +52,7 @@ extern FlagDesc flagdesc_ore[];

class Ore : public ObjDef, public NodeResolver {
public:
static const bool NEEDS_NOISE = false;
const bool needs_noise;

content_t c_ore; // the node to place
std::vector<content_t> c_wherein; // the nodes to be placed in
Expand All @@ -68,7 +68,7 @@ class Ore : public ObjDef, public NodeResolver {
Noise *noise = nullptr;
std::unordered_set<biome_t> biomes;

Ore() = default;;
explicit Ore(bool needs_noise): needs_noise(needs_noise) {}
virtual ~Ore();

virtual void resolveNodeNames();
Expand All @@ -83,88 +83,81 @@ class Ore : public ObjDef, public NodeResolver {

class OreScatter : public Ore {
public:
static const bool NEEDS_NOISE = false;
OreScatter() : Ore(false) {}

ObjDef *clone() const;

virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap);
void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
};

class OreSheet : public Ore {
public:
static const bool NEEDS_NOISE = true;
OreSheet() : Ore(true) {}

ObjDef *clone() const;

u16 column_height_min;
u16 column_height_max;
float column_midpoint_factor;

virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap);
void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
};

class OrePuff : public Ore {
public:
static const bool NEEDS_NOISE = true;

ObjDef *clone() const;

NoiseParams np_puff_top;
NoiseParams np_puff_bottom;
Noise *noise_puff_top = nullptr;
Noise *noise_puff_bottom = nullptr;

OrePuff() = default;
OrePuff() : Ore(true) {}
virtual ~OrePuff();

virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap);
void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
};

class OreBlob : public Ore {
public:
static const bool NEEDS_NOISE = true;

ObjDef *clone() const;

virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap);
OreBlob() : Ore(true) {}
void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
};

class OreVein : public Ore {
public:
static const bool NEEDS_NOISE = true;

ObjDef *clone() const;

float random_factor;
Noise *noise2 = nullptr;
int sizey_prev = 0;

OreVein() = default;
OreVein() : Ore(true) {}
virtual ~OreVein();

virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap);
void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
};

class OreStratum : public Ore {
public:
static const bool NEEDS_NOISE = false;

ObjDef *clone() const;

NoiseParams np_stratum_thickness;
Noise *noise_stratum_thickness = nullptr;
u16 stratum_thickness;

OreStratum() = default;
OreStratum() : Ore(false) {}
virtual ~OreStratum();

virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap);
void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, biome_t *biomemap) override;
};

class OreManager : public ObjDefManager {
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_mapgen.cpp
Expand Up @@ -1335,7 +1335,7 @@ int ModApiMapgen::l_register_ore(lua_State *L)
lua_getfield(L, index, "noise_params");
if (read_noiseparams(L, -1, &ore->np)) {
ore->flags |= OREFLAG_USE_NOISE;
} else if (ore->NEEDS_NOISE) {
} else if (ore->needs_noise) {
errorstream << "register_ore: specified ore type requires valid "
"'noise_params' parameter" << std::endl;
delete ore;
Expand Down

0 comments on commit 4fcd000

Please sign in to comment.