]> git.lizzy.rs Git - dragonfireclient.git/blob - src/mg_ore.h
Add function to get server info.
[dragonfireclient.git] / src / mg_ore.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 MG_ORE_HEADER
21 #define MG_ORE_HEADER
22
23 #include "util/cpp11_container.h"
24 #include "objdef.h"
25 #include "noise.h"
26 #include "nodedef.h"
27
28 class Noise;
29 class Mapgen;
30 class MMVManip;
31
32 /////////////////// Ore generation flags
33
34 #define OREFLAG_ABSHEIGHT     0x01
35 #define OREFLAG_PUFF_CLIFFS   0x02
36 #define OREFLAG_PUFF_ADDITIVE 0x04
37 #define OREFLAG_USE_NOISE     0x08
38
39 #define ORE_RANGE_ACTUAL 1
40 #define ORE_RANGE_MIRROR 2
41
42 enum OreType {
43         ORE_SCATTER,
44         ORE_SHEET,
45         ORE_PUFF,
46         ORE_BLOB,
47         ORE_VEIN,
48 };
49
50 extern FlagDesc flagdesc_ore[];
51
52 class Ore : public ObjDef, public NodeResolver {
53 public:
54         static const bool NEEDS_NOISE = false;
55
56         content_t c_ore;                  // the node to place
57         std::vector<content_t> c_wherein; // the nodes to be placed in
58         u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
59         s16 clust_num_ores; // how many ore nodes are in a chunk
60         s16 clust_size;     // how large (in nodes) a chunk of ore is
61         s16 y_min;
62         s16 y_max;
63         u8 ore_param2;          // to set node-specific attributes
64         u32 flags;          // attributes for this ore
65         float nthresh;      // threshold for noise at which an ore is placed
66         NoiseParams np;     // noise for distribution of clusters (NULL for uniform scattering)
67         Noise *noise;
68         UNORDERED_SET<u8> biomes;
69
70         Ore();
71         virtual ~Ore();
72
73         virtual void resolveNodeNames();
74
75         size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
76         virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
77                 v3s16 nmin, v3s16 nmax, u8 *biomemap) = 0;
78 };
79
80 class OreScatter : public Ore {
81 public:
82         static const bool NEEDS_NOISE = false;
83
84         virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
85                 v3s16 nmin, v3s16 nmax, u8 *biomemap);
86 };
87
88 class OreSheet : public Ore {
89 public:
90         static const bool NEEDS_NOISE = true;
91
92         u16 column_height_min;
93         u16 column_height_max;
94         float column_midpoint_factor;
95
96         virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
97                 v3s16 nmin, v3s16 nmax, u8 *biomemap);
98 };
99
100 class OrePuff : public Ore {
101 public:
102         static const bool NEEDS_NOISE = true;
103
104         NoiseParams np_puff_top;
105         NoiseParams np_puff_bottom;
106         Noise *noise_puff_top;
107         Noise *noise_puff_bottom;
108
109         OrePuff();
110         virtual ~OrePuff();
111
112         virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
113                 v3s16 nmin, v3s16 nmax, u8 *biomemap);
114 };
115
116 class OreBlob : public Ore {
117 public:
118         static const bool NEEDS_NOISE = true;
119
120         virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
121                 v3s16 nmin, v3s16 nmax, u8 *biomemap);
122 };
123
124 class OreVein : public Ore {
125 public:
126         static const bool NEEDS_NOISE = true;
127
128         float random_factor;
129         Noise *noise2;
130
131         OreVein();
132         virtual ~OreVein();
133
134         virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
135                 v3s16 nmin, v3s16 nmax, u8 *biomemap);
136 };
137
138 class OreManager : public ObjDefManager {
139 public:
140         OreManager(IGameDef *gamedef);
141         virtual ~OreManager() {}
142
143         const char *getObjectTitle() const
144         {
145                 return "ore";
146         }
147
148         static Ore *create(OreType type)
149         {
150                 switch (type) {
151                 case ORE_SCATTER:
152                         return new OreScatter;
153                 case ORE_SHEET:
154                         return new OreSheet;
155                 case ORE_PUFF:
156                         return new OrePuff;
157                 case ORE_BLOB:
158                         return new OreBlob;
159                 case ORE_VEIN:
160                         return new OreVein;
161                 default:
162                         return NULL;
163                 }
164         }
165
166         void clear();
167
168         size_t placeAllOres(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
169 };
170
171 #endif