]> git.lizzy.rs Git - minetest.git/blob - src/mapgen_v6.h
Works for debian and a few other distributions but fails for even more so back to...
[minetest.git] / src / mapgen_v6.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 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
25 #define AVERAGE_MUD_AMOUNT 4
26
27 /////////////////// Mapgen V6 flags
28 #define MGV6_JUNGLES    0x01
29 #define MGV6_BIOMEBLEND 0x02
30 #define MGV6_MUDFLOW    0x04
31
32
33 extern FlagDesc flagdesc_mapgen_v6[];
34
35
36 enum BiomeType
37 {
38         BT_NORMAL,
39         BT_DESERT
40 };
41
42 struct MapgenV6Params : public MapgenSpecificParams {
43         u32 spflags;
44         float freq_desert;
45         float freq_beach;
46         NoiseParams np_terrain_base;
47         NoiseParams np_terrain_higher;
48         NoiseParams np_steepness;
49         NoiseParams np_height_select;
50         NoiseParams np_mud;
51         NoiseParams np_beach;
52         NoiseParams np_biome;
53         NoiseParams np_cave;
54         NoiseParams np_humidity;
55         NoiseParams np_trees;
56         NoiseParams np_apple_trees;
57         
58         MapgenV6Params();
59         ~MapgenV6Params() {}
60         
61         void readParams(Settings *settings);
62         void writeParams(Settings *settings);
63 };
64
65 class MapgenV6 : public Mapgen {
66 public:
67         EmergeManager *emerge;
68
69         int ystride;
70         u32 flags;
71         u32 spflags;
72
73         u32 blockseed;
74         v3s16 node_min;
75         v3s16 node_max;
76         v3s16 full_node_min;
77         v3s16 full_node_max;
78         v3s16 central_area_size;
79         int volume_nodes;
80
81         Noise *noise_terrain_base;
82         Noise *noise_terrain_higher;
83         Noise *noise_steepness;
84         Noise *noise_height_select;
85         Noise *noise_mud;
86         Noise *noise_beach;
87         Noise *noise_biome;
88         NoiseParams *np_cave;
89         NoiseParams *np_humidity;
90         NoiseParams *np_trees;
91         NoiseParams *np_apple_trees;
92         float freq_desert;
93         float freq_beach;
94
95         content_t c_stone;
96         content_t c_dirt;
97         content_t c_dirt_with_grass;
98         content_t c_sand;
99         content_t c_water_source;
100         content_t c_lava_source;
101         content_t c_gravel;
102         content_t c_cobble;
103         content_t c_desert_sand;
104         content_t c_desert_stone;
105
106         content_t c_mossycobble;
107         content_t c_sandbrick;
108         content_t c_stair_cobble;
109         content_t c_stair_sandstone;
110
111         MapgenV6(int mapgenid, MapgenParams *params, EmergeManager *emerge);
112         ~MapgenV6();
113         
114         void makeChunk(BlockMakeData *data);
115         int getGroundLevelAtPoint(v2s16 p);
116
117         float baseTerrainLevel(float terrain_base, float terrain_higher,
118                                                    float steepness, float height_select);
119         virtual float baseTerrainLevelFromNoise(v2s16 p);
120         virtual float baseTerrainLevelFromMap(v2s16 p);
121         virtual float baseTerrainLevelFromMap(int index);
122
123         s16 find_stone_level(v2s16 p2d);
124         bool block_is_underground(u64 seed, v3s16 blockpos);
125         s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
126         
127         float getHumidity(v2s16 p);
128         float getTreeAmount(v2s16 p);
129         bool getHaveAppleTree(v2s16 p);
130         float getMudAmount(v2s16 p);
131         virtual float getMudAmount(int index);
132         bool getHaveBeach(v2s16 p);
133         bool getHaveBeach(int index);
134         BiomeType getBiome(v2s16 p);
135         BiomeType getBiome(int index, v2s16 p);
136         
137         u32 get_blockseed(u64 seed, v3s16 p);
138         
139         virtual void calculateNoise();
140         int generateGround();
141         void addMud();
142         void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
143         void addDirtGravelBlobs();
144         void growGrass();
145         void placeTreesAndJungleGrass();
146         virtual void generateCaves(int max_stone_y);
147         virtual void generateExperimental() {}
148 };
149
150 struct MapgenFactoryV6 : public MapgenFactory {
151         Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
152                 return new MapgenV6(mgid, params, emerge);
153         };
154         
155         MapgenSpecificParams *createMapgenParams() {
156                 return new MapgenV6Params();
157         };
158 };
159
160 #endif