]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mapgen/mapgen_v6.h
Dungeons: Add Y limits in all mapgens
[dragonfireclient.git] / src / mapgen / mapgen_v6.h
1 /*
2 Minetest
3 Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2013-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5 Copyright (C) 2014-2018 paramat
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 #pragma once
23
24 #include "mapgen.h"
25 #include "noise.h"
26
27 #define MGV6_AVERAGE_MUD_AMOUNT 4
28 #define MGV6_DESERT_STONE_BASE -32
29 #define MGV6_ICE_BASE 0
30 #define MGV6_FREQ_HOT 0.4
31 #define MGV6_FREQ_SNOW -0.4
32 #define MGV6_FREQ_TAIGA 0.5
33 #define MGV6_FREQ_JUNGLE 0.5
34
35 //////////// Mapgen V6 flags
36 #define MGV6_JUNGLES    0x01
37 #define MGV6_BIOMEBLEND 0x02
38 #define MGV6_MUDFLOW    0x04
39 #define MGV6_SNOWBIOMES 0x08
40 #define MGV6_FLAT       0x10
41 #define MGV6_TREES      0x20
42
43
44 extern FlagDesc flagdesc_mapgen_v6[];
45
46
47 enum BiomeV6Type
48 {
49         BT_NORMAL,
50         BT_DESERT,
51         BT_JUNGLE,
52         BT_TUNDRA,
53         BT_TAIGA,
54 };
55
56
57 struct MapgenV6Params : public MapgenParams {
58         u32 spflags = MGV6_JUNGLES | MGV6_SNOWBIOMES | MGV6_TREES |
59                 MGV6_BIOMEBLEND | MGV6_MUDFLOW;
60         float freq_desert = 0.45f;
61         float freq_beach = 0.15f;
62         s16 dungeon_ymin = -31000;
63         s16 dungeon_ymax = 31000;
64
65         NoiseParams np_terrain_base;
66         NoiseParams np_terrain_higher;
67         NoiseParams np_steepness;
68         NoiseParams np_height_select;
69         NoiseParams np_mud;
70         NoiseParams np_beach;
71         NoiseParams np_biome;
72         NoiseParams np_cave;
73         NoiseParams np_humidity;
74         NoiseParams np_trees;
75         NoiseParams np_apple_trees;
76
77         MapgenV6Params();
78         ~MapgenV6Params() = default;
79
80         void readParams(const Settings *settings);
81         void writeParams(Settings *settings) const;
82 };
83
84
85 class MapgenV6 : public Mapgen {
86 public:
87         EmergeManager *m_emerge;
88
89         int ystride;
90         u32 spflags;
91
92         v3s16 node_min;
93         v3s16 node_max;
94         v3s16 full_node_min;
95         v3s16 full_node_max;
96         v3s16 central_area_size;
97
98         Noise *noise_terrain_base;
99         Noise *noise_terrain_higher;
100         Noise *noise_steepness;
101         Noise *noise_height_select;
102         Noise *noise_mud;
103         Noise *noise_beach;
104         Noise *noise_biome;
105         Noise *noise_humidity;
106         NoiseParams *np_cave;
107         NoiseParams *np_humidity;
108         NoiseParams *np_trees;
109         NoiseParams *np_apple_trees;
110
111         float freq_desert;
112         float freq_beach;
113         s16 dungeon_ymin;
114         s16 dungeon_ymax;
115
116         content_t c_stone;
117         content_t c_dirt;
118         content_t c_dirt_with_grass;
119         content_t c_sand;
120         content_t c_water_source;
121         content_t c_lava_source;
122         content_t c_gravel;
123         content_t c_desert_stone;
124         content_t c_desert_sand;
125         content_t c_dirt_with_snow;
126         content_t c_snow;
127         content_t c_snowblock;
128         content_t c_ice;
129
130         content_t c_cobble;
131         content_t c_mossycobble;
132         content_t c_stair_cobble;
133         content_t c_stair_desert_stone;
134
135         MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge);
136         ~MapgenV6();
137
138         virtual MapgenType getType() const { return MAPGEN_V6; }
139
140         void makeChunk(BlockMakeData *data);
141         int getGroundLevelAtPoint(v2s16 p);
142         int getSpawnLevelAtPoint(v2s16 p);
143
144         float baseTerrainLevel(float terrain_base, float terrain_higher,
145                 float steepness, float height_select);
146         virtual float baseTerrainLevelFromNoise(v2s16 p);
147         virtual float baseTerrainLevelFromMap(v2s16 p);
148         virtual float baseTerrainLevelFromMap(int index);
149
150         s16 find_stone_level(v2s16 p2d);
151         bool block_is_underground(u64 seed, v3s16 blockpos);
152         s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
153
154         float getHumidity(v2s16 p);
155         float getTreeAmount(v2s16 p);
156         bool getHaveAppleTree(v2s16 p);
157         float getMudAmount(v2s16 p);
158         virtual float getMudAmount(int index);
159         bool getHaveBeach(v2s16 p);
160         bool getHaveBeach(int index);
161         BiomeV6Type getBiome(v2s16 p);
162         BiomeV6Type getBiome(int index, v2s16 p);
163
164         u32 get_blockseed(u64 seed, v3s16 p);
165
166         virtual void calculateNoise();
167         int generateGround();
168         void addMud();
169         void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
170         void moveMud(u32 remove_index, u32 place_index,
171                 u32 above_remove_index, v2s16 pos, v3s16 em);
172         void growGrass();
173         void placeTreesAndJungleGrass();
174         virtual void generateCaves(int max_stone_y);
175 };