From 0a8519a26fc7c10b4e7415746e9045caa3ae978f Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sat, 15 Jun 2013 22:23:06 -0400 Subject: Add initial Decoration support, many misc. improvements & modifications --- src/mapgen_v6.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'src/mapgen_v6.cpp') diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index eaca33988..a411f966b 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -79,7 +79,7 @@ MapgenV6::MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge) this->freq_beach = params->freq_beach; this->ystride = csize.X; //////fix this - + np_cave = ¶ms->np_cave; np_humidity = ¶ms->np_humidity; np_trees = ¶ms->np_trees; @@ -108,23 +108,6 @@ MapgenV6::~MapgenV6() { //////////////////////// Some helper functions for the map generator -// Returns Y one under area minimum if not found -s16 MapgenV6::find_ground_level(v2s16 p2d) { - 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); - s16 y; - - for (y = y_nodes_max; y >= y_nodes_min; y--) { - MapNode &n = vm->m_data[i]; - if(ndef->get(n).walkable) - break; - - vm->m_area.add_y(em, i, -1); - } - return (y >= y_nodes_min) ? y : y_nodes_min - 1; -} // Returns Y one under area minimum if not found s16 MapgenV6::find_stone_level(v2s16 p2d) { @@ -849,7 +832,7 @@ void MapgenV6::placeTreesAndJungleGrass() { s16 x = grassrandom.range(p2d_min.X, p2d_max.X); s16 z = grassrandom.range(p2d_min.Y, p2d_max.Y); - s16 y = find_ground_level(v2s16(x, z)); ////////////////optimize this! + s16 y = findGroundLevelFull(v2s16(x, z)); ////////////////optimize this! if (y < water_level || y < node_min.Y || y > node_max.Y) continue; @@ -866,7 +849,7 @@ void MapgenV6::placeTreesAndJungleGrass() { for (u32 i = 0; i < tree_count; i++) { s16 x = myrand_range(p2d_min.X, p2d_max.X); s16 z = myrand_range(p2d_min.Y, p2d_max.Y); - s16 y = find_ground_level(v2s16(x, z)); ////////////////////optimize this! + s16 y = findGroundLevelFull(v2s16(x, z)); ////////////////////optimize this! // Don't make a tree under water level // Don't make a tree so high that it doesn't fit if(y < water_level || y > node_max.Y - 6) -- cgit v1.2.3 From f18b4872ea7e46b50c9ea0e5e6484baae41b0a44 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Mon, 17 Jun 2013 21:59:42 -0400 Subject: Decoration: Place decorations in mgv6, check if air or cignore before placement --- src/mapgen_v6.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/mapgen_v6.cpp') diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index a411f966b..d3db00dc2 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -445,6 +445,12 @@ void MapgenV6::makeChunk(BlockMakeData *data) { // Generate some trees, and add grass, if a jungle if (flags & MG_TREES) placeTreesAndJungleGrass(); + + // Generate the registered decorations + for (unsigned int i = 0; i != emerge->decorations.size(); i++) { + Decoration *deco = emerge->decorations[i]; + deco->placeDeco(this, blockseed + i, node_min, node_max); + } // Generate the registered ores for (unsigned int i = 0; i != emerge->ores.size(); i++) { -- cgit v1.2.3