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