{"action":"created","comment":{"url":"https://api.github.com/repos/minetest/minetest/pulls/comments/49677701","id":49677701,"diff_hunk":"@@ -0,0 +1,1013 @@\n+/*\n+Minetest Valleys C\n+Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net>\n+Copyright (C) 2010-2015 paramat, Matt Gregory\n+Copyright (C) 2016 Duane Robertson <duane@duanerobertson.com>\n+\n+Based on Valleys Mapgen by Gael de Sailly\n+ (https://forum.minetest.net/viewtopic.php?f=9&t=11430)\n+and mapgen_v7 by kwolekr and paramat.\n+\n+Licensing changed by permission of Gael de Sailly.\n+\n+This program is free software; you can redistribute it and/or modify\n+it under the terms of the GNU Lesser General Public License as published by\n+the Free Software Foundation; either version 2.1 of the License, or\n+(at your option) any later version.\n+\n+This program is distributed in the hope that it will be useful,\n+but WITHOUT ANY WARRANTY; without even the implied warranty of\n+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+GNU Lesser General Public License for more details.\n+\n+You should have received a copy of the GNU Lesser General Public License along\n+with this program; if not, write to the Free Software Foundation, Inc.,\n+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n+*/\n+\n+\n+#include \"mapgen.h\"\n+#include \"voxel.h\"\n+#include \"noise.h\"\n+#include \"mapblock.h\"\n+#include \"mapnode.h\"\n+#include \"map.h\"\n+#include \"content_sao.h\"\n+#include \"nodedef.h\"\n+#include \"voxelalgorithms.h\"\n+#include \"settings.h\" // For g_settings\n+#include \"emerge.h\"\n+#include \"dungeongen.h\"\n+#include \"treegen.h\"\n+#include \"mg_biome.h\"\n+#include \"mg_ore.h\"\n+#include \"mg_decoration.h\"\n+#include \"mapgen_valleys.h\"\n+\n+//#undef NDEBUG\n+//#include \"assert.h\"\n+\n+//#include \"util/timetaker.h\"\n+//#include \"profiler.h\"\n+\n+\n+//static Profiler mapgen_prof;\n+//Profiler *mapgen_profiler = &mapgen_prof;\n+\n+static FlagDesc flagdesc_mapgen_valleys[] = {\n+\t{\"altitude_chill\",  MG_VALLEYS_ALT_CHILL},\n+\t{\"cliffs\",          MG_VALLEYS_CLIFFS},\n+\t{\"fast\",            MG_VALLEYS_FAST},\n+\t{\"humid_rivers\",    MG_VALLEYS_HUMID_RIVERS},\n+\t{\"rugged\",          MG_VALLEYS_RUGGED},\n+\t{NULL,              0}\n+};\n+\n+///////////////////////////////////////////////////////////////////////////////\n+\n+\n+MapgenValleys::MapgenValleys(int mapgenid, MapgenParams *params, EmergeManager *emerge)\n+\t: Mapgen(mapgenid, params, emerge)\n+{\n+\tthis->m_emerge = emerge;\n+\tthis->bmgr = emerge->biomemgr;\n+\n+\t//// amount of elements to skip for the next index\n+\t//// for noise/height/biome maps (not vmanip)\n+\tthis->ystride = csize.X;\n+\tthis->zstride = csize.X * (csize.Y + 2);\n+\n+\tthis->biomemap  = new u8[csize.X * csize.Z];\n+\tthis->heightmap = new s16[csize.X * csize.Z];\n+\tthis->heatmap   = NULL;\n+\tthis->humidmap  = NULL;\n+\n+\tMapgenValleysParams *sp = (MapgenValleysParams *)params->sparams;\n+\tthis->spflags = sp->spflags;\n+\n+\tthis->cliff_terrain      = (spflags & MG_VALLEYS_CLIFFS);\n+\tthis->fast_terrain       = (spflags & MG_VALLEYS_FAST);\n+\tthis->humid_rivers       = (spflags & MG_VALLEYS_HUMID_RIVERS);\n+\tthis->rugged_terrain     = (spflags & MG_VALLEYS_RUGGED);\n+\tthis->use_altitude_chill = (spflags & MG_VALLEYS_ALT_CHILL);\n+\n+\tthis->altitude_chill        = sp->altitude_chill;\n+\tthis->cave_water_max_height = sp->cave_water_max_height;\n+\tthis->humidity_adjust       = sp->humidity - 50.f;\n+\tthis->humidity_break_point  = sp->humidity_break_point;\n+\tthis->lava_max_height       = sp->lava_max_height;\n+\tthis->river_depth           = sp->river_depth + 1.f;\n+\tthis->river_size            = sp->river_size / 100.f;\n+\tthis->temperature_adjust    = sp->temperature - 50.f;\n+\tthis->water_features        = MYMAX(1, MYMIN(11, 11 - sp->water_features));\n+\n+\t//// 2D Terrain noise\n+\tnoise_cliffs             = new Noise(&sp->np_cliffs,             seed, csize.X, csize.Z);\n+\tnoise_corr               = new Noise(&sp->np_corr,               seed, csize.X, csize.Z);\n+\tnoise_filler_depth       = new Noise(&sp->np_filler_depth,       seed, csize.X, csize.Z);\n+\tnoise_inter_valley_slope = new Noise(&sp->np_inter_valley_slope, seed, csize.X, csize.Z);\n+\tnoise_rivers             = new Noise(&sp->np_rivers,             seed, csize.X, csize.Z);\n+\tnoise_terrain_height     = new Noise(&sp->np_terrain_height,     seed, csize.X, csize.Z);\n+\tnoise_valley_depth       = new Noise(&sp->np_valley_depth,       seed, csize.X, csize.Z);\n+\tnoise_valley_profile     = new Noise(&sp->np_valley_profile,     seed, csize.X, csize.Z);\n+\n+\tif (this->fast_terrain)\n+\t\tnoise_inter_valley_fill = new Noise(&sp->np_inter_valley_fill, seed, csize.X, csize.Z);\n+\n+\t//// 3D Terrain noise\n+\tnoise_simple_caves_1 = new Noise(&sp->np_simple_caves_1, seed, csize.X, csize.Y + 2, csize.Z);\n+\tnoise_simple_caves_2 = new Noise(&sp->np_simple_caves_2, seed, csize.X, csize.Y + 2, csize.Z);\n+\n+\tif (!this->fast_terrain)\n+\t\tnoise_inter_valley_fill = new Noise(&sp->np_inter_valley_fill, seed, csize.X, csize.Y + 2, csize.Z);\n+\n+\t//// Biome noise\n+\tnoise_heat_blend     = new Noise(&params->np_biome_heat_blend,     seed, csize.X, csize.Z);\n+\tnoise_heat           = new Noise(&params->np_biome_heat,           seed, csize.X, csize.Z);\n+\tnoise_humidity_blend = new Noise(&params->np_biome_humidity_blend, seed, csize.X, csize.Z);\n+\tnoise_humidity       = new Noise(&params->np_biome_humidity,       seed, csize.X, csize.Z);\n+\n+\t//// Resolve nodes to be used\n+\tINodeDefManager *ndef = emerge->ndef;\n+\n+\tc_cobble               = ndef->getId(\"mapgen_cobble\");\n+\tc_desert_stone         = ndef->getId(\"mapgen_desert_stone\");\n+\tc_dirt                 = ndef->getId(\"mapgen_dirt\");\n+\tc_lava_source          = ndef->getId(\"mapgen_lava_source\");\n+\tc_mossycobble          = ndef->getId(\"mapgen_mossycobble\");\n+\tc_river_water_source   = ndef->getId(\"mapgen_river_water_source\");\n+\tc_sand                 = ndef->getId(\"mapgen_sand\");\n+\tc_sandstonebrick       = ndef->getId(\"mapgen_sandstonebrick\");\n+\tc_sandstone            = ndef->getId(\"mapgen_sandstone\");\n+\tc_stair_cobble         = ndef->getId(\"mapgen_stair_cobble\");\n+\tc_stair_sandstonebrick = ndef->getId(\"mapgen_stair_sandstonebrick\");\n+\tc_stone                = ndef->getId(\"mapgen_stone\");\n+\tc_water_source         = ndef->getId(\"mapgen_water_source\");\n+\n+\tif (c_mossycobble == CONTENT_IGNORE)\n+\t\tc_mossycobble = c_cobble;\n+\tif (c_river_water_source == CONTENT_IGNORE)\n+\t\tc_river_water_source = c_water_source;\n+\tif (c_sand == CONTENT_IGNORE)\n+\t\tc_sand = c_stone;\n+\tif (c_sandstonebrick == CONTENT_IGNORE)\n+\t\tc_sandstonebrick = c_sandstone;\n+\tif (c_stair_cobble == CONTENT_IGNORE)\n+\t\tc_stair_cobble = c_cobble;\n+\tif (c_stair_sandstonebrick == CONTENT_IGNORE)\n+\t\tc_stair_sandstonebrick = c_sandstone;\n+}\n+\n+\n+MapgenValleys::~MapgenValleys()\n+{\n+\tdelete noise_cliffs;\n+\tdelete noise_corr;\n+\tdelete noise_filler_depth;\n+\tdelete noise_heat;\n+\tdelete noise_heat_blend;\n+\tdelete noise_humidity;\n+\tdelete noise_humidity_blend;\n+\tdelete noise_inter_valley_fill;\n+\tdelete noise_inter_valley_slope;\n+\tdelete noise_rivers;\n+\tdelete noise_simple_caves_1;\n+\tdelete noise_simple_caves_2;\n+\tdelete noise_terrain_height;\n+\tdelete noise_valley_depth;\n+\tdelete noise_valley_profile;\n+\n+\tdelete[] heightmap;\n+\tdelete[] biomemap;\n+}\n+\n+\n+MapgenValleysParams::MapgenValleysParams()\n+{\n+\tspflags = MG_VALLEYS_CLIFFS | MG_VALLEYS_RUGGED\n+\t         \t| MG_VALLEYS_HUMID_RIVERS | MG_VALLEYS_ALT_CHILL;\n+\n+\taltitude_chill         =  90; // The altitude at which temperature drops by 20C.\n+\t// Water in caves will never be higher than this.\n+\tcave_water_max_height  =  MAX_MAP_GENERATION_LIMIT;\n+\thumidity               =  50;\n+\t// the maximum humidity around rivers in otherwise dry areas\n+\thumidity_break_point   =  65;\n+\tlava_max_height        =  0;  // Lava will never be higher than this.\n+\triver_depth            =  4;  // How deep to carve river channels.\n+\triver_size             =  5;  // How wide to make rivers.\n+\ttemperature            =  50;\n+\twater_features         =  3;  // How often water will occur in caves.\n+\n+\tnp_cliffs             = NoiseParams(0.f,   1.f,  v3f(750,  750,  750),  8445,  5, 1.f,  2.f);\n+\tnp_corr               = NoiseParams(0.f,   1.f,  v3f(40,   40,   40),   -3536, 4, 1.f,  2.f);\n+\tnp_filler_depth       = NoiseParams(0.f,   1.2f, v3f(256,  256,  256),  1605,  3, 0.5f, 2.f);\n+\tnp_inter_valley_fill  = NoiseParams(0.f,   1.f,  v3f(256,  512,  256),  1993,  6, 0.8f, 2.f);\n+\tnp_inter_valley_slope = NoiseParams(0.5f,  0.5f, v3f(128,  128,  128),  746,   1, 1.f,  2.f);\n+\tnp_rivers             = NoiseParams(0.f,   1.f,  v3f(256,  256,  256),  -6050, 5, 0.6f, 2.f);\n+\tnp_simple_caves_1     = NoiseParams(0.f,   1.f,  v3f(64,   64,   64),   -8402, 3, 0.5f, 2.f);\n+\tnp_simple_caves_2     = NoiseParams(0.f,   1.f,  v3f(64,   64,   64),   3944,  3, 0.5f, 2.f);\n+\tnp_terrain_height     = NoiseParams(-10.f, 50.f, v3f(1024, 1024, 1024), 5202,  6, 0.4f, 2.f);\n+\tnp_valley_depth       = NoiseParams(5.f,   4.f,  v3f(512,  512,  512),  -1914, 1, 1.f,  2.f);\n+\tnp_valley_profile     = NoiseParams(0.6f,  0.5f, v3f(512,  512,  512),  777,   1, 1.f,  2.f);\n+\t}\n+\n+\n+void MapgenValleysParams::readParams(const Settings *settings)\n+{\n+\tsettings->getFlagStrNoEx(\"mg_valleys_spflags\", spflags, flagdesc_mapgen_valleys);\n+\n+\tsettings->getU16NoEx(\"mg_valleys_altitude_chill\",        altitude_chill);\n+\tsettings->getS16NoEx(\"mg_valleys_cave_water_max_height\", cave_water_max_height);\n+\tsettings->getS16NoEx(\"mg_valleys_humidity\",              humidity);\n+\tsettings->getS16NoEx(\"mg_valleys_humidity_break_point\",  humidity_break_point);\n+\tsettings->getS16NoEx(\"mg_valleys_lava_max_height\",       lava_max_height);\n+\tsettings->getU16NoEx(\"mg_valleys_river_depth\",           river_depth);\n+\tsettings->getU16NoEx(\"mg_valleys_river_size\",            river_size);\n+\tsettings->getS16NoEx(\"mg_valleys_temperature\",           temperature);\n+\tsettings->getU16NoEx(\"mg_valleys_water_features\",        water_features);\n+\n+\tsettings->getNoiseParams(\"mg_valleys_np_cliffs\",             np_cliffs);\n+\tsettings->getNoiseParams(\"mg_valleys_np_corr\",               np_corr);\n+\tsettings->getNoiseParams(\"mg_valleys_np_filler_depth\",       np_filler_depth);\n+\tsettings->getNoiseParams(\"mg_valleys_np_inter_valley_fill\",  np_inter_valley_fill);\n+\tsettings->getNoiseParams(\"mg_valleys_np_inter_valley_slope\", np_inter_valley_slope);\n+\tsettings->getNoiseParams(\"mg_valleys_np_rivers\",             np_rivers);\n+\tsettings->getNoiseParams(\"mg_valleys_np_simple_caves_1\",     np_simple_caves_1);\n+\tsettings->getNoiseParams(\"mg_valleys_np_simple_caves_2\",     np_simple_caves_2);\n+\tsettings->getNoiseParams(\"mg_valleys_np_terrain_height\",     np_terrain_height);\n+\tsettings->getNoiseParams(\"mg_valleys_np_valley_depth\",       np_valley_depth);\n+\tsettings->getNoiseParams(\"mg_valleys_np_valley_profile\",     np_valley_profile);\n+}\n+\n+\n+void MapgenValleysParams::writeParams(Settings *settings) const\n+{\n+\tsettings->setFlagStr(\"mg_valleys_spflags\", spflags, flagdesc_mapgen_valleys, U32_MAX);\n+\n+\tsettings->setU16(\"mg_valleys_altitude_chill\",        altitude_chill);\n+\tsettings->setS16(\"mg_valleys_cave_water_max_height\", cave_water_max_height);\n+\tsettings->setS16(\"mg_valleys_humidity\",              humidity);\n+\tsettings->setS16(\"mg_valleys_humidity_break_point\",  humidity_break_point);\n+\tsettings->setS16(\"mg_valleys_lava_max_height\",       lava_max_height);\n+\tsettings->setU16(\"mg_valleys_river_depth\",           river_depth);\n+\tsettings->setU16(\"mg_valleys_river_size\",            river_size);\n+\tsettings->setS16(\"mg_valleys_temperature\",           temperature);\n+\tsettings->setU16(\"mg_valleys_water_features\",        water_features);\n+\n+\tsettings->setNoiseParams(\"mg_valleys_np_cliffs\",             np_cliffs);\n+\tsettings->setNoiseParams(\"mg_valleys_np_corr\",               np_corr);\n+\tsettings->setNoiseParams(\"mg_valleys_np_filler_depth\",       np_filler_depth);\n+\tsettings->setNoiseParams(\"mg_valleys_np_inter_valley_fill\",  np_inter_valley_fill);\n+\tsettings->setNoiseParams(\"mg_valleys_np_inter_valley_slope\", np_inter_valley_slope);\n+\tsettings->setNoiseParams(\"mg_valleys_np_rivers\",             np_rivers);\n+\tsettings->setNoiseParams(\"mg_valleys_np_simple_caves_1\",     np_simple_caves_1);\n+\tsettings->setNoiseParams(\"mg_valleys_np_simple_caves_2\",     np_simple_caves_2);\n+\tsettings->setNoiseParams(\"mg_valleys_np_terrain_height\",     np_terrain_height);\n+\tsettings->setNoiseParams(\"mg_valleys_np_valley_depth\",       np_valley_depth);\n+\tsettings->setNoiseParams(\"mg_valleys_np_valley_profile\",     np_valley_profile);\n+}\n+\n+\n+///////////////////////////////////////\n+\n+\n+void MapgenValleys::makeChunk(BlockMakeData *data)\n+{\n+\t// Pre-conditions\n+\tassert(data->vmanip);\n+\tassert(data->nodedef);\n+\tassert(data->blockpos_requested.X >= data->blockpos_min.X &&\n+\t\tdata->blockpos_requested.Y >= data->blockpos_min.Y &&\n+\t\tdata->blockpos_requested.Z >= data->blockpos_min.Z);\n+\tassert(data->blockpos_requested.X <= data->blockpos_max.X &&\n+\t\tdata->blockpos_requested.Y <= data->blockpos_max.Y &&\n+\t\tdata->blockpos_requested.Z <= data->blockpos_max.Z);\n+\n+\tthis->generating = true;\n+\tthis->vm   = data->vmanip;\n+\tthis->ndef = data->nodedef;\n+\n+\t//TimeTaker t(\"makeChunk\");\n+\n+\tv3s16 blockpos_min = data->blockpos_min;\n+\tv3s16 blockpos_max = data->blockpos_max;\n+\tnode_min = blockpos_min * MAP_BLOCKSIZE;\n+\tnode_max = (blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1);\n+\tfull_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE;\n+\tfull_node_max = (blockpos_max + 2) * MAP_BLOCKSIZE - v3s16(1, 1, 1);\n+\n+\tblockseed = getBlockSeed2(full_node_min, seed);\n+\n+\t// Generate noise maps and base terrain height.\n+\tcalculateNoise();\n+\n+\t// Generate base terrain with initial heightmaps\n+\ts16 stone_surface_max_y = generateTerrain();\n+\n+\t// Create biomemap at heightmap surface\n+\tbmgr->calcBiomes(csize.X, csize.Z, heatmap, humidmap, heightmap, biomemap);\n+\n+\t// Actually place the biome-specific nodes\n+\tMgStoneType stone_type = generateBiomes(heatmap, humidmap);\n+\n+\t// Cave creation.\n+\tif (flags & MG_CAVES)\n+\t\tgenerateSimpleCaves(stone_surface_max_y);\n+\n+\t// Dungeon creation\n+\tif ((flags & MG_DUNGEONS) && node_max.Y < 50 && (stone_surface_max_y >= node_min.Y)) {\n+\t\tDungeonParams dp;\n+\n+\t\tdp.np_rarity  = nparams_dungeon_rarity;\n+\t\tdp.np_density = nparams_dungeon_density;\n+\t\tdp.np_wetness = nparams_dungeon_wetness;\n+\t\tdp.c_water    = c_water_source;\n+\t\tif (stone_type == STONE) {\n+\t\t\tdp.c_cobble = c_cobble;\n+\t\t\tdp.c_moss   = c_mossycobble;\n+\t\t\tdp.c_stair  = c_stair_cobble;\n+\n+\t\t\tdp.diagonal_dirs = false;\n+\t\t\tdp.mossratio     = 3.f;\n+\t\t\tdp.holesize      = v3s16(1, 2, 1);\n+\t\t\tdp.roomsize      = v3s16(0, 0, 0);\n+\t\t\tdp.notifytype    = GENNOTIFY_DUNGEON;\n+\t\t} else if (stone_type == DESERT_STONE) {\n+\t\t\tdp.c_cobble = c_desert_stone;\n+\t\t\tdp.c_moss   = c_desert_stone;\n+\t\t\tdp.c_stair  = c_desert_stone;\n+\n+\t\t\tdp.diagonal_dirs = true;\n+\t\t\tdp.mossratio     = 0.f;\n+\t\t\tdp.holesize      = v3s16(2, 3, 2);\n+\t\t\tdp.roomsize      = v3s16(2, 5, 2);\n+\t\t\tdp.notifytype    = GENNOTIFY_TEMPLE;\n+\t\t} else if (stone_type == SANDSTONE) {\n+\t\t\tdp.c_cobble = c_sandstonebrick;\n+\t\t\tdp.c_moss   = c_sandstonebrick;\n+\t\t\tdp.c_stair  = c_sandstonebrick;\n+\n+\t\t\tdp.diagonal_dirs = false;\n+\t\t\tdp.mossratio     = 0.f;\n+\t\t\tdp.holesize      = v3s16(2, 2, 2);\n+\t\t\tdp.roomsize      = v3s16(2, 0, 2);\n+\t\t\tdp.notifytype    = GENNOTIFY_DUNGEON;\n+\t\t}\n+\n+\t\tDungeonGen dgen(this, &dp);\n+\t\tdgen.generate(blockseed, full_node_min, full_node_max);\n+\t}\n+\n+\t// Generate the registered decorations\n+\tif (flags & MG_DECORATIONS)\n+\t\tm_emerge->decomgr->placeAllDecos(this, blockseed, node_min, node_max);\n+\n+\t// Generate the registered ores\n+\tm_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);\n+\n+\t// Sprinkle some dust on top after everything else was generated\n+\tdustTopNodes();\n+\n+\t//TimeTaker tll(\"liquid_lighting\");\n+\n+\tupdateLiquid(&data->transforming_liquid, full_node_min, full_node_max);\n+\n+\tif (flags & MG_LIGHT)\n+\t\tcalcLighting(\n+\t\t\t\tnode_min - v3s16(0, 1, 0), \n+\t\t\t\tnode_max + v3s16(0, 1, 0), \n+\t\t\t\tfull_node_min, \n+\t\t\t\tfull_node_max);\n+\n+\t//mapgen_profiler->avg(\"liquid_lighting\", tll.stop() / 1000.f);\n+\t//mapgen_profiler->avg(\"makeChunk\", t.stop() / 1000.f);\n+\n+\tthis->generating = false;\n+}\n+\n+\n+// Populate the noise tables and do most of the\n+// calculation necessary to determine terrain height.\n+void MapgenValleys::calculateNoise()\n+{\n+\t//TimeTaker t(\"calculateNoise\", NULL, PRECISION_MICRO);\n+\n+\tint x = node_min.X;\n+\tint y = node_min.Y - 1;\n+\tint z = node_min.Z;\n+\n+\t//TimeTaker tcn(\"actualNoise\");\n+\n+\tnoise_filler_depth->perlinMap2D(x, z);\n+\tnoise_heat_blend->perlinMap2D(x, z);\n+\tnoise_heat->perlinMap2D(x, z);\n+\tnoise_humidity_blend->perlinMap2D(x, z);\n+\tnoise_humidity->perlinMap2D(x, z);\n+\tnoise_inter_valley_slope->perlinMap2D(x, z);\n+\tnoise_rivers->perlinMap2D(x, z);\n+\tnoise_terrain_height->perlinMap2D(x, z);\n+\tnoise_valley_depth->perlinMap2D(x, z);\n+\tnoise_valley_profile->perlinMap2D(x, z);\n+\n+\tif (fast_terrain) {\n+\t\t// Make this 2D for speed, if requested.\n+\t\tnoise_inter_valley_fill->perlinMap2D(x, z);\n+\n+\t\tif (cliff_terrain)\n+\t\t\tnoise_cliffs->perlinMap2D(x, z);\n+\t\tif (rugged_terrain)\n+\t\t\tnoise_corr->perlinMap2D(x, z);\n+\t} else {\n+\t\tnoise_inter_valley_fill->perlinMap3D(x, y, z);\n+\t}\n+\n+\tif (flags & MG_CAVES) {\n+\t\tnoise_simple_caves_1->perlinMap3D(x, y, z);\n+\t\tnoise_simple_caves_2->perlinMap3D(x, y, z);\n+\t}\n+\n+\t//mapgen_profiler->avg(\"noisemaps\", tcn.stop() / 1000.f);\n+\n+\tfor (s32 index = 0; index < csize.X * csize.Z; index++) {\n+\t\tnoise_heat->result[index] += noise_heat_blend->result[index];\n+\t\tnoise_heat->result[index] += temperature_adjust;\n+\t\tnoise_humidity->result[index] += noise_humidity_blend->result[index];\n+\t}\n+\n+\tu32 index = 0;\n+\tfor (s16 zi = node_min.Z; zi <= node_max.Z; zi++)\n+\tfor (s16 xi = node_min.X; xi <= node_max.X; xi++, index++) {\n+\t\t// The parameters that we actually need to generate terrain\n+\t\t//  are passed by address (and the return value).\n+\t\tfloat mount = terrainLevelFromNoise(xi, zi,\n+\t\t\t\tnoise_terrain_height->result[index],\n+\t\t\t\t// River noise is replaced with base terrain, which\n+\t\t\t\t// is basically the height of the water table.\n+\t\t\t\t&noise_rivers->result[index],\n+\t\t\t\t// Valley depth noise is replaced with the valley\n+\t\t\t\t// number that represents the height of terrain\n+\t\t\t\t// over rivers and is used to determine about\n+\t\t\t\t// how close a river is for humidity calculation.\n+\t\t\t\t&noise_valley_depth->result[index],\n+\t\t\t\tnoise_valley_profile->result[index],\n+\t\t\t\t// Slope noise is replaced by the calculated slope\n+\t\t\t\t// which is used to get terrain height in the slow\n+\t\t\t\t// method, to create sharper mountains.\n+\t\t\t\t&noise_inter_valley_slope->result[index],\n+\t\t\t\tnoise_inter_valley_fill->result[index],\n+\t\t\t\tnoise_cliffs->result[index],\n+\t\t\t\tnoise_corr->result[index]);\n+\n+\t\tnoise_terrain_height->result[index] = mount;\n+\n+\t\tif (fast_terrain) {\n+\t\t\t// Assign the humidity adjusted by water proximity.\n+\t\t\t// I can't think of a reason why a mod would expect base humidity\n+\t\t\t//  from noise or at any altitude other than ground level.\n+\t\t\tnoise_humidity->result[index] = humidityByTerrain(\n+\t\t\t\t\tnoise_humidity->result[index],\n+\t\t\t\t\tmount,\n+\t\t\t\t\tnoise_rivers->result[index],\n+\t\t\t\t\tnoise_valley_depth->result[index]);\n+\n+\t\t\t// Assign the heat adjusted by altitude. See humidity, above.\n+\t\t\tif (use_altitude_chill && mount > 0.f)\n+\t\t\t\tnoise_heat->result[index] *= pow(0.5f, (mount - altitude_chill / 3.f) / altitude_chill);\n+\t\t}\n+\t}\n+\n+\theatmap = noise_heat->result;\n+\thumidmap = noise_humidity->result;\n+}\n+\n+\n+// This ugly function keeps us from having to maintain two similar sets of\n+//  complicated code to determine ground level.\n+float MapgenValleys::terrainLevelFromNoise(\n+\t\ts16 x,","path":"src/mapgen_valleys.cpp","position":488,"original_position":488,"commit_id":"cea3e7a464452b84a5d8a1f38670d7e631a1b455","original_commit_id":"cea3e7a464452b84a5d8a1f38670d7e631a1b455","user":{"login":"paramat","id":3686677,"avatar_url":"https://avatars.githubusercontent.com/u/3686677?v=3","gravatar_id":"","url":"https://api.github.com/users/paramat","html_url":"https://github.com/paramat","followers_url":"https://api.github.com/users/paramat/followers","following_url":"https://api.github.com/users/paramat/following{/other_user}","gists_url":"https://api.github.com/users/paramat/gists{/gist_id}","starred_url":"https://api.github.com/users/paramat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paramat/subscriptions","organizations_url":"https://api.github.com/users/paramat/orgs","repos_url":"https://api.github.com/users/paramat/repos","events_url":"https://api.github.com/users/paramat/events{/privacy}","received_events_url":"https://api.github.com/users/paramat/received_events","type":"User","site_admin":false},"body":"Which parameters?","created_at":"2016-01-14T01:31:28Z","updated_at":"2016-01-14T01:31:28Z","html_url":"https://github.com/minetest/minetest/pull/3508#discussion_r49677701","pull_request_url":"https://api.github.com/repos/minetest/minetest/pulls/3508","_links":{"self":{"href":"https://api.github.com/repos/minetest/minetest/pulls/comments/49677701"},"html":{"href":"https://github.com/minetest/minetest/pull/3508#discussion_r49677701"},"pull_request":{"href":"https://api.github.com/repos/minetest/minetest/pulls/3508"}}},"pull_request":{"url":"https://api.github.com/repos/minetest/minetest/pulls/3508","id":54885908,"html_url":"https://github.com/minetest/minetest/pull/3508","diff_url":"https://github.com/minetest/minetest/pull/3508.diff","patch_url":"https://github.com/minetest/minetest/pull/3508.patch","issue_url":"https://api.github.com/repos/minetest/minetest/issues/3508","number":3508,"state":"open","locked":false,"title":"Valleys C++ Mapgen","user":{"login":"duane-r","id":14078065,"avatar_url":"https://avatars.githubusercontent.com/u/14078065?v=3","gravatar_id":"","url":"https://api.github.com/users/duane-r","html_url":"https://github.com/duane-r","followers_url":"https://api.github.com/users/duane-r/followers","following_url":"https://api.github.com/users/duane-r/following{/other_user}","gists_url":"https://api.github.com/users/duane-r/gists{/gist_id}","starred_url":"https://api.github.com/users/duane-r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duane-r/subscriptions","organizations_url":"https://api.github.com/users/duane-r/orgs","repos_url":"https://api.github.com/users/duane-r/repos","events_url":"https://api.github.com/users/duane-r/events{/privacy}","received_events_url":"https://api.github.com/users/duane-r/received_events","type":"User","site_admin":false},"body":"This is a mapgen based on the Valleys Mapgen mod. It features realistic terrain with rivers and an interconnected cave system.\r\n\r\nSee also: https://forum.minetest.net/viewtopic.php?f=9&t=11430","created_at":"2016-01-01T01:26:52Z","updated_at":"2016-01-14T01:31:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7c8dfc06192bf1c9050fdb961d6929ac0bf9861","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/minetest/minetest/pulls/3508/commits","review_comments_url":"https://api.github.com/repos/minetest/minetest/pulls/3508/comments","review_comment_url":"https://api.github.com/repos/minetest/minetest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/minetest/minetest/issues/3508/comments","statuses_url":"https://api.github.com/repos/minetest/minetest/statuses/cea3e7a464452b84a5d8a1f38670d7e631a1b455","head":{"label":"duane-r:val_merge","ref":"val_merge","sha":"cea3e7a464452b84a5d8a1f38670d7e631a1b455","user":{"login":"duane-r","id":14078065,"avatar_url":"https://avatars.githubusercontent.com/u/14078065?v=3","gravatar_id":"","url":"https://api.github.com/users/duane-r","html_url":"https://github.com/duane-r","followers_url":"https://api.github.com/users/duane-r/followers","following_url":"https://api.github.com/users/duane-r/following{/other_user}","gists_url":"https://api.github.com/users/duane-r/gists{/gist_id}","starred_url":"https://api.github.com/users/duane-r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duane-r/subscriptions","organizations_url":"https://api.github.com/users/duane-r/orgs","repos_url":"https://api.github.com/users/duane-r/repos","events_url":"https://api.github.com/users/duane-r/events{/privacy}","received_events_url":"https://api.github.com/users/duane-r/received_events","type":"User","site_admin":false},"repo":{"id":42430991,"name":"minetest","full_name":"duane-r/minetest","owner":{"login":"duane-r","id":14078065,"avatar_url":"https://avatars.githubusercontent.com/u/14078065?v=3","gravatar_id":"","url":"https://api.github.com/users/duane-r","html_url":"https://github.com/duane-r","followers_url":"https://api.github.com/users/duane-r/followers","following_url":"https://api.github.com/users/duane-r/following{/other_user}","gists_url":"https://api.github.com/users/duane-r/gists{/gist_id}","starred_url":"https://api.github.com/users/duane-r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duane-r/subscriptions","organizations_url":"https://api.github.com/users/duane-r/orgs","repos_url":"https://api.github.com/users/duane-r/repos","events_url":"https://api.github.com/users/duane-r/events{/privacy}","received_events_url":"https://api.github.com/users/duane-r/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/duane-r/minetest","description":"Valleys C version of Minetest, adds a new mapgen","fork":true,"url":"https://api.github.com/repos/duane-r/minetest","forks_url":"https://api.github.com/repos/duane-r/minetest/forks","keys_url":"https://api.github.com/repos/duane-r/minetest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duane-r/minetest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duane-r/minetest/teams","hooks_url":"https://api.github.com/repos/duane-r/minetest/hooks","issue_events_url":"https://api.github.com/repos/duane-r/minetest/issues/events{/number}","events_url":"https://api.github.com/repos/duane-r/minetest/events","assignees_url":"https://api.github.com/repos/duane-r/minetest/assignees{/user}","branches_url":"https://api.github.com/repos/duane-r/minetest/branches{/branch}","tags_url":"https://api.github.com/repos/duane-r/minetest/tags","blobs_url":"https://api.github.com/repos/duane-r/minetest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duane-r/minetest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duane-r/minetest/git/refs{/sha}","trees_url":"https://api.github.com/repos/duane-r/minetest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duane-r/minetest/statuses/{sha}","languages_url":"https://api.github.com/repos/duane-r/minetest/languages","stargazers_url":"https://api.github.com/repos/duane-r/minetest/stargazers","contributors_url":"https://api.github.com/repos/duane-r/minetest/contributors","subscribers_url":"https://api.github.com/repos/duane-r/minetest/subscribers","subscription_url":"https://api.github.com/repos/duane-r/minetest/subscription","commits_url":"https://api.github.com/repos/duane-r/minetest/commits{/sha}","git_commits_url":"https://api.github.com/repos/duane-r/minetest/git/commits{/sha}","comments_url":"https://api.github.com/repos/duane-r/minetest/comments{/number}","issue_comment_url":"https://api.github.com/repos/duane-r/minetest/issues/comments{/number}","contents_url":"https://api.github.com/repos/duane-r/minetest/contents/{+path}","compare_url":"https://api.github.com/repos/duane-r/minetest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duane-r/minetest/merges","archive_url":"https://api.github.com/repos/duane-r/minetest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duane-r/minetest/downloads","issues_url":"https://api.github.com/repos/duane-r/minetest/issues{/number}","pulls_url":"https://api.github.com/repos/duane-r/minetest/pulls{/number}","milestones_url":"https://api.github.com/repos/duane-r/minetest/milestones{/number}","notifications_url":"https://api.github.com/repos/duane-r/minetest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duane-r/minetest/labels{/name}","releases_url":"https://api.github.com/repos/duane-r/minetest/releases{/id}","created_at":"2015-09-14T06:26:31Z","updated_at":"2015-10-05T19:22:20Z","pushed_at":"2016-01-13T07:46:46Z","git_url":"git://github.com/duane-r/minetest.git","ssh_url":"git@github.com:duane-r/minetest.git","clone_url":"https://github.com/duane-r/minetest.git","svn_url":"https://github.com/duane-r/minetest","homepage":"https://forum.minetest.net/viewtopic.php?f=9&t=11430","size":44663,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"minetest:master","ref":"master","sha":"8fc8cb819b60dcaca887056e9fcb9cb7927412f1","user":{"login":"minetest","id":2624745,"avatar_url":"https://avatars.githubusercontent.com/u/2624745?v=3","gravatar_id":"","url":"https://api.github.com/users/minetest","html_url":"https://github.com/minetest","followers_url":"https://api.github.com/users/minetest/followers","following_url":"https://api.github.com/users/minetest/following{/other_user}","gists_url":"https://api.github.com/users/minetest/gists{/gist_id}","starred_url":"https://api.github.com/users/minetest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minetest/subscriptions","organizations_url":"https://api.github.com/users/minetest/orgs","repos_url":"https://api.github.com/users/minetest/repos","events_url":"https://api.github.com/users/minetest/events{/privacy}","received_events_url":"https://api.github.com/users/minetest/received_events","type":"Organization","site_admin":false},"repo":{"id":2168780,"name":"minetest","full_name":"minetest/minetest","owner":{"login":"minetest","id":2624745,"avatar_url":"https://avatars.githubusercontent.com/u/2624745?v=3","gravatar_id":"","url":"https://api.github.com/users/minetest","html_url":"https://github.com/minetest","followers_url":"https://api.github.com/users/minetest/followers","following_url":"https://api.github.com/users/minetest/following{/other_user}","gists_url":"https://api.github.com/users/minetest/gists{/gist_id}","starred_url":"https://api.github.com/users/minetest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minetest/subscriptions","organizations_url":"https://api.github.com/users/minetest/orgs","repos_url":"https://api.github.com/users/minetest/repos","events_url":"https://api.github.com/users/minetest/events{/privacy}","received_events_url":"https://api.github.com/users/minetest/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/minetest/minetest","description":"Minetest, an open source infinite-world block sandbox game with survival and crafting. [also https://github.com/minetest/minetest_game]","fork":false,"url":"https://api.github.com/repos/minetest/minetest","forks_url":"https://api.github.com/repos/minetest/minetest/forks","keys_url":"https://api.github.com/repos/minetest/minetest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minetest/minetest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minetest/minetest/teams","hooks_url":"https://api.github.com/repos/minetest/minetest/hooks","issue_events_url":"https://api.github.com/repos/minetest/minetest/issues/events{/number}","events_url":"https://api.github.com/repos/minetest/minetest/events","assignees_url":"https://api.github.com/repos/minetest/minetest/assignees{/user}","branches_url":"https://api.github.com/repos/minetest/minetest/branches{/branch}","tags_url":"https://api.github.com/repos/minetest/minetest/tags","blobs_url":"https://api.github.com/repos/minetest/minetest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minetest/minetest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minetest/minetest/git/refs{/sha}","trees_url":"https://api.github.com/repos/minetest/minetest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minetest/minetest/statuses/{sha}","languages_url":"https://api.github.com/repos/minetest/minetest/languages","stargazers_url":"https://api.github.com/repos/minetest/minetest/stargazers","contributors_url":"https://api.github.com/repos/minetest/minetest/contributors","subscribers_url":"https://api.github.com/repos/minetest/minetest/subscribers","subscription_url":"https://api.github.com/repos/minetest/minetest/subscription","commits_url":"https://api.github.com/repos/minetest/minetest/commits{/sha}","git_commits_url":"https://api.github.com/repos/minetest/minetest/git/commits{/sha}","comments_url":"https://api.github.com/repos/minetest/minetest/comments{/number}","issue_comment_url":"https://api.github.com/repos/minetest/minetest/issues/comments{/number}","contents_url":"https://api.github.com/repos/minetest/minetest/contents/{+path}","compare_url":"https://api.github.com/repos/minetest/minetest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minetest/minetest/merges","archive_url":"https://api.github.com/repos/minetest/minetest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minetest/minetest/downloads","issues_url":"https://api.github.com/repos/minetest/minetest/issues{/number}","pulls_url":"https://api.github.com/repos/minetest/minetest/pulls{/number}","milestones_url":"https://api.github.com/repos/minetest/minetest/milestones{/number}","notifications_url":"https://api.github.com/repos/minetest/minetest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minetest/minetest/labels{/name}","releases_url":"https://api.github.com/repos/minetest/minetest/releases{/id}","created_at":"2011-08-07T13:48:36Z","updated_at":"2016-01-13T18:12:39Z","pushed_at":"2016-01-13T07:46:47Z","git_url":"git://github.com/minetest/minetest.git","ssh_url":"git@github.com:minetest/minetest.git","clone_url":"https://github.com/minetest/minetest.git","svn_url":"https://github.com/minetest/minetest","homepage":"http://minetest.net/","size":91134,"stargazers_count":1760,"watchers_count":1760,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":585,"mirror_url":null,"open_issues_count":686,"forks":585,"open_issues":686,"watchers":1760,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/minetest/minetest/pulls/3508"},"html":{"href":"https://github.com/minetest/minetest/pull/3508"},"issue":{"href":"https://api.github.com/repos/minetest/minetest/issues/3508"},"comments":{"href":"https://api.github.com/repos/minetest/minetest/issues/3508/comments"},"review_comments":{"href":"https://api.github.com/repos/minetest/minetest/pulls/3508/comments"},"review_comment":{"href":"https://api.github.com/repos/minetest/minetest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/minetest/minetest/pulls/3508/commits"},"statuses":{"href":"https://api.github.com/repos/minetest/minetest/statuses/cea3e7a464452b84a5d8a1f38670d7e631a1b455"}}}}