]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/map.cpp
+ clay and associated items
[dragonfireclient.git] / src / map.cpp
index 316d662a616225494e673a0f366e9d8e259340a1..bf9f38c877598d4a39af4975d2cd33fc937b89a3 100644 (file)
@@ -897,6 +897,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
        }
 #endif
 
+#if 0
        /*
                If the new node is mud and it is under sunlight, change it
                to grass
@@ -905,6 +906,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
        {
                n.d = CONTENT_GRASS;
        }
+#endif
 
        /*
                Remove all light that has come out of this node
@@ -2043,6 +2045,20 @@ void make_tree(VoxelManipulator &vmanip, v3s16 p0)
        }
 }
 
+void make_cactus(VoxelManipulator &vmanip, v3s16 p0)
+{
+       MapNode cactusnode(CONTENT_CACTUS);
+
+       s16 trunk_h = 3;
+       v3s16 p1 = p0;
+       for(s16 ii=0; ii<trunk_h; ii++)
+       {
+               if(vmanip.m_area.contains(p1))
+                       vmanip.m_data[vmanip.m_area.index(p1)] = cactusnode;
+               p1.Y++;
+       }
+}
+
 /*
        Noise functions. Make sure seed is mangled differently in each one.
 */
@@ -3125,6 +3141,13 @@ void makeChunk(ChunkMakeData *data)
                if(have_sand == false)
                        continue;
 
+               // 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, 8, 0.95);
+
+               bool have_clay = have_sand && (claynoise > 0.95);
+
                // Find ground level
                s16 surface_y = find_ground_level_clever(data->vmanip, p2d);
                
@@ -3141,7 +3164,10 @@ void makeChunk(ChunkMakeData *data)
                                MapNode *n = &data->vmanip.m_data[i];
                                if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS)
                                {
-                                       n->d = CONTENT_SAND;
+                                       if(have_clay && (surface_y == WATER_LEVEL))
+                                               n->d = CONTENT_CLAY;
+                                       else
+                                               n->d = CONTENT_SAND;
                                }
                                else
                                {
@@ -3205,18 +3231,24 @@ void makeChunk(ChunkMakeData *data)
                                if(y > y_nodes_max - 6)
                                        continue;
                                v3s16 p(x,y,z);
-                               /*
-                                       Trees grow only on mud and grass
-                               */
                                {
                                        u32 i = data->vmanip.m_area.index(v3s16(p));
                                        MapNode *n = &data->vmanip.m_data[i];
-                                       if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS)
+                                       if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND)
                                                continue;
+                                       // Trees grow only on mud and grass
+                                       if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS)
+                                       {
+                                               p.Y++;
+                                               make_tree(data->vmanip, p);
+                                       }
+                                       // Cactii grow only on sand
+                                       if(n->d == CONTENT_SAND)
+                                       {
+                                               p.Y++;
+                                               make_cactus(data->vmanip, p);
+                                       }
                                }
-                               p.Y++;
-                               // Make a tree
-                               make_tree(data->vmanip, p);
                        }
                }
                /*u32 tree_max = relative_area / 60;
@@ -3584,7 +3616,18 @@ void ServerMap::initChunkMake(ChunkMakeData &data, v2s16 chunkpos)
                        sectorpos_base - v2s16(1,1) * max_spread_amount_sectors;
        s16 sectorpos_bigbase_size =
                        sectorpos_base_size + 2 * max_spread_amount_sectors;
-                       
+       
+       // Check limits
+       const s16 limit = MAP_GENERATION_LIMIT / MAP_BLOCKSIZE;
+       if(sectorpos_bigbase.X < -limit
+       || sectorpos_bigbase.X + sectorpos_bigbase_size >= limit
+       || sectorpos_bigbase.Y < -limit
+       || sectorpos_bigbase.Y + sectorpos_bigbase_size >= limit)
+       {
+               data.no_op = true;
+               return;
+       }
+
        data.seed = m_seed;
        data.chunkpos = chunkpos;
        data.y_blocks_min = y_blocks_min;