]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/mapgen.h
CavesRandomWalk: Make 'lava_depth' a mapgen parameter
[dragonfireclient.git] / src / mapgen.h
index 5fcf2a36548085d9d7809e89b27a872b4a9fc38d..9369a6c357f9b8898a94b9bce3ef283ebdc6b977 100644 (file)
@@ -1,6 +1,8 @@
 /*
 Minetest
-Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2013-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
+Copyright (C) 2015-2017 paramat
 
 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
@@ -26,14 +28,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/string.h"
 #include "util/container.h"
 
-#define MAPGEN_DEFAULT MAPGEN_V6
-#define MAPGEN_DEFAULT_NAME "v6"
+#define MAPGEN_DEFAULT MAPGEN_V7
+#define MAPGEN_DEFAULT_NAME "v7"
 
 /////////////////// Mapgen flags
-#define MG_TREES       0x01
+#define MG_TREES       0x01  // Deprecated. Moved into mgv6 flags
 #define MG_CAVES       0x02
 #define MG_DUNGEONS    0x04
-#define MG_FLAT        0x08
+#define MG_FLAT        0x08  // Deprecated. Moved into mgv6 flags
 #define MG_LIGHT       0x10
 #define MG_DECORATIONS 0x20
 
@@ -103,7 +105,7 @@ class GenerateNotifier {
                bool peek_events=false);
 
 private:
-       u32 m_notify_on;
+       u32 m_notify_on = 0;
        std::set<u32> *m_notify_on_deco_ids;
        std::list<GenNotifyEvent> m_notify_events;
 };
@@ -120,28 +122,33 @@ enum MapgenType {
 };
 
 struct MapgenParams {
-       MapgenType mgtype;
-       s16 chunksize;
-       u64 seed;
-       s16 water_level;
-       u32 flags;
-
-       BiomeParams *bparams;
-
-       MapgenParams() :
-               mgtype(MAPGEN_DEFAULT),
-               chunksize(5),
-               seed(0),
-               water_level(1),
-               flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS),
-               bparams(NULL)
-       {
-       }
-
+       MapgenParams() {}
        virtual ~MapgenParams();
 
+       MapgenType mgtype = MAPGEN_DEFAULT;
+       s16 chunksize = 5;
+       u64 seed = 0;
+       s16 water_level = 1;
+       s16 mapgen_limit = MAX_MAP_GENERATION_LIMIT;
+       u32 flags = MG_CAVES | MG_LIGHT | MG_DECORATIONS;
+
+       BiomeParams *bparams = nullptr;
+
+       s16 mapgen_edge_min = -MAX_MAP_GENERATION_LIMIT;
+       s16 mapgen_edge_max = MAX_MAP_GENERATION_LIMIT;
+
        virtual void readParams(const Settings *settings);
        virtual void writeParams(Settings *settings) const;
+
+       bool saoPosOverLimit(const v3f &p);
+       s32 getSpawnRangeMax();
+
+private:
+       void calcMapgenEdges();
+
+       float m_sao_limit_min = -MAX_MAP_GENERATION_LIMIT * BS;
+       float m_sao_limit_max = MAX_MAP_GENERATION_LIMIT * BS;
+       bool m_mapgen_edges_calculated = false;
 };
 
 
@@ -156,26 +163,28 @@ struct MapgenParams {
 */
 class Mapgen {
 public:
-       s32 seed;
-       int water_level;
-       u32 flags;
-       bool generating;
-       int id;
+       s32 seed = 0;
+       int water_level = 0;
+       int mapgen_limit = 0;
+       u32 flags = 0;
+       bool generating = false;
+       int id = -1;
 
-       MMVManip *vm;
-       INodeDefManager *ndef;
+       MMVManip *vm = nullptr;
+       INodeDefManager *ndef = nullptr;
 
        u32 blockseed;
-       s16 *heightmap;
-       biome_t *biomemap;
+       s16 *heightmap = nullptr;
+       biome_t *biomemap = nullptr;
        v3s16 csize;
 
-       BiomeGen *biomegen;
+       BiomeGen *biomegen = nullptr;
        GenerateNotifier gennotify;
 
        Mapgen();
        Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
        virtual ~Mapgen();
+       DISABLE_CLASS_COPY(Mapgen);
 
        virtual MapgenType getType() const { return MAPGEN_INVALID; }
 
@@ -217,7 +226,6 @@ class Mapgen {
        // that checks whether there are floodable nodes without liquid beneath
        // the node at index vi.
        inline bool isLiquidHorizontallyFlowable(u32 vi, v3s16 em);
-       DISABLE_CLASS_COPY(Mapgen);
 };
 
 /*
@@ -240,6 +248,7 @@ class MapgenBasic : public Mapgen {
        virtual ~MapgenBasic();
 
        virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth);
+       virtual bool generateCaverns(s16 max_stone_y);
        virtual void generateDungeons(s16 max_stone_y, MgStoneType stone_type);
        virtual MgStoneType generateBiomes();
        virtual void dustTopNodes();
@@ -257,17 +266,19 @@ class MapgenBasic : public Mapgen {
 
        // Content required for generateBiomes
        content_t c_stone;
-       content_t c_water_source;
-       content_t c_river_water_source;
        content_t c_desert_stone;
        content_t c_sandstone;
+       content_t c_water_source;
+       content_t c_river_water_source;
+       content_t c_lava_source;
 
        // Content required for generateDungeons
        content_t c_cobble;
        content_t c_stair_cobble;
        content_t c_mossycobble;
+       content_t c_stair_desert_stone;
        content_t c_sandstonebrick;
-       content_t c_stair_sandstonebrick;
+       content_t c_stair_sandstone_block;
 
        int ystride;
        int zstride;
@@ -278,7 +289,12 @@ class MapgenBasic : public Mapgen {
 
        NoiseParams np_cave1;
        NoiseParams np_cave2;
+       NoiseParams np_cavern;
        float cave_width;
+       float cavern_limit;
+       float cavern_taper;
+       float cavern_threshold;
+       int lava_depth;
 };
 
 #endif