From bee1adc651677fa98717901a5e8dac437c7f3383 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 1 Apr 2012 20:54:36 +0300 Subject: Some completely crapshit coding to make caves more varied --- src/mapgen.cpp | 242 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 146 insertions(+), 96 deletions(-) (limited to 'src') diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 3212b6932..f34526891 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -61,10 +61,13 @@ static s16 find_ground_level(VoxelManipulator &vmanip, v2s16 p2d, return y_nodes_min - 1; } +#if 0 // Returns Y one under area minimum if not found static s16 find_ground_level_clever(VoxelManipulator &vmanip, v2s16 p2d, INodeDefManager *ndef) { + if(!vmanip.m_area.contains(v3s16(p2d.X, vmanip.m_area.MaxEdge.Y, p2d.Y))) + return vmanip.m_area.MinEdge.Y-1; v3s16 em = vmanip.m_area.getExtent(); s16 y_nodes_max = vmanip.m_area.MaxEdge.Y; s16 y_nodes_min = vmanip.m_area.MinEdge.Y; @@ -87,6 +90,7 @@ static s16 find_ground_level_clever(VoxelManipulator &vmanip, v2s16 p2d, else return y_nodes_min - 1; } +#endif // Returns Y one under area minimum if not found static s16 find_stone_level(VoxelManipulator &vmanip, v2s16 p2d, @@ -1444,42 +1448,6 @@ void make_block(BlockMakeData *data) }//timer1 - /* - Add blobs of dirt and gravel underground - */ - { - PseudoRandom pr(blockseed+983); - for(int i=0; i -32 && pr.range(0,1) == 0) - n1 = MapNode(c_dirt); - else - n1 = MapNode(c_gravel); - for(int x1=0; x1seed+34329, 3, 0.50); + cave_amount = MYMAX(0.0, 4.0*cave_amount+2.0); + u32 caves_count = cave_amount * volume_nodes / 100000; + u32 bruises_count = cave_amount * volume_nodes / 400000; + bruises_count *= MYMAX(1, -node_max.Y/100); if(stone_surface_max_y < WATER_LEVEL - 20) bruises_count = 0; for(u32 jj=0; jj= 0){ coming_from_surface = (jj % 4 == 0 && bruise_surface == false); if(coming_from_surface) route_start_y_min = -of.Y + stone_surface_max_y + 10; - } + }*/ route_start_y_min = rangelim(route_start_y_min, 0, ar.Y-1); route_start_y_max = rangelim(route_start_y_max, route_start_y_min, ar.Y-1); @@ -1595,8 +1571,12 @@ void make_block(BlockMakeData *data) (float)(myrand()%ar.Z)+0.5 ); + v3s16 startp(orp.X, orp.Y, orp.Z); + startp += of; + MapNode airnode(CONTENT_AIR); MapNode waternode(c_water_source); + MapNode lavanode(c_lava_source); /* Generate some tunnel starting from orp @@ -1604,14 +1584,14 @@ void make_block(BlockMakeData *data) for(u16 j=0; j WATER_LEVEL){ + if(p.Y <= WATER_LEVEL) + vmanip.m_data[i] = waternode; + else + vmanip.m_data[i] = airnode; + } else if(full_node_max.Y < WATER_LEVEL){ + if(is_bottomish) + vmanip.m_data[i] = MapNode(c_stone); + else if(p.Y < startp.Y - 2) + vmanip.m_data[i] = lavanode; + else + vmanip.m_data[i] = airnode; + } else { vmanip.m_data[i] = airnode; + } } else { + // Don't replace air or water or lava + if(vmanip.m_data[i].getContent() == CONTENT_AIR || + vmanip.m_data[i].getContent() == c_water_source || + vmanip.m_data[i].getContent() == c_lava_source) + continue; vmanip.m_data[i] = airnode; } @@ -1821,6 +1813,48 @@ void make_block(BlockMakeData *data) }//timer1 #endif + /* + Add blobs of dirt and gravel underground + */ + { + PseudoRandom pr(blockseed+983); + for(int i=0; i -32 && pr.range(0,1) == 0) + n1 = MapNode(c_dirt); + else + n1 = MapNode(c_gravel); + for(int x1=0; x1d)) // break; if(n->getContent() == c_dirt || - n->getContent() == c_dirt_with_grass) + n->getContent() == c_dirt_with_grass || + n->getContent() == c_gravel) break; vmanip.m_area.add_y(em, i, -1); @@ -1877,24 +1912,28 @@ void make_block(BlockMakeData *data) if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS) continue;*/ - /* - Don't flow it if the stuff under it is not mud - */ + if(n->getContent() == c_dirt || + n->getContent() == c_dirt_with_grass) { - u32 i2 = i; - vmanip.m_area.add_y(em, i2, -1); - // Cancel if out of area - if(vmanip.m_area.contains(i2) == false) - continue; - MapNode *n2 = &vmanip.m_data[i2]; - if(n2->getContent() != c_dirt && - n2->getContent() != c_dirt_with_grass) - continue; + // Make it exactly mud + n->setContent(c_dirt); + + /* + Don't flow it if the stuff under it is not mud + */ + { + u32 i2 = i; + vmanip.m_area.add_y(em, i2, -1); + // Cancel if out of area + if(vmanip.m_area.contains(i2) == false) + continue; + MapNode *n2 = &vmanip.m_data[i2]; + if(n2->getContent() != c_dirt && + n2->getContent() != c_dirt_with_grass) + continue; + } } - // Make it exactly mud - n->setContent(c_dirt); - /*s16 recurse_count = 0; mudflow_recurse:*/ @@ -2002,9 +2041,15 @@ void make_block(BlockMakeData *data) u32 i = vmanip.m_area.index(v3s16(p2d.X, full_node_max.Y, p2d.Y)); for(s16 y=full_node_max.Y; y>=full_node_min.Y; y--) { - if(water_found == false) + if(y == full_node_max.Y){ + water_found = + (vmanip.m_data[i].getContent() == c_water_source || + vmanip.m_data[i].getContent() == c_lava_source); + } + else if(water_found == false) { - if(vmanip.m_data[i].getContent() == c_water_source) + if(vmanip.m_data[i].getContent() == c_water_source || + vmanip.m_data[i].getContent() == c_lava_source) { v3s16 p = v3s16(p2d.X, y, p2d.Y); data->transforming_liquid.push_back(p); @@ -2016,7 +2061,8 @@ void make_block(BlockMakeData *data) // This can be done because water_found can only // turn to true and end up here after going through // a single block. - if(vmanip.m_data[i+1].getContent() != c_water_source) + if(vmanip.m_data[i+1].getContent() != c_water_source || + vmanip.m_data[i+1].getContent() != c_lava_source) { v3s16 p = v3s16(p2d.X, y+1, p2d.Y); data->transforming_liquid.push_back(p); @@ -2067,8 +2113,12 @@ void make_block(BlockMakeData *data) u32 i = vmanip.m_area.index(p2d.X, surface_y, p2d.Y); MapNode *n = &vmanip.m_data[i]; - if(n->getContent() == c_dirt) + if(n->getContent() == c_dirt){ + // Well yeah, this can't be overground... + if(surface_y < WATER_LEVEL - 20) + continue; n->setContent(c_dirt_with_grass); + } } /* -- cgit v1.2.3