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
32 /////////////////// Mapgen flags
35 #define MG_DUNGEONS 0x04
36 #define MGV6_JUNGLES 0x08
37 #define MGV6_BIOME_BLEND 0x10
39 #define MG_NOLIGHT 0x40
40 #define MGV7_MOUNTAINS 0x80
41 #define MGV7_RIDGES 0x100
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 extern FlagDesc flagdesc_mapgen[];
58 extern FlagDesc flagdesc_ore[];
59 extern FlagDesc flagdesc_deco_schematic[];
61 class BiomeDefManager;
65 class ManualMapVoxelManipulator;
66 class VoxelManipulator;
83 flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
86 virtual bool readParams(Settings *settings) { return true; }
87 virtual void writeParams(Settings *settings) {}
88 virtual ~MapgenParams() {}
97 ManualMapVoxelManipulator *vm;
98 INodeDefManager *ndef;
107 s16 findGroundLevelFull(v2s16 p2d);
108 s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
109 void updateHeightmap(v3s16 nmin, v3s16 nmax);
110 void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
111 void setLighting(v3s16 nmin, v3s16 nmax, u8 light);
112 void lightSpread(VoxelArea &a, v3s16 p, u8 light);
113 void calcLighting(v3s16 nmin, v3s16 nmax);
114 void calcLightingOld(v3s16 nmin, v3s16 nmax);
116 virtual void makeChunk(BlockMakeData *data) {}
117 virtual int getGroundLevelAtPoint(v2s16 p) { return 0; }
119 //Legacy functions for Farmesh (pending removal)
120 static bool get_have_beach(u64 seed, v2s16 p2d);
121 static double tree_amount_2d(u64 seed, v2s16 p);
122 static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
125 struct MapgenFactory {
126 virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
127 EmergeManager *emerge) = 0;
128 virtual MapgenParams *createMapgenParams() = 0;
129 virtual ~MapgenFactory() {}
146 #define ORE_RANGE_ACTUAL 1
147 #define ORE_RANGE_MIRROR 2
151 std::string ore_name;
152 std::vector<std::string> wherein_names;
154 std::vector<content_t> wherein; // the node to be replaced
155 u32 clust_scarcity; // ore cluster has a 1-in-clust_scarcity chance of appearing at a node
156 s16 clust_num_ores; // how many ore nodes are in a chunk
157 s16 clust_size; // how large (in nodes) a chunk of ore is
160 u8 ore_param2; // to set node-specific attributes
161 u32 flags; // attributes for this ore
162 float nthresh; // threshhold for noise at which an ore is placed
163 NoiseParams *np; // noise for distribution of clusters (NULL for uniform scattering)
167 ore = CONTENT_IGNORE;
174 void resolveNodeNames(INodeDefManager *ndef);
175 void placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
176 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
177 u32 blockseed, v3s16 nmin, v3s16 nmax) = 0;
180 class OreScatter : public Ore {
182 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
183 u32 blockseed, v3s16 nmin, v3s16 nmax);
186 class OreSheet : public Ore {
188 virtual void generate(ManualMapVoxelManipulator *vm, int seed,
189 u32 blockseed, v3s16 nmin, v3s16 nmax);
192 Ore *createOre(OreType type);
195 enum DecorationType {
209 CutoffData(s16 x, s16 y, s16 z, s16 h) {
218 INodeDefManager *ndef;
221 std::string place_on_name;
222 content_t c_place_on;
228 //std::list<CutoffData> cutoffs;
229 //JMutex cutoff_mutex;
232 virtual ~Decoration();
234 virtual void resolveNodeNames(INodeDefManager *ndef);
235 void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
236 void placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
238 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) = 0;
239 virtual int getHeight() = 0;
240 virtual std::string getName() = 0;
243 class DecoSimple : public Decoration {
245 std::string deco_name;
246 std::string spawnby_name;
253 std::vector<std::string> decolist_names;
254 std::vector<content_t> c_decolist;
258 void resolveNodeNames(INodeDefManager *ndef);
259 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
260 virtual int getHeight();
261 virtual std::string getName();
264 #define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
266 class DecoSchematic : public Decoration {
268 std::string filename;
270 std::vector<std::string> *node_names;
271 std::vector<content_t> c_nodes;
272 std::map<std::string, std::string> replacements;
282 void resolveNodeNames(INodeDefManager *ndef);
283 virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p);
284 virtual int getHeight();
285 virtual std::string getName();
287 void blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
288 Rotation rot, bool force_placement);
290 bool loadSchematicFile();
291 void saveSchematicFile(INodeDefManager *ndef);
293 bool getSchematicFromMap(Map *map, v3s16 p1, v3s16 p2);
294 void placeStructure(Map *map, v3s16 p);
295 void applyProbabilities(std::vector<std::pair<v3s16, s16> > *plist, v3s16 p0);
298 void build_nnlist_and_update_ids(MapNode *nodes, u32 nodecount,
299 std::vector<content_t> *usednodes);
302 class DecoLSystem : public Decoration {
304 virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax);
308 Decoration *createDecoration(DecorationType type);