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_extrabloated.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
39 /////////////////// Ore generation flags
40 // Use absolute value of height to determine ore placement
41 #define OREFLAG_ABSHEIGHT 0x01
42 // Use 3d noise to get density of ore placement, instead of just the position
43 #define OREFLAG_DENSITY 0x02 // not yet implemented
44 // For claylike ore types, place ore if the number of surrounding
45 // nodes isn't the specified node
46 #define OREFLAG_NODEISNT 0x04 // not yet implemented
48 /////////////////// Decoration flags
49 #define DECO_PLACE_CENTER_X 1
50 #define DECO_PLACE_CENTER_Y 2
51 #define DECO_PLACE_CENTER_Z 4
53 extern FlagDesc flagdesc_mapgen[];
54 extern FlagDesc flagdesc_ore[];
55 extern FlagDesc flagdesc_deco_schematic[];
57 class BiomeDefManager;
61 class ManualMapVoxelManipulator;
62 class VoxelManipulator;
63 class INodeDefManager;
80 flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
83 virtual bool readParams(Settings *settings) = 0;
84 virtual void writeParams(Settings *settings) = 0;
85 virtual ~MapgenParams() {}
94 ManualMapVoxelManipulator *vm;
95 INodeDefManager *ndef;
102 s16 findGroundLevelFull(v2s16 p2d);
103 s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
104 void updateHeightmap(v3s16 nmin, v3s16 nmax);
105 void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
106 void setLighting(v3s16 nmin, v3s16 nmax, u8 light);
107 void lightSpread(VoxelArea &a, v3s16 p, u8 light);
108 void calcLighting(v3s16 nmin, v3s16 nmax);
109 void calcLightingOld(v3s16 nmin, v3s16 nmax);
111 virtual void makeChunk(BlockMakeData *data) {};
112 virtual int getGroundLevelAtPoint(v2s16 p) = 0;
114 //Legacy functions for Farmesh (pending removal)
115 static bool get_have_beach(u64 seed, v2s16 p2d);
116 static double tree_amount_2d(u64 seed, v2s16 p);
117 static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
120 struct MapgenFactory {
121 virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
122 EmergeManager *emerge) = 0;
123 virtual MapgenParams *createMapgenParams() = 0;
124 virtual ~MapgenFactory() {}
133 #define ORE_RANGE_ACTUAL 1
134 #define ORE_RANGE_MIRROR 2
138 std::string ore_name;
139 std::string wherein_name;
141 content_t wherein; // the node to be replaced
142 u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
143 s16 clust_num_ores; // how many ore nodes are in a chunk
144 s16 clust_size; // how large (in nodes) a chunk of ore is
147 u8 ore_param2; // to set node-specific attributes
148 u32 flags; // attributes for this ore
149 float nthresh; // threshhold for noise at which an ore is placed
150 NoiseParams *np; // noise for distribution of clusters (NULL for uniform scattering)
154 ore = CONTENT_IGNORE;
155 wherein = CONTENT_IGNORE;
162 void resolveNodeNames(INodeDefManager *ndef);
163 void placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
164 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
165 u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
168 class OreScatter : public Ore {
170 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
171 u32 blockseed, v3s16 nmin, v3s16 nmax);
174 class OreSheet : public Ore {
176 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
177 u32 blockseed, v3s16 nmin, v3s16 nmax);
180 Ore *createOre(OreType type);
183 enum DecorationType {
197 CutoffData(s16 x, s16 y, s16 z, s16 h) {
207 std::string place_on_name;
208 content_t c_place_on;
214 //std::list<CutoffData> cutoffs;
215 //JMutex cutoff_mutex;
218 virtual ~Decoration();
220 virtual void resolveNodeNames(INodeDefManager *ndef);
221 void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
222 void placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
224 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
225 virtual int getHeight() = 0;
226 virtual std::string getName() = 0;
229 class DecoSimple : public Decoration {
231 std::string deco_name;
232 std::string spawnby_name;
239 std::vector<std::string> decolist_names;
240 std::vector<content_t> c_decolist;
244 void resolveNodeNames(INodeDefManager *ndef);
245 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
246 virtual int getHeight();
247 virtual std::string getName();
250 class DecoSchematic : public Decoration {
252 std::string filename;
254 std::vector<std::string> *node_names;
255 std::vector<content_t> c_nodes;
264 void resolveNodeNames(INodeDefManager *ndef);
265 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
266 virtual int getHeight();
267 virtual std::string getName();
269 bool loadSchematicFile();
270 void saveSchematicFile(INodeDefManager *ndef);
272 bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
273 void placeStructure(Map *map, v3s16 p);
274 void applyProbabilities(std::vector<std::pair<v3s16, s16> > *plist, v3s16 p0);
277 void build_nnlist_and_update_ids(MapNode *nodes, u32 nodecount,
278 std::vector<content_t> *usednodes);
281 class DecoLSystem : public Decoration {
283 virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
287 Decoration *createDecoration(DecorationType type);