Cavegen: Rename CaveV6 to CavesV6
[oweals/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 DEFAULT_LAVA_DEPTH (-256)
25
26 class MapgenV6;
27
28 class CavesRandomWalk {
29 public:
30         Mapgen *mg;
31         MMVManip *vm;
32         INodeDefManager *ndef;
33
34         // variables
35         int lava_depth;
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         int ystride;
68
69         CavesRandomWalk(Mapgen *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 /*
76         CavesV6 is the original version of caves used with Mapgen V6.
77
78         Though it uses the same fundamental algorithm as CavesRandomWalk, it is made
79         separate to preserve the exact sequence of PseudoRandom calls - any change
80         to this ordering results in the output being radically different.
81         Because caves in Mapgen V6 are responsible for a large portion of the basic
82         terrain shape, modifying this will break our contract of reverse
83         compatibility for a 'stable' mapgen such as V6.
84
85         tl;dr,
86         *** DO NOT TOUCH THIS CLASS UNLESS YOU KNOW WHAT YOU ARE DOING ***
87 */
88 class CavesV6 {
89 public:
90         MapgenV6 *mg;
91         MMVManip *vm;
92         INodeDefManager *ndef;
93
94         s16 min_tunnel_diameter;
95         s16 max_tunnel_diameter;
96         u16 tunnel_routepoints;
97         int dswitchint;
98         int part_max_length_rs;
99
100         bool large_cave;
101         bool large_cave_is_flat;
102
103         s16 max_stone_y;
104         v3s16 node_min;
105         v3s16 node_max;
106
107         v3f orp;  // starting point, relative to caved space
108         v3s16 of; // absolute coordinates of caved space
109         v3s16 ar; // allowed route area
110         s16 rs;   // tunnel radius size
111         v3f main_direction;
112
113         s16 route_y_min;
114         s16 route_y_max;
115
116         PseudoRandom *ps;
117         PseudoRandom *ps2;
118
119         content_t c_water_source;
120         content_t c_lava_source;
121
122         int water_level;
123
124         CavesV6(MapgenV6 *mg, PseudoRandom *ps, PseudoRandom *ps2, bool large_cave);
125         void makeCave(v3s16 nmin, v3s16 nmax, int max_stone_height);
126         void makeTunnel(bool dirswitch);
127         void carveRoute(v3f vec, float f, bool randomize_xz, bool tunnel_above_ground);
128 };
129
130 #endif