3 Copyright (C) 2010-2011 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_FORESTS 0x08
36 #define MGV6_BIOME_BLEND 0x10
38 class BiomeDefManager;
42 class ManualMapVoxelManipulator;
43 class VoxelManipulator;
44 class INodeDefManager;
46 struct BlockMakeData {
48 ManualMapVoxelManipulator *vmanip;
52 v3s16 blockpos_requested;
53 UniqueQueue<v3s16> transforming_liquid;
54 INodeDefManager *nodedef;
72 flags = MG_TREES | MG_CAVES | MGV6_BIOME_BLEND;
75 virtual bool readParams(Settings *settings) = 0;
76 virtual void writeParams(Settings *settings) {};
86 virtual void makeChunk(BlockMakeData *data) {};
87 virtual int getGroundLevelAtPoint(v2s16 p) = 0;
89 //Legacy functions for Farmesh (pending removal)
90 static bool get_have_beach(u64 seed, v2s16 p2d);
91 static double tree_amount_2d(u64 seed, v2s16 p);
92 static s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
95 struct MapgenFactory {
96 virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
97 EmergeManager *emerge) = 0;
98 virtual MapgenParams *createMapgenParams() = 0;
101 class EmergeManager {
103 std::map<std::string, MapgenFactory *> mglist;
106 MapgenParams *params;
108 //mapgen objects here
112 BiomeDefManager *biomedef;
114 EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef);
117 void initMapgens(MapgenParams *mgparams);
118 Mapgen *createMapgen(std::string mgname, int mgid,
119 MapgenParams *mgparams, EmergeManager *emerge);
120 MapgenParams *createMapgenParams(std::string mgname);
122 void addBlockToQueue();
124 bool registerMapgen(std::string name, MapgenFactory *mgfactory);
125 MapgenParams *getParamsFromSettings(Settings *settings);
127 //mapgen helper methods
128 Biome *getBiomeAtPoint(v3s16 p);
129 int getGroundLevelAtPoint(v2s16 p);
130 bool isBlockUnderground(v3s16 blockpos);
131 u32 getBlockSeed(v3s16 p);