]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mapgen_v6.h
Merge pull request #505 from RealBadAngel/master
[dragonfireclient.git] / src / mapgen_v6.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 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
27 enum BiomeType
28 {
29         BT_NORMAL,
30         BT_DESERT
31 };
32
33 extern NoiseParams nparams_v6_def_terrain_base;
34 extern NoiseParams nparams_v6_def_terrain_higher;
35 extern NoiseParams nparams_v6_def_steepness;
36 extern NoiseParams nparams_v6_def_height_select;
37 extern NoiseParams nparams_v6_def_trees;
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
43 struct MapgenV6Params : public MapgenParams {
44         float freq_desert;
45         float freq_beach;
46         NoiseParams *np_terrain_base;
47         NoiseParams *np_terrain_higher;
48         NoiseParams *np_steepness;
49         NoiseParams *np_height_select;
50         NoiseParams *np_trees;
51         NoiseParams *np_mud;
52         NoiseParams *np_beach;
53         NoiseParams *np_biome;
54         NoiseParams *np_cave;
55
56         MapgenV6Params() {
57                 freq_desert       = 0.45;
58                 freq_beach        = 0.15;
59                 np_terrain_base   = &nparams_v6_def_terrain_base;
60                 np_terrain_higher = &nparams_v6_def_terrain_higher;
61                 np_steepness      = &nparams_v6_def_steepness;
62                 np_height_select  = &nparams_v6_def_height_select;
63                 np_trees          = &nparams_v6_def_trees;
64                 np_mud            = &nparams_v6_def_mud;
65                 np_beach          = &nparams_v6_def_beach;
66                 np_biome          = &nparams_v6_def_biome;
67                 np_cave           = &nparams_v6_def_cave;
68         }
69         
70         bool readParams(Settings *settings);
71         void writeParams(Settings *settings);
72 };
73
74 class MapgenV6 : public Mapgen {
75 public:
76         //ManualMapVoxelManipulator &vmanip;
77
78         int ystride;
79         v3s16 csize;
80
81         v3s16 node_min;
82         v3s16 node_max;
83
84         Noise *noise_terrain_base;
85         Noise *noise_terrain_higher;
86         Noise *noise_steepness;
87         Noise *noise_height_select;
88         Noise *noise_trees;
89         Noise *noise_mud;
90         Noise *noise_beach;
91         Noise *noise_biome;
92
93         float *map_terrain_base;
94         float *map_terrain_higher;
95         float *map_steepness;
96         float *map_height_select;
97         float *map_trees;
98         float *map_mud;
99         float *map_beach;
100         float *map_biome;
101
102         NoiseParams *np_cave;
103
104         u32 flags;
105         float freq_desert;
106         float freq_beach;
107
108         MapgenV6(int mapgenid, MapgenV6Params *params);
109         ~MapgenV6();
110         
111         void makeChunk(BlockMakeData *data);
112         int getGroundLevelAtPoint(v2s16 p);
113
114         double baseRockLevelFromNoise(v2s16 p);
115         static s16 find_ground_level(VoxelManipulator &vmanip,
116                                                                  v2s16 p2d, INodeDefManager *ndef);
117         static s16 find_stone_level(VoxelManipulator &vmanip,
118                                                                  v2s16 p2d, INodeDefManager *ndef);
119         void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
120                                          bool is_apple_tree, INodeDefManager *ndef);
121         double tree_amount_2d(u64 seed, v2s16 p);
122         bool block_is_underground(u64 seed, v3s16 blockpos);
123         double base_rock_level_2d(u64 seed, v2s16 p);
124         s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
125         double get_mud_add_amount(u64 seed, v2s16 p);
126         bool get_have_beach(u64 seed, v2s16 p2d);
127         BiomeType get_biome(u64 seed, v2s16 p2d);
128         u32 get_blockseed(u64 seed, v3s16 p);
129 };
130
131 struct MapgenFactoryV6 : public MapgenFactory {
132         Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
133                 return new MapgenV6(mgid, (MapgenV6Params *)params);
134         };
135         
136         MapgenParams *createMapgenParams() {
137                 return new MapgenV6Params();
138         };
139 };
140
141 #endif