]> git.lizzy.rs Git - minetest.git/blob - src/cavegen.h
Fix segfaults caused by the Environment not being initialized yet
[minetest.git] / src / cavegen.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
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 CAVEGEN_HEADER
21 #define CAVEGEN_HEADER
22
23 #define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
24 #define MGV7_LAVA_DEPTH -256
25
26 class MapgenV5;
27 class MapgenV6;
28 class MapgenV7;
29
30 class CaveV5 {
31 public:
32         MapgenV5 *mg;
33         MMVManip *vm;
34         INodeDefManager *ndef;
35
36         NoiseParams *np_caveliquids;
37
38         s16 min_tunnel_diameter;
39         s16 max_tunnel_diameter;
40         u16 tunnel_routepoints;
41         int dswitchint;
42         int part_max_length_rs;
43
44         bool large_cave_is_flat;
45         bool flooded;
46
47         s16 max_stone_y;
48         v3s16 node_min;
49         v3s16 node_max;
50
51         v3f orp;  // starting point, relative to caved space
52         v3s16 of; // absolute coordinates of caved space
53         v3s16 ar; // allowed route area
54         s16 rs;   // tunnel radius size
55         v3f main_direction;
56
57         s16 route_y_min;
58         s16 route_y_max;
59
60         PseudoRandom *ps;
61
62         content_t c_water_source;
63         content_t c_lava_source;
64         content_t c_ice;
65
66         int water_level;
67
68         CaveV5() {}
69         CaveV5(MapgenV5 *mg, PseudoRandom *ps);
70         void makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height);
71         void makeTunnel(bool dirswitch);
72         void carveRoute(v3f vec, float f, bool randomize_xz);
73 };
74
75 class CaveV6 {
76 public:
77         MapgenV6 *mg;
78         MMVManip *vm;
79         INodeDefManager *ndef;
80
81         s16 min_tunnel_diameter;
82         s16 max_tunnel_diameter;
83         u16 tunnel_routepoints;
84         int dswitchint;
85         int part_max_length_rs;
86
87         bool large_cave;
88         bool large_cave_is_flat;
89         bool flooded;
90
91         s16 max_stone_y;
92         v3s16 node_min;
93         v3s16 node_max;
94
95         v3f orp;  // starting point, relative to caved space
96         v3s16 of; // absolute coordinates of caved space
97         v3s16 ar; // allowed route area
98         s16 rs;   // tunnel radius size
99         v3f main_direction;
100
101         s16 route_y_min;
102         s16 route_y_max;
103
104         PseudoRandom *ps;
105         PseudoRandom *ps2;
106
107         content_t c_water_source;
108         content_t c_lava_source;
109
110         int water_level;
111
112         CaveV6() {}
113         CaveV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool large_cave);
114         void makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height);
115         void makeTunnel(bool dirswitch);
116         void carveRoute(v3f vec, float f, bool randomize_xz, bool tunnel_above_ground);
117 };
118
119 class CaveV7 {
120 public:
121         MapgenV7 *mg;
122         MMVManip *vm;
123         INodeDefManager *ndef;
124
125         NoiseParams *np_caveliquids;
126
127         s16 min_tunnel_diameter;
128         s16 max_tunnel_diameter;
129         u16 tunnel_routepoints;
130         int dswitchint;
131         int part_max_length_rs;
132
133         bool large_cave_is_flat;
134         bool flooded;
135
136         s16 max_stone_y;
137         v3s16 node_min;
138         v3s16 node_max;
139
140         v3f orp;  // starting point, relative to caved space
141         v3s16 of; // absolute coordinates of caved space
142         v3s16 ar; // allowed route area
143         s16 rs;   // tunnel radius size
144         v3f main_direction;
145
146         s16 route_y_min;
147         s16 route_y_max;
148
149         PseudoRandom *ps;
150
151         content_t c_water_source;
152         content_t c_lava_source;
153         content_t c_ice;
154
155         int water_level;
156
157         CaveV7() {}
158         CaveV7(MapgenV7 *mg, PseudoRandom *ps);
159         void makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height);
160         void makeTunnel(bool dirswitch);
161         void carveRoute(v3f vec, float f, bool randomize_xz);
162 };
163
164 #endif