]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mapgen_v6.h
(Re)spawn players within 'mapgen_limit'
[dragonfireclient.git] / src / mapgen_v6.h
1 /*
2 Minetest
3 Copyright (C) 2010-2015 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2013-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5 Copyright (C) 2014-2017 paramat
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 #ifndef MAPGENV6_HEADER
23 #define MAPGENV6_HEADER
24
25 #include "mapgen.h"
26 #include "noise.h"
27
28 #define MGV6_AVERAGE_MUD_AMOUNT 4
29 #define MGV6_DESERT_STONE_BASE -32
30 #define MGV6_ICE_BASE 0
31 #define MGV6_FREQ_HOT 0.4
32 #define MGV6_FREQ_SNOW -0.4
33 #define MGV6_FREQ_TAIGA 0.5
34 #define MGV6_FREQ_JUNGLE 0.5
35
36 //////////// Mapgen V6 flags
37 #define MGV6_JUNGLES    0x01
38 #define MGV6_BIOMEBLEND 0x02
39 #define MGV6_MUDFLOW    0x04
40 #define MGV6_SNOWBIOMES 0x08
41 #define MGV6_FLAT       0x10
42 #define MGV6_TREES      0x20
43
44
45 extern FlagDesc flagdesc_mapgen_v6[];
46
47
48 enum BiomeV6Type
49 {
50         BT_NORMAL,
51         BT_DESERT,
52         BT_JUNGLE,
53         BT_TUNDRA,
54         BT_TAIGA,
55 };
56
57
58 struct MapgenV6Params : public MapgenParams {
59         u32 spflags;
60         float freq_desert;
61         float freq_beach;
62         NoiseParams np_terrain_base;
63         NoiseParams np_terrain_higher;
64         NoiseParams np_steepness;
65         NoiseParams np_height_select;
66         NoiseParams np_mud;
67         NoiseParams np_beach;
68         NoiseParams np_biome;
69         NoiseParams np_cave;
70         NoiseParams np_humidity;
71         NoiseParams np_trees;
72         NoiseParams np_apple_trees;
73
74         MapgenV6Params();
75         ~MapgenV6Params() {}
76
77         void readParams(const Settings *settings);
78         void writeParams(Settings *settings) const;
79 };
80
81
82 class MapgenV6 : public Mapgen {
83 public:
84         EmergeManager *m_emerge;
85
86         int ystride;
87         u32 spflags;
88
89         v3s16 node_min;
90         v3s16 node_max;
91         v3s16 full_node_min;
92         v3s16 full_node_max;
93         v3s16 central_area_size;
94         int volume_nodes;
95
96         Noise *noise_terrain_base;
97         Noise *noise_terrain_higher;
98         Noise *noise_steepness;
99         Noise *noise_height_select;
100         Noise *noise_mud;
101         Noise *noise_beach;
102         Noise *noise_biome;
103         Noise *noise_humidity;
104         NoiseParams *np_cave;
105         NoiseParams *np_humidity;
106         NoiseParams *np_trees;
107         NoiseParams *np_apple_trees;
108         float freq_desert;
109         float freq_beach;
110
111         content_t c_stone;
112         content_t c_dirt;
113         content_t c_dirt_with_grass;
114         content_t c_sand;
115         content_t c_water_source;
116         content_t c_lava_source;
117         content_t c_gravel;
118         content_t c_desert_stone;
119         content_t c_desert_sand;
120         content_t c_dirt_with_snow;
121         content_t c_snow;
122         content_t c_snowblock;
123         content_t c_ice;
124
125         content_t c_cobble;
126         content_t c_mossycobble;
127         content_t c_stair_cobble;
128         content_t c_stair_desert_stone;
129
130         MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge);
131         ~MapgenV6();
132
133         virtual MapgenType getType() const { return MAPGEN_V6; }
134
135         void makeChunk(BlockMakeData *data);
136         int getGroundLevelAtPoint(v2s16 p);
137         int getSpawnLevelAtPoint(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_stone_level(v2s16 p2d);
146         bool block_is_underground(u64 seed, v3s16 blockpos);
147         s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
148
149         float getHumidity(v2s16 p);
150         float getTreeAmount(v2s16 p);
151         bool getHaveAppleTree(v2s16 p);
152         float getMudAmount(v2s16 p);
153         virtual float getMudAmount(int index);
154         bool getHaveBeach(v2s16 p);
155         bool getHaveBeach(int index);
156         BiomeV6Type getBiome(v2s16 p);
157         BiomeV6Type getBiome(int index, v2s16 p);
158
159         u32 get_blockseed(u64 seed, v3s16 p);
160
161         virtual void calculateNoise();
162         int generateGround();
163         void addMud();
164         void flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos);
165         void growGrass();
166         void placeTreesAndJungleGrass();
167         virtual void generateCaves(int max_stone_y);
168 };
169
170 #endif