]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/mapgen_flat.cpp
Sound: Add pitch option (#5960)
[dragonfireclient.git] / src / mapgen_flat.cpp
index cc43684c466e2ee9c189283e44a51bf19d3a5e9a..604c79dd0b59b78107500fef2c36d44dcefad872 100644 (file)
@@ -1,7 +1,7 @@
 /*
 Minetest
-Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
-Copyright (C) 2010-2015 paramat, Matt Gregory
+Copyright (C) 2015-2017 paramat
+Copyright (C) 2015-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
@@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "emerge.h"
 #include "dungeongen.h"
 #include "cavegen.h"
-#include "treegen.h"
 #include "mg_biome.h"
 #include "mg_ore.h"
 #include "mg_decoration.h"
@@ -49,50 +48,35 @@ FlagDesc flagdesc_mapgen_flat[] = {
 ///////////////////////////////////////////////////////////////////////////////////////
 
 
-MapgenFlat::MapgenFlat(int mapgenid, MapgenParams *params, EmergeManager *emerge)
+MapgenFlat::MapgenFlat(int mapgenid, MapgenFlatParams *params, EmergeManager *emerge)
        : MapgenBasic(mapgenid, params, emerge)
 {
-       MapgenFlatParams *sp = (MapgenFlatParams *)params->sparams;
-
-       this->spflags          = sp->spflags;
-       this->ground_level     = sp->ground_level;
-       this->large_cave_depth = sp->large_cave_depth;
-       this->cave_width       = sp->cave_width;
-       this->lake_threshold   = sp->lake_threshold;
-       this->lake_steepness   = sp->lake_steepness;
-       this->hill_threshold   = sp->hill_threshold;
-       this->hill_steepness   = sp->hill_steepness;
-
-       //// 2D noise
-       noise_terrain      = new Noise(&sp->np_terrain,      seed, csize.X, csize.Z);
-       noise_filler_depth = new Noise(&sp->np_filler_depth, seed, csize.X, csize.Z);
-
-       MapgenBasic::np_cave1 = sp->np_cave1;
-       MapgenBasic::np_cave2 = sp->np_cave2;
-
-       // Content used for dungeon generation
-       c_cobble               = ndef->getId("mapgen_cobble");
-       c_stair_cobble         = ndef->getId("mapgen_stair_cobble");
-       c_mossycobble          = ndef->getId("mapgen_mossycobble");
-       c_sandstonebrick       = ndef->getId("mapgen_sandstonebrick");
-       c_stair_sandstonebrick = ndef->getId("mapgen_stair_sandstonebrick");
-
-       // Fall back to more basic content if not defined
-       if (c_mossycobble == CONTENT_IGNORE)
-               c_mossycobble = c_cobble;
-       if (c_stair_cobble == CONTENT_IGNORE)
-               c_stair_cobble = c_cobble;
-       if (c_sandstonebrick == CONTENT_IGNORE)
-               c_sandstonebrick = c_sandstone;
-       if (c_stair_sandstonebrick == CONTENT_IGNORE)
-               c_stair_sandstonebrick = c_sandstone;
+       this->spflags          = params->spflags;
+       this->ground_level     = params->ground_level;
+       this->large_cave_depth = params->large_cave_depth;
+       this->cave_width       = params->cave_width;
+       this->lake_threshold   = params->lake_threshold;
+       this->lake_steepness   = params->lake_steepness;
+       this->hill_threshold   = params->hill_threshold;
+       this->hill_steepness   = params->hill_steepness;
+
+       // 2D noise
+       noise_filler_depth = new Noise(&params->np_filler_depth, seed, csize.X, csize.Z);
+
+       if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS))
+               noise_terrain = new Noise(&params->np_terrain, seed, csize.X, csize.Z);
+       // 3D noise
+       MapgenBasic::np_cave1 = params->np_cave1;
+       MapgenBasic::np_cave2 = params->np_cave2;
 }
 
 
 MapgenFlat::~MapgenFlat()
 {
-       delete noise_terrain;
        delete noise_filler_depth;
+
+       if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS))
+               delete noise_terrain;
 }
 
 
@@ -101,7 +85,7 @@ MapgenFlatParams::MapgenFlatParams()
        spflags          = 0;
        ground_level     = 8;
        large_cave_depth = -33;
-       cave_width       = 0.3;
+       cave_width       = 0.09;
        lake_threshold   = -0.45;
        lake_steepness   = 48.0;
        hill_threshold   = 0.45;
@@ -109,8 +93,8 @@ MapgenFlatParams::MapgenFlatParams()
 
        np_terrain      = NoiseParams(0, 1,   v3f(600, 600, 600), 7244,  5, 0.6, 2.0);
        np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261,   3, 0.7, 2.0);
-       np_cave1        = NoiseParams(0, 12,  v3f(96,  96,  96),  52534, 4, 0.5, 2.0);
-       np_cave2        = NoiseParams(0, 12,  v3f(96,  96,  96),  10325, 4, 0.5, 2.0);
+       np_cave1        = NoiseParams(0, 12,  v3f(61,  61,  61),  52534, 3, 0.5, 2.0);
+       np_cave2        = NoiseParams(0, 12,  v3f(67,  67,  67),  10325, 3, 0.5, 2.0);
 }
 
 
@@ -156,7 +140,9 @@ void MapgenFlatParams::writeParams(Settings *settings) const
 int MapgenFlat::getSpawnLevelAtPoint(v2s16 p)
 {
        s16 level_at_point = ground_level;
-       float n_terrain = NoisePerlin2D(&noise_terrain->np, p.X, p.Y, seed);
+       float n_terrain = 0.0f;
+       if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS))
+               n_terrain = NoisePerlin2D(&noise_terrain->np, p.X, p.Y, seed);
 
        if ((spflags & MGFLAT_LAKES) && n_terrain < lake_threshold) {
                level_at_point = ground_level -
@@ -209,54 +195,13 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
 
        // Init biome generator, place biome-specific nodes, and build biomemap
        biomegen->calcBiomeNoise(node_min);
-       biomegen->getBiomes(heightmap);
        MgStoneType stone_type = generateBiomes();
 
        if (flags & MG_CAVES)
                generateCaves(stone_surface_max_y, large_cave_depth);
 
-       if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
-               DungeonParams dp;
-
-               dp.np_rarity  = nparams_dungeon_rarity;
-               dp.np_density = nparams_dungeon_density;
-               dp.np_wetness = nparams_dungeon_wetness;
-               dp.c_water    = c_water_source;
-               if (stone_type == MGSTONE_STONE) {
-                       dp.c_cobble = c_cobble;
-                       dp.c_moss   = c_mossycobble;
-                       dp.c_stair  = c_stair_cobble;
-
-                       dp.diagonal_dirs = false;
-                       dp.mossratio     = 3.0;
-                       dp.holesize      = v3s16(1, 2, 1);
-                       dp.roomsize      = v3s16(0, 0, 0);
-                       dp.notifytype    = GENNOTIFY_DUNGEON;
-               } else if (stone_type == MGSTONE_DESERT_STONE) {
-                       dp.c_cobble = c_desert_stone;
-                       dp.c_moss   = c_desert_stone;
-                       dp.c_stair  = c_desert_stone;
-
-                       dp.diagonal_dirs = true;
-                       dp.mossratio     = 0.0;
-                       dp.holesize      = v3s16(2, 3, 2);
-                       dp.roomsize      = v3s16(2, 5, 2);
-                       dp.notifytype    = GENNOTIFY_TEMPLE;
-               } else if (stone_type == MGSTONE_SANDSTONE) {
-                       dp.c_cobble = c_sandstonebrick;
-                       dp.c_moss   = c_sandstonebrick;
-                       dp.c_stair  = c_sandstonebrick;
-
-                       dp.diagonal_dirs = false;
-                       dp.mossratio     = 0.0;
-                       dp.holesize      = v3s16(2, 2, 2);
-                       dp.roomsize      = v3s16(2, 0, 2);
-                       dp.notifytype    = GENNOTIFY_DUNGEON;
-               }
-
-               DungeonGen dgen(this, &dp);
-               dgen.generate(blockseed, full_node_min, full_node_max);
-       }
+       if (flags & MG_DUNGEONS)
+               generateDungeons(stone_surface_max_y, stone_type);
 
        // Generate the registered decorations
        if (flags & MG_DECORATIONS)