summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorteddydestodes <derkomtur@schattengang.net>2011-06-01 14:11:52 +0200
committerteddydestodes <derkomtur@schattengang.net>2011-06-01 14:11:52 +0200
commit4ddf2bc8a2531e158d63e92325319f21bea9278d (patch)
tree1a28b7a0b2b454354f2dfdab278b51b0cc741f28 /src/map.cpp
parent9de57d13bc7a97fba17da5807e1ef57d96586deb (diff)
parent5f52a622b6a2602742ea472c1163eba2acf17fb6 (diff)
downloadminetest-4ddf2bc8a2531e158d63e92325319f21bea9278d.tar.gz
minetest-4ddf2bc8a2531e158d63e92325319f21bea9278d.tar.bz2
minetest-4ddf2bc8a2531e158d63e92325319f21bea9278d.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/map.cpp b/src/map.cpp
index a49de3c46..ac5bd7d14 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -2045,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.
*/
@@ -3127,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, 6, 0.95);
+
+ bool have_clay = have_sand && (claynoise > 1.25);
+
// Find ground level
s16 surface_y = find_ground_level_clever(data->vmanip, p2d);
@@ -3143,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
{
@@ -3207,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;