aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2013-05-18 23:26:27 -0400
committerkwolekr <kwolekr@minetest.net>2013-05-19 12:22:20 -0400
commit93474c4218eee621a96e24324b1b41a55571f0df (patch)
treedc74d8a27cfa853b4580159cde8c66e485c4f9f2 /src
parentf577facf79729a03bb274a27c9f50f0092cd3a40 (diff)
downloadminetest-93474c4218eee621a96e24324b1b41a55571f0df.tar.gz
minetest-93474c4218eee621a96e24324b1b41a55571f0df.tar.bz2
minetest-93474c4218eee621a96e24324b1b41a55571f0df.zip
Remove no virtual dtor warnings, make MapgenParams contain actual NoiseParams
Diffstat (limited to 'src')
-rw-r--r--src/mapgen.cpp52
-rw-r--r--src/mapgen.h10
-rw-r--r--src/mapgen_indev.cpp88
-rw-r--r--src/mapgen_indev.h59
-rw-r--r--src/mapgen_singlenode.h4
-rw-r--r--src/mapgen_v6.cpp24
-rw-r--r--src/mapgen_v6.h47
-rw-r--r--src/mapgen_v7.cpp12
-rw-r--r--src/mapgen_v7.h26
-rw-r--r--src/noise.h6
-rw-r--r--src/settings.h37
11 files changed, 185 insertions, 180 deletions
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 0646a8826..835c14be1 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -71,6 +71,12 @@ Ore *createOre(OreType type) {
}
+Ore::~Ore() {
+ delete np;
+ delete noise;
+}
+
+
void Ore::resolveNodeNames(INodeDefManager *ndef) {
if (ore == CONTENT_IGNORE) {
ore = ndef->getId(ore_name);
@@ -347,23 +353,18 @@ bool MapgenV6Params::readParams(Settings *settings) {
freq_desert = settings->getFloat("mgv6_freq_desert");
freq_beach = settings->getFloat("mgv6_freq_beach");
- np_terrain_base = settings->getNoiseParams("mgv6_np_terrain_base");
- np_terrain_higher = settings->getNoiseParams("mgv6_np_terrain_higher");
- np_steepness = settings->getNoiseParams("mgv6_np_steepness");
- np_height_select = settings->getNoiseParams("mgv6_np_height_select");
- np_mud = settings->getNoiseParams("mgv6_np_mud");
- np_beach = settings->getNoiseParams("mgv6_np_beach");
- np_biome = settings->getNoiseParams("mgv6_np_biome");
- np_cave = settings->getNoiseParams("mgv6_np_cave");
- np_humidity = settings->getNoiseParams("mgv6_np_humidity");
- np_trees = settings->getNoiseParams("mgv6_np_trees");
- np_apple_trees = settings->getNoiseParams("mgv6_np_apple_trees");
-
- bool success =
- np_terrain_base && np_terrain_higher && np_steepness &&
- np_height_select && np_trees && np_mud &&
- np_beach && np_biome && np_cave &&
- np_humidity && np_apple_trees;
+ bool success =
+ settings->getNoiseParams("mgv6_np_terrain_base", np_terrain_base) &&
+ settings->getNoiseParams("mgv6_np_terrain_higher", np_terrain_higher) &&
+ settings->getNoiseParams("mgv6_np_steepness", np_steepness) &&
+ settings->getNoiseParams("mgv6_np_height_select", np_height_select) &&
+ settings->getNoiseParams("mgv6_np_mud", np_mud) &&
+ settings->getNoiseParams("mgv6_np_beach", np_beach) &&
+ settings->getNoiseParams("mgv6_np_biome", np_biome) &&
+ settings->getNoiseParams("mgv6_np_cave", np_cave) &&
+ settings->getNoiseParams("mgv6_np_humidity", np_humidity) &&
+ settings->getNoiseParams("mgv6_np_trees", np_trees) &&
+ settings->getNoiseParams("mgv6_np_apple_trees", np_apple_trees);
return success;
}
@@ -387,16 +388,13 @@ void MapgenV6Params::writeParams(Settings *settings) {
bool MapgenV7Params::readParams(Settings *settings) {
- np_terrain_base = settings->getNoiseParams("mgv7_np_terrain_base");
- np_terrain_alt = settings->getNoiseParams("mgv7_np_terrain_alt");
- np_terrain_mod = settings->getNoiseParams("mgv7_np_terrain_mod");
- np_terrain_persist = settings->getNoiseParams("mgv7_np_terrain_persist");
- np_height_select = settings->getNoiseParams("mgv7_np_height_select");
- np_ridge = settings->getNoiseParams("mgv7_np_ridge");
-
- bool success =
- np_terrain_base && np_terrain_alt && np_terrain_mod &&
- np_terrain_persist && np_height_select && np_ridge;
+ bool success =
+ settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base) &&
+ settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt) &&
+ settings->getNoiseParams("mgv7_np_terrain_mod", np_terrain_mod) &&
+ settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist) &&
+ settings->getNoiseParams("mgv7_np_height_select", np_height_select) &&
+ settings->getNoiseParams("mgv7_np_ridge", np_ridge);
return success;
}
diff --git a/src/mapgen.h b/src/mapgen.h
index 17136a137..5d1e3bdf0 100644
--- a/src/mapgen.h
+++ b/src/mapgen.h
@@ -74,7 +74,8 @@ struct MapgenParams {
}
virtual bool readParams(Settings *settings) = 0;
- virtual void writeParams(Settings *settings) {};
+ virtual void writeParams(Settings *settings) = 0;
+ virtual ~MapgenParams() {}
};
class Mapgen {
@@ -86,6 +87,8 @@ public:
ManualMapVoxelManipulator *vm;
INodeDefManager *ndef;
+ virtual ~Mapgen() {}
+
void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
void setLighting(v3s16 nmin, v3s16 nmax, u8 light);
void lightSpread(VoxelArea &a, v3s16 p, u8 light);
@@ -105,6 +108,7 @@ struct MapgenFactory {
virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
EmergeManager *emerge) = 0;
virtual MapgenParams *createMapgenParams() = 0;
+ virtual ~MapgenFactory() {}
};
enum OreType {
@@ -140,6 +144,8 @@ public:
noise = NULL;
}
+ virtual ~Ore();
+
void resolveNodeNames(INodeDefManager *ndef);
void placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
virtual void generate(ManualMapVoxelManipulator *vm, int seed,
@@ -147,11 +153,13 @@ public:
};
class OreScatter : public Ore {
+ ~OreScatter() {}
virtual void generate(ManualMapVoxelManipulator *vm, int seed,
u32 blockseed, v3s16 nmin, v3s16 nmax);
};
class OreSheet : public Ore {
+ ~OreSheet() {}
virtual void generate(ManualMapVoxelManipulator *vm, int seed,
u32 blockseed, v3s16 nmin, v3s16 nmax);
};
diff --git a/src/mapgen_indev.cpp b/src/mapgen_indev.cpp
index 2eeaf13eb..430359be2 100644
--- a/src/mapgen_indev.cpp
+++ b/src/mapgen_indev.cpp
@@ -84,17 +84,14 @@ void NoiseIndev::transformNoiseMapFarScale(float xx, float yy, float zz) {
MapgenIndev::MapgenIndev(int mapgenid, MapgenIndevParams *params, EmergeManager *emerge)
: MapgenV6(mapgenid, params, emerge)
{
- noiseindev_terrain_base = new NoiseIndev(params->npindev_terrain_base, seed, csize.X, csize.Z);
- noiseindev_terrain_higher = new NoiseIndev(params->npindev_terrain_higher, seed, csize.X, csize.Z);
- noiseindev_steepness = new NoiseIndev(params->npindev_steepness, seed, csize.X, csize.Z);
-// noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Y);
-// noise_trees = new Noise(params->np_trees, seed, csize.X, csize.Y);
- noiseindev_mud = new NoiseIndev(params->npindev_mud, seed, csize.X, csize.Z);
-// noise_beach = new Noise(params->np_beach, seed, csize.X, csize.Y);
- noiseindev_float_islands1 = new NoiseIndev(params->npindev_float_islands1, seed, csize.X, csize.Y, csize.Z);
- noiseindev_float_islands2 = new NoiseIndev(params->npindev_float_islands2, seed, csize.X, csize.Y, csize.Z);
- noiseindev_float_islands3 = new NoiseIndev(params->npindev_float_islands3, seed, csize.X, csize.Z);
- noiseindev_biome = new NoiseIndev(params->npindev_biome, seed, csize.X, csize.Z);
+ noiseindev_terrain_base = new NoiseIndev(&params->npindev_terrain_base, seed, csize.X, csize.Z);
+ noiseindev_terrain_higher = new NoiseIndev(&params->npindev_terrain_higher, seed, csize.X, csize.Z);
+ noiseindev_steepness = new NoiseIndev(&params->npindev_steepness, seed, csize.X, csize.Z);
+ noiseindev_mud = new NoiseIndev(&params->npindev_mud, seed, csize.X, csize.Z);
+ noiseindev_float_islands1 = new NoiseIndev(&params->npindev_float_islands1, seed, csize.X, csize.Y, csize.Z);
+ noiseindev_float_islands2 = new NoiseIndev(&params->npindev_float_islands2, seed, csize.X, csize.Y, csize.Z);
+ noiseindev_float_islands3 = new NoiseIndev(&params->npindev_float_islands3, seed, csize.X, csize.Z);
+ noiseindev_biome = new NoiseIndev(&params->npindev_biome, seed, csize.X, csize.Z);
}
MapgenIndev::~MapgenIndev() {
@@ -170,46 +167,41 @@ void MapgenIndev::calculateNoise() {
}
bool MapgenIndevParams::readParams(Settings *settings) {
- freq_desert = settings->getFloat("mgv6_freq_desert");
- freq_beach = settings->getFloat("mgv6_freq_beach");
-
- npindev_terrain_base = settings->getNoiseIndevParams("mgindev_np_terrain_base");
- npindev_terrain_higher = settings->getNoiseIndevParams("mgindev_np_terrain_higher");
- npindev_steepness = settings->getNoiseIndevParams("mgindev_np_steepness");
- np_height_select = settings->getNoiseParams("mgv6_np_height_select");
- np_trees = settings->getNoiseParams("mgv6_np_trees");
- npindev_mud = settings->getNoiseIndevParams("mgindev_np_mud");
- np_beach = settings->getNoiseParams("mgv6_np_beach");
- npindev_biome = settings->getNoiseIndevParams("mgindev_np_biome");
- np_cave = settings->getNoiseParams("mgv6_np_cave");
- npindev_float_islands1 = settings->getNoiseIndevParams("mgindev_np_float_islands1");
- npindev_float_islands2 = settings->getNoiseIndevParams("mgindev_np_float_islands2");
- npindev_float_islands3 = settings->getNoiseIndevParams("mgindev_np_float_islands3");
-
- bool success =
- npindev_terrain_base && npindev_terrain_higher && npindev_steepness &&
- np_height_select && np_trees && npindev_mud &&
- np_beach && np_biome && np_cave &&
- npindev_float_islands1 && npindev_float_islands2 && npindev_float_islands3;
- return success;
+ freq_desert = settings->getFloat("mgv6_freq_desert");
+ freq_beach = settings->getFloat("mgv6_freq_beach");
+
+ bool success =
+ settings->getNoiseIndevParams("mgindev_np_terrain_base", npindev_terrain_base) &&
+ settings->getNoiseIndevParams("mgindev_np_terrain_higher", npindev_terrain_higher) &&
+ settings->getNoiseIndevParams("mgindev_np_steepness", npindev_steepness) &&
+ settings->getNoiseParams("mgv6_np_height_select", np_height_select) &&
+ settings->getNoiseParams("mgv6_np_trees", np_trees) &&
+ settings->getNoiseIndevParams("mgindev_np_mud", npindev_mud) &&
+ settings->getNoiseParams("mgv6_np_beach", np_beach) &&
+ settings->getNoiseIndevParams("mgindev_np_biome", npindev_biome) &&
+ settings->getNoiseParams("mgv6_np_cave", np_cave) &&
+ settings->getNoiseIndevParams("mgindev_np_float_islands1", npindev_float_islands1) &&
+ settings->getNoiseIndevParams("mgindev_np_float_islands2", npindev_float_islands2) &&
+ settings->getNoiseIndevParams("mgindev_np_float_islands3", npindev_float_islands3);
+ return success;
}
void MapgenIndevParams::writeParams(Settings *settings) {
- settings->setFloat("mgv6_freq_desert", freq_desert);
- settings->setFloat("mgv6_freq_beach", freq_beach);
-
- settings->setNoiseIndevParams("mgindev_np_terrain_base", npindev_terrain_base);
- settings->setNoiseIndevParams("mgindev_np_terrain_higher", npindev_terrain_higher);
- settings->setNoiseIndevParams("mgindev_np_steepness", npindev_steepness);
- settings->setNoiseParams("mgv6_np_height_select", np_height_select);
- settings->setNoiseParams("mgv6_np_trees", np_trees);
- settings->setNoiseIndevParams("mgindev_np_mud", npindev_mud);
- settings->setNoiseParams("mgv6_np_beach", np_beach);
- settings->setNoiseIndevParams("mgindev_np_biome", npindev_biome);
- settings->setNoiseParams("mgv6_np_cave", np_cave);
- settings->setNoiseIndevParams("mgindev_np_float_islands1", npindev_float_islands1);
- settings->setNoiseIndevParams("mgindev_np_float_islands2", npindev_float_islands2);
- settings->setNoiseIndevParams("mgindev_np_float_islands3", npindev_float_islands3);
+ settings->setFloat("mgv6_freq_desert", freq_desert);
+ settings->setFloat("mgv6_freq_beach", freq_beach);
+
+ settings->setNoiseIndevParams("mgindev_np_terrain_base", npindev_terrain_base);
+ settings->setNoiseIndevParams("mgindev_np_terrain_higher", npindev_terrain_higher);
+ settings->setNoiseIndevParams("mgindev_np_steepness", npindev_steepness);
+ settings->setNoiseParams("mgv6_np_height_select", np_height_select);
+ settings->setNoiseParams("mgv6_np_trees", np_trees);
+ settings->setNoiseIndevParams("mgindev_np_mud", npindev_mud);
+ settings->setNoiseParams("mgv6_np_beach", np_beach);
+ settings->setNoiseIndevParams("mgindev_np_biome", npindev_biome);
+ settings->setNoiseParams("mgv6_np_cave", np_cave);
+ settings->setNoiseIndevParams("mgindev_np_float_islands1", npindev_float_islands1);
+ settings->setNoiseIndevParams("mgindev_np_float_islands2", npindev_float_islands2);
+ settings->setNoiseIndevParams("mgindev_np_float_islands3", npindev_float_islands3);
}
diff --git a/src/mapgen_indev.h b/src/mapgen_indev.h
index 87ae39d09..cfef59041 100644
--- a/src/mapgen_indev.h
+++ b/src/mapgen_indev.h
@@ -32,30 +32,33 @@ struct NoiseIndevParams : public NoiseParams {
float farscale;
float farspread;
- NoiseIndevParams(){}
- NoiseIndevParams(float offset_, float scale_, v3f spread_, int seed_, int octaves_, float persist_, float farscale_ = 1, float farspread_ = 1)
+ NoiseIndevParams() {}
+ NoiseIndevParams(float offset_, float scale_, v3f spread_,
+ int seed_, int octaves_, float persist_,
+ float farscale_ = 1, float farspread_ = 1)
{
- offset = offset_;
- scale = scale_;
- spread = spread_;
- seed = seed_;
+ offset = offset_;
+ scale = scale_;
+ spread = spread_;
+ seed = seed_;
octaves = octaves_;
persist = persist_;
- farscale = farscale_;
+ farscale = farscale_;
farspread = farspread_;
}
-
+
+ ~NoiseIndevParams() {}
};
-#define getNoiseIndevParams(x) getStruct<NoiseIndevParams>((x), "f,f,v3,s32,s32,f,f,f")
-#define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f,f", (y))
+#define getNoiseIndevParams(x, y) getStruct((x), "f,f,v3,s32,s32,f,f,f", &(y), sizeof(y))
+#define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f,f", &(y))
class NoiseIndev : public Noise {
- public:
+public:
NoiseIndevParams *npindev;
- //NoiseIndev() {};
+ virtual ~NoiseIndev() {};
NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy);
NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz);
void init(NoiseIndevParams *np, int seed, int sx, int sy, int sz);
@@ -77,34 +80,34 @@ extern NoiseIndevParams nparams_indev_def_float_islands;
*/
struct MapgenIndevParams : public MapgenV6Params {
- NoiseIndevParams *npindev_terrain_base;
- NoiseIndevParams *npindev_terrain_higher;
- NoiseIndevParams *npindev_steepness;
+ NoiseIndevParams npindev_terrain_base;
+ NoiseIndevParams npindev_terrain_higher;
+ NoiseIndevParams npindev_steepness;
//NoiseParams *np_height_select;
//NoiseParams *np_trees;
- NoiseIndevParams *npindev_mud;
+ NoiseIndevParams npindev_mud;
//NoiseParams *np_beach;
- NoiseIndevParams *npindev_biome;
+ NoiseIndevParams npindev_biome;
//NoiseParams *np_cave;
- NoiseIndevParams *npindev_float_islands1;
- NoiseIndevParams *npindev_float_islands2;
- NoiseIndevParams *npindev_float_islands3;
+ NoiseIndevParams npindev_float_islands1;
+ NoiseIndevParams npindev_float_islands2;
+ NoiseIndevParams npindev_float_islands3;
MapgenIndevParams() {
//freq_desert = 0.45;
//freq_beach = 0.15;
- npindev_terrain_base = &nparams_indev_def; //&nparams_indev_def_terrain_base;
- npindev_terrain_higher = &nparams_indev_def; //&nparams_indev_def_terrain_higher;
- npindev_steepness = &nparams_indev_def; //&nparams_indev_def_steepness;
+ npindev_terrain_base = nparams_indev_def; //&nparams_indev_def_terrain_base;
+ npindev_terrain_higher = nparams_indev_def; //&nparams_indev_def_terrain_higher;
+ npindev_steepness = nparams_indev_def; //&nparams_indev_def_steepness;
//np_height_select = &nparams_v6_def_height_select;
//np_trees = &nparams_v6_def_trees;
- npindev_mud = &nparams_indev_def; //&nparams_indev_def_mud;
+ npindev_mud = nparams_indev_def; //&nparams_indev_def_mud;
//np_beach = &nparams_v6_def_beach;
- npindev_biome = &nparams_indev_def; //&nparams_indev_def_biome;
+ npindev_biome = nparams_indev_def; //&nparams_indev_def_biome;
//np_cave = &nparams_v6_def_cave;
- npindev_float_islands1 = &nparams_indev_def; //&nparams_indev_def_float_islands;
- npindev_float_islands2 = &nparams_indev_def; //&nparams_indev_def_float_islands;
- npindev_float_islands3 = &nparams_indev_def; //&nparams_indev_def_float_islands;
+ npindev_float_islands1 = nparams_indev_def; //&nparams_indev_def_float_islands;
+ npindev_float_islands2 = nparams_indev_def; //&nparams_indev_def_float_islands;
+ npindev_float_islands3 = nparams_indev_def; //&nparams_indev_def_float_islands;
}
diff --git a/src/mapgen_singlenode.h b/src/mapgen_singlenode.h
index b86c9a77f..8b816aa25 100644
--- a/src/mapgen_singlenode.h
+++ b/src/mapgen_singlenode.h
@@ -24,8 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct MapgenSinglenodeParams : public MapgenParams {
- MapgenSinglenodeParams() {
- }
+ MapgenSinglenodeParams() {}
+ ~MapgenSinglenodeParams() {}
bool readParams(Settings *settings);
void writeParams(Settings *settings);
diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp
index d90d142d5..e5ff72a60 100644
--- a/src/mapgen_v6.cpp
+++ b/src/mapgen_v6.cpp
@@ -80,18 +80,18 @@ MapgenV6::MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge)
this->ystride = csize.X; //////fix this
- np_cave = params->np_cave;
- np_humidity = params->np_humidity;
- np_trees = params->np_trees;
- np_apple_trees = params->np_apple_trees;
-
- noise_terrain_base = new Noise(params->np_terrain_base, seed, csize.X, csize.Y);
- noise_terrain_higher = new Noise(params->np_terrain_higher, seed, csize.X, csize.Y);
- noise_steepness = new Noise(params->np_steepness, seed, csize.X, csize.Y);
- noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Y);
- noise_mud = new Noise(params->np_mud, seed, csize.X, csize.Y);
- noise_beach = new Noise(params->np_beach, seed, csize.X, csize.Y);
- noise_biome = new Noise(params->np_biome, seed, csize.X, csize.Y);
+ np_cave = &params->np_cave;
+ np_humidity = &params->np_humidity;
+ np_trees = &params->np_trees;
+ np_apple_trees = &params->np_apple_trees;
+
+ noise_terrain_base = new Noise(&params->np_terrain_base, seed, csize.X, csize.Y);
+ noise_terrain_higher = new Noise(&params->np_terrain_higher, seed, csize.X, csize.Y);
+ noise_steepness = new Noise(&params->np_steepness, seed, csize.X, csize.Y);
+ noise_height_select = new Noise(&params->np_height_select, seed, csize.X, csize.Y);
+ noise_mud = new Noise(&params->np_mud, seed, csize.X, csize.Y);
+ noise_beach = new Noise(&params->np_beach, seed, csize.X, csize.Y);
+ noise_biome = new Noise(&params->np_biome, seed, csize.X, csize.Y);
}
diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h
index a0276fb59..8f456fd3f 100644
--- a/src/mapgen_v6.h
+++ b/src/mapgen_v6.h
@@ -45,35 +45,36 @@ extern NoiseParams nparams_v6_def_apple_trees;
struct MapgenV6Params : public MapgenParams {
float freq_desert;
float freq_beach;
- NoiseParams *np_terrain_base;
- NoiseParams *np_terrain_higher;
- NoiseParams *np_steepness;
- NoiseParams *np_height_select;
- NoiseParams *np_mud;
- NoiseParams *np_beach;
- NoiseParams *np_biome;
- NoiseParams *np_cave;
- NoiseParams *np_humidity;
- NoiseParams *np_trees;
- NoiseParams *np_apple_trees;
+ NoiseParams np_terrain_base;
+ NoiseParams np_terrain_higher;
+ NoiseParams np_steepness;
+ NoiseParams np_height_select;
+ NoiseParams np_mud;
+ NoiseParams np_beach;
+ NoiseParams np_biome;
+ NoiseParams np_cave;
+ NoiseParams np_humidity;
+ NoiseParams np_trees;
+ NoiseParams np_apple_trees;
MapgenV6Params() {
freq_desert = 0.45;
freq_beach = 0.15;
- np_terrain_base = &nparams_v6_def_terrain_base;
- np_terrain_higher = &nparams_v6_def_terrain_higher;
- np_steepness = &nparams_v6_def_steepness;
- np_height_select = &nparams_v6_def_height_select;
- np_mud = &nparams_v6_def_mud;
- np_beach = &nparams_v6_def_beach;
- np_biome = &nparams_v6_def_biome;
- np_cave = &nparams_v6_def_cave;
- np_humidity = &nparams_v6_def_humidity;
- np_trees = &nparams_v6_def_trees;
- np_apple_trees = &nparams_v6_def_apple_trees;
-
+ np_terrain_base = nparams_v6_def_terrain_base;
+ np_terrain_higher = nparams_v6_def_terrain_higher;
+ np_steepness = nparams_v6_def_steepness;
+ np_height_select = nparams_v6_def_height_select;
+ np_mud = nparams_v6_def_mud;
+ np_beach = nparams_v6_def_beach;
+ np_biome = nparams_v6_def_biome;
+ np_cave = nparams_v6_def_cave;
+ np_humidity = nparams_v6_def_humidity;
+ np_trees = nparams_v6_def_trees;
+ np_apple_trees = nparams_v6_def_apple_trees;
}
+ ~MapgenV6Params() {}
+
bool readParams(Settings *settings);
void writeParams(Settings *settings);
};
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp
index 4bfc866e2..2fb5d7b9b 100644
--- a/src/mapgen_v7.cpp
+++ b/src/mapgen_v7.cpp
@@ -85,12 +85,12 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
this->ridge_heightmap = new s16[csize.X * csize.Z];
// Terrain noise
- noise_terrain_base = new Noise(params->np_terrain_base, seed, csize.X, csize.Z);
- noise_terrain_alt = new Noise(params->np_terrain_alt, seed, csize.X, csize.Z);
- noise_terrain_mod = new Noise(params->np_terrain_mod, seed, csize.X, csize.Z);
- noise_terrain_persist = new Noise(params->np_terrain_persist, seed, csize.X, csize.Z);
- noise_height_select = new Noise(params->np_height_select, seed, csize.X, csize.Z);
- noise_ridge = new Noise(params->np_ridge, seed, csize.X, csize.Y, csize.Z);
+ noise_terrain_base = new Noise(&params->np_terrain_base, seed, csize.X, csize.Z);
+ noise_terrain_alt = new Noise(&params->np_terrain_alt, seed, csize.X, csize.Z);
+ noise_terrain_mod = new Noise(&params->np_terrain_mod, seed, csize.X, csize.Z);
+ noise_terrain_persist = new Noise(&params->np_terrain_persist, seed, csize.X, csize.Z);
+ noise_height_select = new Noise(&params->np_height_select, seed, csize.X, csize.Z);
+ noise_ridge = new Noise(&params->np_ridge, seed, csize.X, csize.Y, csize.Z);
// Biome noise
noise_heat = new Noise(bmgr->np_heat, seed, csize.X, csize.Z);
diff --git a/src/mapgen_v7.h b/src/mapgen_v7.h
index 3391098ea..b6b03689d 100644
--- a/src/mapgen_v7.h
+++ b/src/mapgen_v7.h
@@ -30,22 +30,24 @@ extern NoiseParams nparams_v7_def_height_select;
extern NoiseParams nparams_v7_def_ridge;
struct MapgenV7Params : public MapgenParams {
- NoiseParams *np_terrain_base;
- NoiseParams *np_terrain_alt;
- NoiseParams *np_terrain_mod;
- NoiseParams *np_terrain_persist;
- NoiseParams *np_height_select;
- NoiseParams *np_ridge;
+ NoiseParams np_terrain_base;
+ NoiseParams np_terrain_alt;
+ NoiseParams np_terrain_mod;
+ NoiseParams np_terrain_persist;
+ NoiseParams np_height_select;
+ NoiseParams np_ridge;
MapgenV7Params() {
- np_terrain_base = &nparams_v7_def_terrain_base;
- np_terrain_alt = &nparams_v7_def_terrain_alt;
- np_terrain_mod = &nparams_v7_def_terrain_mod;
- np_terrain_persist = &nparams_v7_def_terrain_persist;
- np_height_select = &nparams_v7_def_height_select;
- np_ridge = &nparams_v7_def_ridge;
+ np_terrain_base = nparams_v7_def_terrain_base;
+ np_terrain_alt = nparams_v7_def_terrain_alt;
+ np_terrain_mod = nparams_v7_def_terrain_mod;
+ np_terrain_persist = nparams_v7_def_terrain_persist;
+ np_height_select = nparams_v7_def_height_select;
+ np_ridge = nparams_v7_def_ridge;
}
+ ~MapgenV7Params() {}
+
bool readParams(Settings *settings);
void writeParams(Settings *settings);
};
diff --git a/src/noise.h b/src/noise.h
index ace6d7eb4..0bf1a2f13 100644
--- a/src/noise.h
+++ b/src/noise.h
@@ -72,8 +72,8 @@ struct NoiseParams {
// Convenience macros for getting/setting NoiseParams in Settings
-#define getNoiseParams(x) getStruct<NoiseParams>((x), "f,f,v3,s32,s32,f")
-#define setNoiseParams(x, y) setStruct((x), "f,f,v3,s32,s32,f", (y))
+#define getNoiseParams(x, y) getStruct((x), "f,f,v3,s32,s32,f", &(y), sizeof(y))
+#define setNoiseParams(x, y) setStruct((x), "f,f,v3,s32,s32,f", &(y))
class Noise {
public:
@@ -88,7 +88,7 @@ public:
Noise(NoiseParams *np, int seed, int sx, int sy);
Noise(NoiseParams *np, int seed, int sx, int sy, int sz);
- ~Noise();
+ virtual ~Noise();
virtual void init(NoiseParams *np, int seed, int sx, int sy, int sz);
void setSize(int sx, int sy);
diff --git a/src/settings.h b/src/settings.h
index 1b7e3cb09..e7b49b6d7 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -577,15 +577,15 @@ public:
return (isdigit(val[0])) ? stoi(val) : readFlagString(val, flagdesc);
}
- template <class T> T *getStruct(std::string name, std::string format)
+ bool getStruct(std::string name, std::string format, void *out, size_t olen)
{
- size_t len = sizeof(T);
+ size_t len = olen;
std::vector<std::string *> strs_alloced;
std::string *str;
std::string valstr = get(name);
char *s = &valstr[0];
- T *buf = new T;
- char *bufpos = (char *)buf;
+ char *buf = new char[len];
+ char *bufpos = buf;
char *f, *snext;
size_t pos;
@@ -608,7 +608,7 @@ public:
case 'i':
if (width == 16) {
bufpos += PADDING(bufpos, u16);
- if ((bufpos - (char *)buf) + sizeof(u16) <= len) {
+ if ((bufpos - buf) + sizeof(u16) <= len) {
if (is_unsigned)
*(u16 *)bufpos = (u16)strtoul(s, &s, 10);
else
@@ -617,7 +617,7 @@ public:
bufpos += sizeof(u16);
} else if (width == 32) {
bufpos += PADDING(bufpos, u32);
- if ((bufpos - (char *)buf) + sizeof(u32) <= len) {
+ if ((bufpos - buf) + sizeof(u32) <= len) {
if (is_unsigned)
*(u32 *)bufpos = (u32)strtoul(s, &s, 10);
else
@@ -626,7 +626,7 @@ public:
bufpos += sizeof(u32);
} else if (width == 64) {
bufpos += PADDING(bufpos, u64);
- if ((bufpos - (char *)buf) + sizeof(u64) <= len) {
+ if ((bufpos - buf) + sizeof(u64) <= len) {
if (is_unsigned)
*(u64 *)bufpos = (u64)strtoull(s, &s, 10);
else
@@ -642,7 +642,7 @@ public:
*snext++ = 0;
bufpos += PADDING(bufpos, bool);
- if ((bufpos - (char *)buf) + sizeof(bool) <= len)
+ if ((bufpos - buf) + sizeof(bool) <= len)
*(bool *)bufpos = is_yes(std::string(s));
bufpos += sizeof(bool);
@@ -650,7 +650,7 @@ public:
break;
case 'f':
bufpos += PADDING(bufpos, float);
- if ((bufpos - (char *)buf) + sizeof(float) <= len)
+ if ((bufpos - buf) + sizeof(float) <= len)
*(float *)bufpos = strtof(s, &s);
bufpos += sizeof(float);
@@ -674,7 +674,7 @@ public:
while ((pos = str->find("\\\"", pos)) != std::string::npos)
str->erase(pos, 1);
- if ((bufpos - (char *)buf) + sizeof(std::string *) <= len)
+ if ((bufpos - buf) + sizeof(std::string *) <= len)
*(std::string **)bufpos = str;
bufpos += sizeof(std::string *);
strs_alloced.push_back(str);
@@ -690,7 +690,7 @@ public:
if (width == 2) {
bufpos += PADDING(bufpos, v2f);
- if ((bufpos - (char *)buf) + sizeof(v2f) <= len) {
+ if ((bufpos - buf) + sizeof(v2f) <= len) {
v2f *v = (v2f *)bufpos;
v->X = strtof(s, &s);
s++;
@@ -700,7 +700,7 @@ public:
bufpos += sizeof(v2f);
} else if (width == 3) {
bufpos += PADDING(bufpos, v3f);
- if ((bufpos - (char *)buf) + sizeof(v3f) <= len) {
+ if ((bufpos - buf) + sizeof(v3f) <= len) {
v3f *v = (v3f *)bufpos;
v->X = strtof(s, &s);
s++;
@@ -720,20 +720,21 @@ public:
if (s && *s == ',')
s++;
- if ((size_t)(bufpos - (char *)buf) > len) //error, buffer too small
+ if ((size_t)(bufpos - buf) > len) //error, buffer too small
goto fail;
}
if (f && *f) { //error, mismatched number of fields and values
fail:
- for (unsigned int i = 0; i != strs_alloced.size(); i++)
+ for (size_t i = 0; i != strs_alloced.size(); i++)
delete strs_alloced[i];
- delete buf;
- //delete[] buf;
- buf = NULL;
+ delete[] buf;
+ return false;
}
- return buf;
+ memcpy(out, buf, olen);
+ delete[] buf;
+ return true;
}
bool setStruct(std::string name, std::string format, void *value)