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 {
103 v3s16 central_area_size;
106 Noise *noise_terrain_base;
107 Noise *noise_terrain_higher;
108 Noise *noise_steepness;
109 Noise *noise_height_select;
113 NoiseParams *np_cave;
114 NoiseParams *np_humidity;
115 NoiseParams *np_trees;
116 NoiseParams *np_apple_trees;
122 content_t c_dirt_with_grass;
124 content_t c_water_source;
125 content_t c_lava_source;
128 content_t c_desert_sand;
129 content_t c_desert_stone;
131 MapgenV6(int mapgenid, MapgenV6Params *params);
134 void makeChunk(BlockMakeData *data);
135 int getGroundLevelAtPoint(v2s16 p);
137 float baseTerrainLevel(float terrain_base, float terrain_higher,
138 float steepness, float height_select);
139 virtual float baseTerrainLevelFromNoise(v2s16 p);
140 virtual float baseTerrainLevelFromMap(v2s16 p);
141 virtual float baseTerrainLevelFromMap(int index);
143 s16 find_ground_level(v2s16 p2d);
144 s16 find_stone_level(v2s16 p2d);
145 bool block_is_underground(u64 seed, v3s16 blockpos);
146 s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
148 float getHumidity(v2s16 p);
149 float getTreeAmount(v2s16 p);
150 bool getHaveAppleTree(v2s16 p);
151 float getMudAmount(v2s16 p);
152 virtual float getMudAmount(int index);
153 bool getHaveBeach(v2s16 p);
154 bool getHaveBeach(int index);
155 BiomeType getBiome(v2s16 p);
156 BiomeType getBiome(int index, v2s16 p);
158 u32 get_blockseed(u64 seed, v3s16 p);
160 virtual void calculateNoise();
161 int generateGround();
163 void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
164 void addDirtGravelBlobs();
166 void placeTreesAndJungleGrass();
167 virtual void defineCave(Cave &cave, PseudoRandom ps,
168 v3s16 node_min, bool large_cave);
169 void generateCaves(int max_stone_y);
172 struct MapgenFactoryV6 : public MapgenFactory {
173 Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
174 return new MapgenV6(mgid, (MapgenV6Params *)params);
177 MapgenParams *createMapgenParams() {
178 return new MapgenV6Params();