]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mapgen_v6.h
Split HUD code off to hud.cpp, make into a class, extensive Lua HUD modification
[dragonfireclient.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 #define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
27
28 enum BiomeType
29 {
30         BT_NORMAL,
31         BT_DESERT
32 };
33
34 extern NoiseParams nparams_v6_def_terrain_base;
35 extern NoiseParams nparams_v6_def_terrain_higher;
36 extern NoiseParams nparams_v6_def_steepness;
37 extern NoiseParams nparams_v6_def_height_select;
38 extern NoiseParams nparams_v6_def_mud;
39 extern NoiseParams nparams_v6_def_beach;
40 extern NoiseParams nparams_v6_def_biome;
41 extern NoiseParams nparams_v6_def_cave;
42 extern NoiseParams nparams_v6_def_humidity;
43 extern NoiseParams nparams_v6_def_trees;
44 extern NoiseParams nparams_v6_def_apple_trees;
45
46 struct Cave {
47         s16 min_tunnel_diameter;
48         s16 max_tunnel_diameter;
49         int dswitchint;
50         u16 tunnel_routepoints;
51         int part_max_length_rs;
52         bool large_cave_is_flat;
53         bool flooded;
54 };
55
56 struct MapgenV6Params : public MapgenParams {
57         float freq_desert;
58         float freq_beach;
59         NoiseParams *np_terrain_base;
60         NoiseParams *np_terrain_higher;
61         NoiseParams *np_steepness;
62         NoiseParams *np_height_select;
63         NoiseParams *np_mud;
64         NoiseParams *np_beach;
65         NoiseParams *np_biome;
66         NoiseParams *np_cave;
67         NoiseParams *np_humidity;
68         NoiseParams *np_trees;
69         NoiseParams *np_apple_trees;
70         
71         MapgenV6Params() {
72                 freq_desert       = 0.45;
73                 freq_beach        = 0.15;
74                 np_terrain_base   = &nparams_v6_def_terrain_base;
75                 np_terrain_higher = &nparams_v6_def_terrain_higher;
76                 np_steepness      = &nparams_v6_def_steepness;
77                 np_height_select  = &nparams_v6_def_height_select;
78                 np_mud            = &nparams_v6_def_mud;
79                 np_beach          = &nparams_v6_def_beach;
80                 np_biome          = &nparams_v6_def_biome;
81                 np_cave           = &nparams_v6_def_cave;
82                 np_humidity       = &nparams_v6_def_humidity;
83                 np_trees          = &nparams_v6_def_trees;
84                 np_apple_trees    = &nparams_v6_def_apple_trees;
85
86         }
87         
88         bool readParams(Settings *settings);
89         void writeParams(Settings *settings);
90 };
91
92 class MapgenV6 : public Mapgen {
93 public:
94         EmergeManager *emerge;
95
96         int ystride;
97         v3s16 csize;
98         u32 flags;
99
100         u32 blockseed;
101         v3s16 node_min;
102         v3s16 node_max;
103         v3s16 full_node_min;
104         v3s16 full_node_max;
105         v3s16 central_area_size;
106         int volume_nodes;
107
108         Noise *noise_terrain_base;
109         Noise *noise_terrain_higher;
110         Noise *noise_steepness;
111         Noise *noise_height_select;
112         Noise *noise_mud;
113         Noise *noise_beach;
114         Noise *noise_biome;
115         NoiseParams *np_cave;
116         NoiseParams *np_humidity;
117         NoiseParams *np_trees;
118         NoiseParams *np_apple_trees;
119         float freq_desert;
120         float freq_beach;
121         
122         content_t c_stone;
123         content_t c_dirt;
124         content_t c_dirt_with_grass;
125         content_t c_sand;
126         content_t c_water_source;
127         content_t c_lava_source;
128         content_t c_gravel;
129         content_t c_cobble;
130         content_t c_desert_sand;
131         content_t c_desert_stone;
132
133         MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge);
134         ~MapgenV6();
135         
136         void makeChunk(BlockMakeData *data);
137         int getGroundLevelAtPoint(v2s16 p);
138
139         float baseTerrainLevel(float terrain_base, float terrain_higher,
140                                                    float steepness, float height_select);
141         virtual float baseTerrainLevelFromNoise(v2s16 p);
142         virtual float baseTerrainLevelFromMap(v2s16 p);
143         virtual float baseTerrainLevelFromMap(int index);
144
145         s16 find_ground_level(v2s16 p2d);
146         s16 find_stone_level(v2s16 p2d);
147         bool block_is_underground(u64 seed, v3s16 blockpos);
148         s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
149         
150         float getHumidity(v2s16 p);
151         float getTreeAmount(v2s16 p);
152         bool getHaveAppleTree(v2s16 p);
153         float getMudAmount(v2s16 p);
154         virtual float getMudAmount(int index);
155         bool getHaveBeach(v2s16 p);
156         bool getHaveBeach(int index);
157         BiomeType getBiome(v2s16 p);
158         BiomeType getBiome(int index, v2s16 p);
159         
160         u32 get_blockseed(u64 seed, v3s16 p);
161         
162         virtual void calculateNoise();
163         int generateGround();
164         void addMud();
165         void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
166         void addDirtGravelBlobs();
167         void growGrass();
168         void placeTreesAndJungleGrass();
169         virtual void defineCave(Cave &cave, PseudoRandom ps,
170                                                         v3s16 node_min, bool large_cave);
171         void generateCaves(int max_stone_y);
172         virtual void generateSomething() {}; //for next mapgen
173 };
174
175 struct MapgenFactoryV6 : public MapgenFactory {
176         Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
177                 return new MapgenV6(mgid, (MapgenV6Params *)params, emerge);
178         };
179         
180         MapgenParams *createMapgenParams() {
181                 return new MapgenV6Params();
182         };
183 };
184
185 #endif