]> git.lizzy.rs Git - minetest.git/blobdiff - src/mapgen_valleys.cpp
Remove ClientMap::m_camera_mutex
[minetest.git] / src / mapgen_valleys.cpp
index f003ae63c1d89cf8759847be2d9a356c98a8b74e..2f96c339773f673a4461129ac84aa5211d8df921 100644 (file)
@@ -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;
@@ -99,8 +99,8 @@ MapgenValleys::MapgenValleys(int mapgenid, MapgenParams *params, EmergeManager *
        this->water_features_lim = rangelim(sp->water_features, 0, 10);
 
        // a small chance of overflows if the settings are very high
-       this->cave_water_max_height = water_level + MYMAX(0, water_features_lim - 6) * 50;
-       this->lava_max_height       = water_level + MYMAX(0, lava_features_lim - 6) * 50;
+       this->cave_water_max_height = water_level + MYMAX(0, water_features_lim - 4) * 50;
+       this->lava_max_height       = water_level + MYMAX(0, lava_features_lim - 4) * 50;
 
        tcave_cache = new float[csize.Y + 2];
 
@@ -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;
@@ -482,7 +482,8 @@ float MapgenValleys::terrainLevelFromNoise(TerrainNoise *tn)
 
                // base - depth : height of the bottom of the river
                // water_level - 6 : don't make rivers below 6 nodes under the surface
-               mount = rangelim(base - depth, (float) (water_level - 6), mount);
+               // There is no logical equivalent to this using rangelim.
+               mount = MYMIN(MYMAX(base - depth, (float) (water_level - 6)), mount);
 
                // Slope has no influence on rivers.
                *tn->slope = 0.f;
@@ -512,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;
 }
 
 
@@ -846,8 +842,8 @@ void MapgenValleys::generateCaves(s16 max_stone_y)
 
        // Reduce the odds of overflows even further.
        if (node_max.Y > water_level) {
-               lava_chance /= 5;
-               water_chance /= 5;
+               lava_chance /= 3;
+               water_chance /= 3;
        }
 
        u32 index_2d = 0;