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
38 class ManualMapVoxelManipulator;
39 class INodeDefManager;
41 extern FlagDesc flagdesc_mapgen[];
42 extern FlagDesc flagdesc_gennotify[];
47 class ManualMapVoxelManipulator;
48 class VoxelManipulator;
67 GENNOTIFY_LARGECAVE_BEGIN,
68 GENNOTIFY_LARGECAVE_END,
73 struct GenNotifyEvent {
79 class GenerateNotifier {
82 GenerateNotifier(u32 notify_on, std::set<u32> *notify_on_deco_ids);
84 void setNotifyOn(u32 notify_on);
85 void setNotifyOnDecoIds(std::set<u32> *notify_on_deco_ids);
87 bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0);
88 void getEvents(std::map<std::string, std::vector<v3s16> > &event_map,
89 bool peek_events=false);
93 std::set<u32> *m_notify_on_deco_ids;
94 std::list<GenNotifyEvent> m_notify_events;
97 struct MapgenSpecificParams {
98 virtual void readParams(Settings *settings) = 0;
99 virtual void writeParams(Settings *settings) = 0;
100 virtual ~MapgenSpecificParams() {}
103 struct MapgenParams {
110 MapgenSpecificParams *sparams;
114 mg_name = DEFAULT_MAPGEN;
118 flags = MG_TREES | MG_CAVES | MG_LIGHT;
130 ManualMapVoxelManipulator *vm;
131 INodeDefManager *ndef;
137 GenerateNotifier gennotify;
140 Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
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 MapgenSpecificParams *createMapgenParams() = 0;
160 virtual ~MapgenFactory() {}
165 virtual ~GenElement() {}
170 class GenElementManager {
172 static const char *ELEMENT_TITLE;
173 static const size_t ELEMENT_LIMIT = -1;
175 GenElementManager() {}
176 virtual ~GenElementManager();
178 virtual GenElement *create(int type) = 0;
180 virtual u32 add(GenElement *elem);
181 virtual GenElement *get(u32 id);
182 virtual GenElement *update(u32 id, GenElement *elem);
183 virtual GenElement *remove(u32 id);
184 virtual void clear();
186 virtual GenElement *getByName(const std::string &name);
189 std::vector<GenElement *> m_elements;