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_valleys.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_valleys.cpp')
-rw-r--r-- | src/mapgen_valleys.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/mapgen_valleys.cpp b/src/mapgen_valleys.cpp index ceb2c774d..2f96c3397 100644 --- a/src/mapgen_valleys.cpp +++ b/src/mapgen_valleys.cpp @@ -56,8 +56,8 @@ with this program; if not, write to the Free Software Foundation, Inc., //Profiler *mapgen_profiler = &mapgen_prof; static FlagDesc flagdesc_mapgen_valleys[] = { - {"altitude_chill", MG_VALLEYS_ALT_CHILL}, - {"humid_rivers", MG_VALLEYS_HUMID_RIVERS}, + {"altitude_chill", MGVALLEYS_ALT_CHILL}, + {"humid_rivers", MGVALLEYS_HUMID_RIVERS}, {NULL, 0} }; @@ -86,8 +86,8 @@ MapgenValleys::MapgenValleys(int mapgenid, MapgenParams *params, EmergeManager * MapgenValleysParams *sp = (MapgenValleysParams *)params->sparams; this->spflags = sp->spflags; - this->humid_rivers = (spflags & MG_VALLEYS_HUMID_RIVERS); - this->use_altitude_chill = (spflags & MG_VALLEYS_ALT_CHILL); + this->humid_rivers = (spflags & MGVALLEYS_HUMID_RIVERS); + this->use_altitude_chill = (spflags & MGVALLEYS_ALT_CHILL); this->altitude_chill = sp->altitude_chill; this->humidity_adjust = params->np_biome_humidity.offset - 50.f; @@ -181,7 +181,7 @@ MapgenValleys::~MapgenValleys() MapgenValleysParams::MapgenValleysParams() { - spflags = MG_VALLEYS_HUMID_RIVERS | MG_VALLEYS_ALT_CHILL; + spflags = MGVALLEYS_HUMID_RIVERS | MGVALLEYS_ALT_CHILL; altitude_chill = 90; // The altitude at which temperature drops by 20C. large_cave_depth = -33; @@ -513,24 +513,19 @@ float MapgenValleys::adjustedTerrainLevelFromNoise(TerrainNoise *tn) } -int MapgenValleys::getGroundLevelAtPoint(v2s16 p) +int MapgenValleys::getSpawnLevelAtPoint(v2s16 p) { - // *********************************** - // This method (deliberately) does not - // return correct terrain values. - // *********************************** - - // Since MT doesn't normally deal with rivers, check - // to make sure this isn't a request for a location - // in a river. + // Check to make sure this isn't a request for a location in a river. float rivers = NoisePerlin2D(&noise_rivers->np, p.X, p.Y, seed); - - // If it's wet, return an unusable number. if (fabs(rivers) < river_size_factor) - return MAX_MAP_GENERATION_LIMIT; - - // Otherwise, return the real result. - return terrainLevelAtPoint(p.X, p.Y); + return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point + + s16 level_at_point = terrainLevelAtPoint(p.X, p.Y); + if (level_at_point <= water_level || + level_at_point > water_level + 16) + return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point + else + return level_at_point; } |