3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
20 #ifndef MAPGENV6_HEADER
21 #define MAPGENV6_HEADER
25 #define AVERAGE_MUD_AMOUNT 4
26 #define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
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;
47 s16 min_tunnel_diameter;
48 s16 max_tunnel_diameter;
50 u16 tunnel_routepoints;
51 int part_max_length_rs;
52 bool large_cave_is_flat;
56 struct MapgenV6Params : public MapgenParams {
59 NoiseParams *np_terrain_base;
60 NoiseParams *np_terrain_higher;
61 NoiseParams *np_steepness;
62 NoiseParams *np_height_select;
64 NoiseParams *np_beach;
65 NoiseParams *np_biome;
67 NoiseParams *np_humidity;
68 NoiseParams *np_trees;
69 NoiseParams *np_apple_trees;
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;
88 bool readParams(Settings *settings);
89 void writeParams(Settings *settings);
92 class MapgenV6 : public Mapgen {
94 EmergeManager *emerge;
105 v3s16 central_area_size;
108 Noise *noise_terrain_base;
109 Noise *noise_terrain_higher;
110 Noise *noise_steepness;
111 Noise *noise_height_select;
115 NoiseParams *np_cave;
116 NoiseParams *np_humidity;
117 NoiseParams *np_trees;
118 NoiseParams *np_apple_trees;
124 content_t c_dirt_with_grass;
126 content_t c_water_source;
127 content_t c_lava_source;
130 content_t c_desert_sand;
131 content_t c_desert_stone;
133 MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge);
136 void makeChunk(BlockMakeData *data);
137 int getGroundLevelAtPoint(v2s16 p);
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);
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);
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);
160 u32 get_blockseed(u64 seed, v3s16 p);
162 virtual void calculateNoise();
163 int generateGround();
165 void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
166 void addDirtGravelBlobs();
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
175 struct MapgenFactoryV6 : public MapgenFactory {
176 Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
177 return new MapgenV6(mgid, (MapgenV6Params *)params, emerge);
180 MapgenParams *createMapgenParams() {
181 return new MapgenV6Params();