Noise: Prevent unittest crash caused by division by zero
[oweals/minetest.git] / src / mapgen_v6.cpp
index ebbd932d4de88d39526bbcf7a5b790a85bfe89fd..cbc4a19c3fb17d19497ec6ee4973f2330c65dbd6 100644 (file)
@@ -206,7 +206,7 @@ void MapgenV6Params::writeParams(Settings *settings) const
 // Returns Y one under area minimum if not found
 s16 MapgenV6::find_stone_level(v2s16 p2d)
 {
-       v3s16 em = vm->m_area.getExtent();
+       const v3s16 &em = vm->m_area.getExtent();
        s16 y_nodes_max = vm->m_area.MaxEdge.Y;
        s16 y_nodes_min = vm->m_area.MinEdge.Y;
        u32 i = vm->m_area.index(p2d.X, y_nodes_max, p2d.Y);
@@ -619,10 +619,12 @@ void MapgenV6::makeChunk(BlockMakeData *data)
 
        // Generate the registered decorations
        if (flags & MG_DECORATIONS)
-               m_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);
+               m_emerge->decomgr->placeAllDecos(this, blockseed,
+                       node_min, node_max, water_level - 1);
 
        // Generate the registered ores
-       m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
+       m_emerge->oremgr->placeAllOres(this, blockseed,
+               node_min, node_max, water_level - 1);
 
        // Calculate lighting
        if (flags & MG_LIGHT)
@@ -679,7 +681,7 @@ int MapgenV6::generateGround()
                BiomeV6Type bt = getBiome(v2s16(x, z));
 
                // Fill ground with stone
-               v3s16 em = vm->m_area.getExtent();
+               const v3s16 &em = vm->m_area.getExtent();
                u32 i = vm->m_area.index(x, node_min.Y, z);
                for (s16 y = node_min.Y; y <= node_max.Y; y++) {
                        if (vm->m_data[i].getContent() == CONTENT_IGNORE) {
@@ -748,7 +750,7 @@ void MapgenV6::addMud()
 
                // Add mud on ground
                s16 mudcount = 0;
-               v3s16 em = vm->m_area.getExtent();
+               const v3s16 &em = vm->m_area.getExtent();
                s16 y_start = surface_y + 1;
                u32 i = vm->m_area.index(x, y_start, z);
                for (s16 y = y_start; y <= node_max.Y; y++) {
@@ -782,7 +784,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                        // Node position in 2d
                        v2s16 p2d = v2s16(node_min.X, node_min.Z) + v2s16(x, z);
 
-                       v3s16 em = vm->m_area.getExtent();
+                       const v3s16 &em = vm->m_area.getExtent();
                        u32 i = vm->m_area.index(p2d.X, node_max.Y, p2d.Y);
                        s16 y = node_max.Y;
 
@@ -945,7 +947,7 @@ void MapgenV6::placeTreesAndJungleGrass()
        if (c_junglegrass == CONTENT_IGNORE)
                c_junglegrass = CONTENT_AIR;
        MapNode n_junglegrass(c_junglegrass);
-       v3s16 em = vm->m_area.getExtent();
+       const v3s16 &em = vm->m_area.getExtent();
 
        // Divide area into parts
        s16 div = 8;
@@ -1053,7 +1055,7 @@ void MapgenV6::growGrass() // Add surface nodes
        MapNode n_dirt_with_snow(c_dirt_with_snow);
        MapNode n_snowblock(c_snowblock);
        MapNode n_snow(c_snow);
-       v3s16 em = vm->m_area.getExtent();
+       const v3s16 &em = vm->m_area.getExtent();
 
        u32 index = 0;
        for (s16 z = full_node_min.Z; z <= full_node_max.Z; z++)