]> git.lizzy.rs Git - minetest.git/blob - src/mapgen_valleys.h
Fix wield item glitch
[minetest.git] / src / mapgen_valleys.h
1 /*
2 Minetest Valleys C
3 Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4 Copyright (C) 2010-2015 paramat, Matt Gregory
5 Copyright (C) 2016 Duane Robertson <duane@duanerobertson.com>
6
7 Based on Valleys Mapgen by Gael de Sailly
8  (https://forum.minetest.net/viewtopic.php?f=9&t=11430)
9 and mapgen_v7 by kwolekr and paramat.
10
11 Licensing changed by permission of Gael de Sailly.
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 GNU Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public License along
24 with this program; if not, write to the Free Software Foundation, Inc.,
25 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27
28 #ifndef MAPGEN_VALLEYS_HEADER
29 #define MAPGEN_VALLEYS_HEADER
30
31 #include "mapgen.h"
32
33 /////////////////// Mapgen Valleys flags
34 #define  MG_VALLEYS_ALT_CHILL     0x01
35 #define  MG_VALLEYS_CLIFFS        0x02
36 #define  MG_VALLEYS_FAST          0x04
37 #define  MG_VALLEYS_HUMID_RIVERS  0x08
38 #define  MG_VALLEYS_RUGGED        0x10
39
40 class BiomeManager;
41
42 // Global profiler
43 //class Profiler;
44 //extern Profiler *mapgen_profiler;
45
46
47 struct MapgenValleysParams : public MapgenSpecificParams {
48         u32 spflags;
49
50         u16 altitude_chill;
51         s16 cave_water_max_height;
52         s16 humidity;
53         s16 humidity_break_point;
54         s16 lava_max_height;
55         u16 river_depth;
56         u16 river_size;
57         s16 temperature;
58         u16 water_features;
59
60         NoiseParams np_biome_heat;
61         NoiseParams np_biome_heat_blend;
62         NoiseParams np_biome_humidity;
63         NoiseParams np_biome_humidity_blend;
64         NoiseParams np_cliffs;
65         NoiseParams np_corr;
66         NoiseParams np_filler_depth;
67         NoiseParams np_inter_valley_fill;
68         NoiseParams np_inter_valley_slope;
69         NoiseParams np_rivers;
70         NoiseParams np_simple_caves_1;
71         NoiseParams np_simple_caves_2;
72         NoiseParams np_terrain_height;
73         NoiseParams np_valley_depth;
74         NoiseParams np_valley_profile;
75
76         MapgenValleysParams();
77         ~MapgenValleysParams() {}
78
79         void readParams(const Settings *settings);
80         void writeParams(Settings *settings) const;
81 };
82
83 struct TerrainNoise {
84         s16 x;
85         s16 z;
86         float terrain_height;
87         float *rivers;
88         float *valley;
89         float valley_profile;
90         float *slope;
91         float inter_valley_fill;
92         float cliffs;
93         float corr;
94 };
95
96 class MapgenValleys : public Mapgen {
97 public:
98
99         MapgenValleys(int mapgenid, MapgenParams *params, EmergeManager *emerge);
100         ~MapgenValleys();
101
102         virtual void makeChunk(BlockMakeData *data);
103         int getGroundLevelAtPoint(v2s16 p);
104
105 private:
106         EmergeManager *m_emerge;
107         BiomeManager *bmgr;
108
109         int ystride;
110         int zstride;
111
112         u32 spflags;
113         bool cliff_terrain;
114         bool fast_terrain;
115         bool rugged_terrain;
116         bool humid_rivers;
117         bool use_altitude_chill;
118
119         v3s16 node_min;
120         v3s16 node_max;
121         v3s16 full_node_min;
122         v3s16 full_node_max;
123
124         Noise *noise_filler_depth;
125
126         Noise *noise_cliffs;
127         Noise *noise_corr;
128         Noise *noise_heat;
129         Noise *noise_heat_blend;
130         Noise *noise_humidity;
131         Noise *noise_humidity_blend;
132         Noise *noise_inter_valley_fill;
133         Noise *noise_inter_valley_slope;
134         Noise *noise_rivers;
135         Noise *noise_simple_caves_1;
136         Noise *noise_simple_caves_2;
137         Noise *noise_terrain_height;
138         Noise *noise_valley_depth;
139         Noise *noise_valley_profile;
140
141         float altitude_chill;
142         float cave_water_max_height;
143         float humidity_adjust;
144         float humidity_break_point;
145         float lava_max_height;
146         float river_depth;
147         float river_size;
148         float temperature_adjust;
149         s16 water_features;
150
151         content_t c_cobble;
152         content_t c_desert_stone;
153         content_t c_dirt;
154         content_t c_ice;
155         content_t c_lava_source;
156         content_t c_mossycobble;
157         content_t c_river_water_source;
158         content_t c_sand;
159         content_t c_sandstone;
160         content_t c_sandstonebrick;
161         content_t c_stair_cobble;
162         content_t c_stair_sandstonebrick;
163         content_t c_stone;
164         content_t c_water_source;
165
166         float terrainLevelAtPoint(s16 x, s16 z);
167
168         void calculateNoise();
169
170         virtual int generateTerrain();
171         float terrainLevelFromNoise(TerrainNoise *tn);
172         float adjustedTerrainLevelFromNoise(TerrainNoise *tn);
173
174         float humidityByTerrain(float humidity_base, float mount, float rivers, float valley);
175
176         MgStoneType generateBiomes(float *heat_map, float *humidity_map);
177         void dustTopNodes();
178
179         void generateSimpleCaves(s16 max_stone_y);
180 };
181
182 struct MapgenFactoryValleys : public MapgenFactory {
183         Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge)
184         {
185                 return new MapgenValleys(mgid, params, emerge);
186         };
187
188         MapgenSpecificParams *createMapgenParams()
189         {
190                 return new MapgenValleysParams();
191         };
192 };
193
194 #endif