]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/mapgen.cpp
Node placement client-side prediction
[dragonfireclient.git] / src / mapgen.cpp
index 1d1d663c097306e39ca046295db0e397af3056e3..a487e8f6dd04bd4d5da39ca82c3b2c75a755524a 100644 (file)
@@ -3,16 +3,16 @@ Minetest-c55
 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
 
-You should have received a copy of the GNU General Public License along
+You should have received a copy of the GNU Lesser General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
@@ -1297,7 +1297,7 @@ BiomeType get_biome(u64 seed, v2s16 p2d)
        double d = noise2d_perlin(
                        0.6+(float)p2d.X/250, 0.2+(float)p2d.Y/250,
                        seed+9130, 3, 0.50);
-       if(d > 0.2)
+       if(d > 0.35)
                return BT_DESERT;
        return BT_NORMAL;
 };
@@ -1510,10 +1510,11 @@ void make_block(BlockMakeData *data)
                        0.5+(double)node_min.X/250, 0.5+(double)node_min.Y/250,
                        data->seed+34329, 3, 0.50);
        cave_amount = MYMAX(0.0, cave_amount);
-       u32 caves_count = cave_amount * volume_nodes / 20000;
+       u32 caves_count = cave_amount * volume_nodes / 50000;
        u32 bruises_count = 1;
        PseudoRandom ps(blockseed+21343);
-       if(ps.range(1, 4) == 1)
+       PseudoRandom ps2(blockseed+1032);
+       if(ps.range(1, 6) == 1)
                bruises_count = ps.range(0, ps.range(0, 2));
        if(get_biome(data->seed, v2s16(node_min.X, node_min.Y)) == BT_DESERT){
                caves_count /= 3;
@@ -1523,7 +1524,7 @@ void make_block(BlockMakeData *data)
        {
                bool large_cave = (jj >= caves_count);
                s16 min_tunnel_diameter = 2;
-               s16 max_tunnel_diameter = ps.range(2,5);
+               s16 max_tunnel_diameter = ps.range(2,6);
                int dswitchint = ps.range(1,14);
                u16 tunnel_routepoints = 0;
                int part_max_length_rs = 0;
@@ -1629,12 +1630,15 @@ void make_block(BlockMakeData *data)
                                );
                                main_direction *= (float)ps.range(0, 10)/10;
                        }
-
+                       
                        // Randomize size
                        s16 min_d = min_tunnel_diameter;
                        s16 max_d = max_tunnel_diameter;
                        s16 rs = ps.range(min_d, max_d);
                        
+                       // Every second section is rough
+                       bool randomize_xz = (ps2.range(1,2) == 1);
+
                        v3s16 maxlen;
                        if(large_cave)
                        {
@@ -1703,8 +1707,12 @@ void make_block(BlockMakeData *data)
                                fp.Z += 0.1*ps.range(-10,10);
                                v3s16 cp(fp.X, fp.Y, fp.Z);
 
-                               s16 d0 = -rs/2 + ps.range(-1,1);
-                               s16 d1 = d0 + rs + ps.range(-1,1);
+                               s16 d0 = -rs/2;
+                               s16 d1 = d0 + rs;
+                               if(randomize_xz){
+                                       d0 += ps.range(-1,1);
+                                       d1 += ps.range(-1,1);
+                               }
                                for(s16 z0=d0; z0<=d1; z0++)
                                {
                                        s16 si = rs/2 - MYMAX(0, abs(z0)-rs/7-1);
@@ -1790,11 +1798,6 @@ void make_block(BlockMakeData *data)
                // Node position in 2d
                v2s16 p2d = v2s16(x,z);
                
-               MapNode addnode(c_dirt);
-               BiomeType bt = get_biome(data->seed, p2d);
-               if(bt == BT_DESERT)
-                       addnode = MapNode(c_desert_sand);
-
                // Randomize mud amount
                s16 mud_add_amount = get_mud_add_amount(data->seed, p2d) / 2.0 + 0.5;
 
@@ -1804,7 +1807,15 @@ void make_block(BlockMakeData *data)
                if(surface_y == vmanip.m_area.MinEdge.Y - 1)
                        continue;
 
-               if(mud_add_amount <= 0){
+               MapNode addnode(c_dirt);
+               BiomeType bt = get_biome(data->seed, p2d);
+
+               if(bt == BT_DESERT)
+                       addnode = MapNode(c_desert_sand);
+
+               if(bt == BT_DESERT && surface_y + mud_add_amount <= WATER_LEVEL+1){
+                       addnode = MapNode(c_sand);
+               } else if(mud_add_amount <= 0){
                        mud_add_amount = 1 - mud_add_amount;
                        addnode = MapNode(c_gravel);
                } else if(bt == BT_NORMAL && get_have_beach(data->seed, p2d) &&
@@ -2501,19 +2512,7 @@ void make_block(BlockMakeData *data)
                                                {
                                                        if(have_sand)
                                                        {
-                                                               // Determine whether to have clay in the sand here
-                                                               double claynoise = noise2d_perlin(
-                                                                               0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500,
-                                                                               data->seed+4321, 6, 0.95) + 0.5;
-                               
-                                                               have_clay = (y <= WATER_LEVEL) && (y >= WATER_LEVEL-2) && (
-                                                                       ((claynoise > 0) && (claynoise < 0.04) && (current_depth == 0)) ||
-                                                                       ((claynoise > 0) && (claynoise < 0.12) && (current_depth == 1))
-                                                                       );
-                                                               if (have_clay)
-                                                                       vmanip.m_data[i] = MapNode(c_clay);
-                                                               else
-                                                                       vmanip.m_data[i] = MapNode(c_sand);
+                                                               vmanip.m_data[i] = MapNode(c_sand);
                                                        }
                                                        #if 1
                                                        else if(current_depth==0 && !water_detected