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.
26 #include "util/string.h"
27 #include "util/container.h"
29 #define DEFAULT_MAPGEN "v6"
31 /////////////////// Mapgen flags
34 #define MG_DUNGEONS 0x04
39 class ManualMapVoxelManipulator;
40 class INodeDefManager;
42 extern FlagDesc flagdesc_mapgen[];
43 extern FlagDesc flagdesc_gennotify[];
48 class ManualMapVoxelManipulator;
49 class VoxelManipulator;
68 GENNOTIFY_LARGECAVE_BEGIN,
69 GENNOTIFY_LARGECAVE_END,
74 struct GenNotifyEvent {
80 class GenerateNotifier {
83 GenerateNotifier(u32 notify_on, std::set<u32> *notify_on_deco_ids);
85 void setNotifyOn(u32 notify_on);
86 void setNotifyOnDecoIds(std::set<u32> *notify_on_deco_ids);
88 bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0);
89 void getEvents(std::map<std::string, std::vector<v3s16> > &event_map,
90 bool peek_events=false);
94 std::set<u32> *m_notify_on_deco_ids;
95 std::list<GenNotifyEvent> m_notify_events;
98 struct MapgenSpecificParams {
99 virtual void readParams(Settings *settings) = 0;
100 virtual void writeParams(Settings *settings) = 0;
101 virtual ~MapgenSpecificParams() {}
104 struct MapgenParams {
111 NoiseParams np_biome_heat;
112 NoiseParams np_biome_humidity;
114 MapgenSpecificParams *sparams;
118 mg_name = DEFAULT_MAPGEN;
122 flags = MG_TREES | MG_CAVES | MG_LIGHT;
124 np_biome_heat = NoiseParams(50, 50, v3f(500.0, 500.0, 500.0), 5349, 3, 0.5, 2.0);
125 np_biome_humidity = NoiseParams(50, 50, v3f(500.0, 500.0, 500.0), 842, 3, 0.5, 2.0);
137 ManualMapVoxelManipulator *vm;
138 INodeDefManager *ndef;
145 GenerateNotifier gennotify;
148 Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
151 static u32 getBlockSeed(v3s16 p, int seed);
152 static u32 getBlockSeed2(v3s16 p, int seed);
153 s16 findGroundLevelFull(v2s16 p2d);
154 s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
155 void updateHeightmap(v3s16 nmin, v3s16 nmax);
156 void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
158 void setLighting(u8 light, v3s16 nmin, v3s16 nmax);
159 void lightSpread(VoxelArea &a, v3s16 p, u8 light);
161 void calcLighting(v3s16 nmin, v3s16 nmax);
162 void calcLighting(v3s16 nmin, v3s16 nmax,
163 v3s16 full_nmin, v3s16 full_nmax);
165 void propagateSunlight(v3s16 nmin, v3s16 nmax);
166 void spreadLight(v3s16 nmin, v3s16 nmax);
168 void calcLightingOld(v3s16 nmin, v3s16 nmax);
170 virtual void makeChunk(BlockMakeData *data) {}
171 virtual int getGroundLevelAtPoint(v2s16 p) { return 0; }
174 struct MapgenFactory {
175 virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
176 EmergeManager *emerge) = 0;
177 virtual MapgenSpecificParams *createMapgenParams() = 0;
178 virtual ~MapgenFactory() {}
183 virtual ~GenElement() {}
188 class GenElementManager {
190 static const char *ELEMENT_TITLE;
191 static const size_t ELEMENT_LIMIT = -1;
193 GenElementManager(IGameDef *gamedef);
194 virtual ~GenElementManager();
196 virtual GenElement *create(int type) = 0;
198 virtual u32 add(GenElement *elem);
199 virtual GenElement *get(u32 id);
200 virtual GenElement *update(u32 id, GenElement *elem);
201 virtual GenElement *remove(u32 id);
202 virtual void clear();
204 virtual GenElement *getByName(const std::string &name);
207 INodeDefManager *m_ndef;
208 std::vector<GenElement *> m_elements;