diff options
author | paramat <mat.gregory@virginmedia.com> | 2016-02-04 01:03:31 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-02-09 07:14:45 +0000 |
commit | 4adbd69a3701608876b50665ed3f7a150750d26e (patch) | |
tree | de3ec585173cbf4e480004c8d64c23489222677f /src/mapgen_v7.cpp | |
parent | 38e712260046f159aa201259569054bdf9793b7f (diff) | |
download | minetest-4adbd69a3701608876b50665ed3f7a150750d26e.tar.gz minetest-4adbd69a3701608876b50665ed3f7a150750d26e.tar.bz2 minetest-4adbd69a3701608876b50665ed3f7a150750d26e.zip |
FindSpawnPos: Let mapgens decide what spawn altitude is suitable
To avoid spawn search failing in new specialised mapgens
Increase spawn search range to 4000 nodes
Add getSpawnLevelAtPoint() functions to EmergeManager, class Mapgen
and all mapgens
Remove getGroundLevelAtPoint() functions from all mapgens except mgv6
(possibly to be re-added later in the correct form to return actual
ground level)
Make mgvalleys flag names consistent with other mapgens
Remove now unused 'vertical spawn range' setting
Diffstat (limited to 'src/mapgen_v7.cpp')
-rw-r--r-- | src/mapgen_v7.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index aec00b938..029f56a45 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -202,7 +202,7 @@ void MapgenV7Params::writeParams(Settings *settings) const /////////////////////////////////////// -int MapgenV7::getGroundLevelAtPoint(v2s16 p) +int MapgenV7::getSpawnLevelAtPoint(v2s16 p) { // Base terrain calculation s16 y = baseTerrainLevelAtPoint(p.X, p.Y); @@ -210,22 +210,24 @@ int MapgenV7::getGroundLevelAtPoint(v2s16 p) // Ridge/river terrain calculation float width = 0.2; float uwatern = NoisePerlin2D(&noise_ridge_uwater->np, p.X, p.Y, seed) * 2; - // actually computing the depth of the ridge is much more expensive; - // if inside a river, simply guess + // if inside a river this is an unsuitable spawn point if (fabs(uwatern) <= width) - return water_level - 10; + return MAX_MAP_GENERATION_LIMIT; // Mountain terrain calculation - int iters = 128; // don't even bother iterating more than 128 times.. + int iters = 128; while (iters--) { - //current point would have been air - if (!getMountainTerrainAtPoint(p.X, y, p.Y)) - return y; - + if (!getMountainTerrainAtPoint(p.X, y + 1, p.Y)) { // Air, y is ground level + if (y <= water_level || y > water_level + 16) + return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point + else + return y; + } y++; } - return y; + // Unsuitable spawn point, no ground surface found + return MAX_MAP_GENERATION_LIMIT; } |