summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2017-06-25 04:45:40 +0100
committerSmallJoker <mk939@ymail.com>2018-06-03 17:31:59 +0200
commita08a93bc9c64ee426132424770fc28bf15457db9 (patch)
treeab18c983f04b7895df74f28cf4ac8c0f22a0c29a
parent6e0557e20c7347f2196c8c76f84d647f8699ec78 (diff)
downloadminetest-a08a93bc9c64ee426132424770fc28bf15457db9.tar.gz
minetest-a08a93bc9c64ee426132424770fc28bf15457db9.tar.bz2
minetest-a08a93bc9c64ee426132424770fc28bf15457db9.zip
Mgv7: Clean up divide-by-zero fix
-rw-r--r--src/mapgen_v7.cpp9
-rw-r--r--src/mapgen_v7.h2
2 files changed, 6 insertions, 5 deletions
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp
index ae500d5f8..3ac099d32 100644
--- a/src/mapgen_v7.cpp
+++ b/src/mapgen_v7.cpp
@@ -57,13 +57,16 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
this->spflags = params->spflags;
this->cave_width = params->cave_width;
this->float_mount_density = params->float_mount_density;
- float_mount_height_lim = MYMAX(params->float_mount_height, 1.0f);
this->floatland_level = params->floatland_level;
this->shadow_limit = params->shadow_limit;
this->cavern_limit = params->cavern_limit;
this->cavern_taper = params->cavern_taper;
this->cavern_threshold = params->cavern_threshold;
+ // This is to avoid a divide-by-zero.
+ // Parameter will be saved to map_meta.txt in limited form.
+ params->float_mount_height = MYMAX(params->float_mount_height, 1.0f);
+
// 2D 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);
@@ -399,8 +402,8 @@ bool MapgenV7::getFloatlandMountainFromMap(int idx_xyz, int idx_xz, s16 y)
{
// Make rim 2 nodes thick to match floatland base terrain
float density_gradient = (y >= floatland_level) ?
- -pow((float)(y - floatland_level) / float_mount_height_lim, 0.75f) :
- -pow((float)(floatland_level - 1 - y) / float_mount_height_lim, 0.75f);
+ -pow((float)(y - floatland_level) / float_mount_height, 0.75f) :
+ -pow((float)(floatland_level - 1 - y) / float_mount_height, 0.75f);
float floatn = noise_mountain->result[idx_xyz] + float_mount_density;
diff --git a/src/mapgen_v7.h b/src/mapgen_v7.h
index 2b79cce51..a69170057 100644
--- a/src/mapgen_v7.h
+++ b/src/mapgen_v7.h
@@ -103,8 +103,6 @@ private:
Noise *noise_float_base_height;
Noise *noise_mountain;
Noise *noise_ridge;
-
- float float_mount_height_lim;
};
#endif