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.
25 #include "util/string.h"
26 #include "util/container.h"
28 #define DEFAULT_MAPGEN "v6"
30 /////////////////// Mapgen flags
33 #define MG_DUNGEONS 0x04
37 #define NUM_GEN_NOTIFY 6
40 class ManualMapVoxelManipulator;
41 class INodeDefManager;
43 extern FlagDesc flagdesc_mapgen[];
44 extern FlagDesc flagdesc_gennotify[];
49 class ManualMapVoxelManipulator;
50 class VoxelManipulator;
69 GENNOTIFY_LARGECAVE_BEGIN,
70 GENNOTIFY_LARGECAVE_END
73 struct MapgenSpecificParams {
74 virtual void readParams(Settings *settings) = 0;
75 virtual void writeParams(Settings *settings) = 0;
76 virtual ~MapgenSpecificParams() {}
86 MapgenSpecificParams *sparams;
89 mg_name = DEFAULT_MAPGEN;
93 flags = MG_TREES | MG_CAVES | MG_LIGHT;
104 ManualMapVoxelManipulator *vm;
105 INodeDefManager *ndef;
112 std::vector<v3s16> *gen_notifications[NUM_GEN_NOTIFY];
117 s16 findGroundLevelFull(v2s16 p2d);
118 s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
119 void updateHeightmap(v3s16 nmin, v3s16 nmax);
120 void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
121 void setLighting(v3s16 nmin, v3s16 nmax, u8 light);
122 void lightSpread(VoxelArea &a, v3s16 p, u8 light);
123 void calcLighting(v3s16 nmin, v3s16 nmax);
124 void calcLightingOld(v3s16 nmin, v3s16 nmax);
126 virtual void makeChunk(BlockMakeData *data) {}
127 virtual int getGroundLevelAtPoint(v2s16 p) { return 0; }
130 struct MapgenFactory {
131 virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
132 EmergeManager *emerge) = 0;
133 virtual MapgenSpecificParams *createMapgenParams() = 0;
134 virtual ~MapgenFactory() {}
143 class GenElementManager {
145 static const char *ELEMENT_TITLE;
146 static const size_t ELEMENT_LIMIT = -1;
148 GenElementManager() {}
149 virtual ~GenElementManager();
151 virtual GenElement *create(int type) = 0;
153 virtual u32 add(GenElement *elem);
154 virtual GenElement *get(u32 id);
155 virtual GenElement *update(u32 id, GenElement *elem);
156 virtual GenElement *remove(u32 id);
158 virtual GenElement *getByName(const char *name);
159 virtual GenElement *getByName(std::string &name);
162 std::vector<GenElement *> m_elements;