3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
23 #include "irrlichttypes_bloated.h"
24 #include "util/container.h" // UniqueQueue
31 /////////////////// Mapgen flags
34 #define MG_DUNGEONS 0x04
35 #define MGV6_JUNGLES 0x08
36 #define MGV6_BIOME_BLEND 0x10
38 #define MG_NOLIGHT 0x40
39 #define MGV7_MOUNTAINS 0x80
40 #define MGV7_RIDGES 0x100
41 #define MGV6_NOMUDFLOW 0x200
43 /////////////////// Ore generation flags
44 // Use absolute value of height to determine ore placement
45 #define OREFLAG_ABSHEIGHT 0x01
46 // Use 3d noise to get density of ore placement, instead of just the position
47 #define OREFLAG_DENSITY 0x02 // not yet implemented
48 // For claylike ore types, place ore if the number of surrounding
49 // nodes isn't the specified node
50 #define OREFLAG_NODEISNT 0x04 // not yet implemented
52 /////////////////// Decoration flags
53 #define DECO_PLACE_CENTER_X 1
54 #define DECO_PLACE_CENTER_Y 2
55 #define DECO_PLACE_CENTER_Z 4
57 #define ORE_RANGE_ACTUAL 1
58 #define ORE_RANGE_MIRROR 2
60 #define NUM_GEN_NOTIFY 6
63 extern FlagDesc flagdesc_mapgen[];
64 extern FlagDesc flagdesc_ore[];
65 extern FlagDesc flagdesc_deco_schematic[];
66 extern FlagDesc flagdesc_gennotify[];
68 class BiomeDefManager;
72 class ManualMapVoxelManipulator;
73 class VoxelManipulator;
93 GENNOTIFY_LARGECAVE_BEGIN,
94 GENNOTIFY_LARGECAVE_END
104 struct MapgenParams {
116 flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
119 virtual bool readParams(Settings *settings) { return true; }
120 virtual void writeParams(Settings *settings) {}
121 virtual ~MapgenParams() {}
130 ManualMapVoxelManipulator *vm;
131 INodeDefManager *ndef;
138 std::vector<v3s16> *gen_notifications[NUM_GEN_NOTIFY];
143 s16 findGroundLevelFull(v2s16 p2d);
144 s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
145 void updateHeightmap(v3s16 nmin, v3s16 nmax);
146 void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
147 void setLighting(v3s16 nmin, v3s16 nmax, u8 light);
148 void lightSpread(VoxelArea &a, v3s16 p, u8 light);
149 void calcLighting(v3s16 nmin, v3s16 nmax);
150 void calcLightingOld(v3s16 nmin, v3s16 nmax);
152 virtual void makeChunk(BlockMakeData *data) {}
153 virtual int getGroundLevelAtPoint(v2s16 p) { return 0; }
156 struct MapgenFactory {
157 virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
158 EmergeManager *emerge) = 0;
159 virtual MapgenParams *createMapgenParams() = 0;
160 virtual ~MapgenFactory() {}
165 std::string ore_name;
166 std::vector<std::string> wherein_names;
168 std::vector<content_t> wherein; // the node to be replaced
169 u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
170 s16 clust_num_ores; // how many ore nodes are in a chunk
171 s16 clust_size; // how large (in nodes) a chunk of ore is
174 u8 ore_param2; // to set node-specific attributes
175 u32 flags; // attributes for this ore
176 float nthresh; // threshhold for noise at which an ore is placed
177 NoiseParams *np; // noise for distribution of clusters (NULL for uniform scattering)
181 ore = CONTENT_IGNORE;
188 void resolveNodeNames(INodeDefManager *ndef);
189 void placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
190 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
191 u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
194 class OreScatter : public Ore {
196 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
197 u32 blockseed, v3s16 nmin, v3s16 nmax);
200 class OreSheet : public Ore {
202 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
203 u32 blockseed, v3s16 nmin, v3s16 nmax);
206 Ore *createOre(OreType type);
209 enum DecorationType {
223 CutoffData(s16 x, s16 y, s16 z, s16 h) {
232 INodeDefManager *ndef;
235 std::string place_on_name;
236 content_t c_place_on;
242 //std::list<CutoffData> cutoffs;
243 //JMutex cutoff_mutex;
246 virtual ~Decoration();
248 virtual void resolveNodeNames(INodeDefManager *ndef);
249 void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
250 void placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
252 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
253 virtual int getHeight() = 0;
254 virtual std::string getName() = 0;
257 class DecoSimple : public Decoration {
259 std::string deco_name;
260 std::string spawnby_name;
267 std::vector<std::string> decolist_names;
268 std::vector<content_t> c_decolist;
272 void resolveNodeNames(INodeDefManager *ndef);
273 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
274 virtual int getHeight();
275 virtual std::string getName();
278 #define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
279 #define MTSCHEM_FILE_VER_HIGHEST_READ 3
280 #define MTSCHEM_FILE_VER_HIGHEST_WRITE 3
282 #define MTSCHEM_PROB_NEVER 0x00
283 #define MTSCHEM_PROB_ALWAYS 0xFF
285 class DecoSchematic : public Decoration {
287 std::string filename;
289 std::vector<std::string> *node_names;
290 std::vector<content_t> c_nodes;
291 std::map<std::string, std::string> replacements;
302 void resolveNodeNames(INodeDefManager *ndef);
303 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
304 virtual int getHeight();
305 virtual std::string getName();
307 void blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
308 Rotation rot, bool force_placement);
310 bool loadSchematicFile();
311 void saveSchematicFile(INodeDefManager *ndef);
313 bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
314 void placeStructure(Map *map, v3s16 p);
315 void applyProbabilities(v3s16 p0,
316 std::vector<std::pair<v3s16, u8> > *plist,
317 std::vector<std::pair<s16, u8> > *splist);
320 void build_nnlist_and_update_ids(MapNode *nodes, u32 nodecount,
321 std::vector<content_t> *usednodes);
324 class DecoLSystem : public Decoration {
326 virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
330 Decoration *createDecoration(DecorationType type);