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
40 class INodeDefManager;
42 extern FlagDesc flagdesc_mapgen[];
43 extern FlagDesc flagdesc_gennotify[];
48 class VoxelManipulator;
67 GENNOTIFY_LARGECAVE_BEGIN,
68 GENNOTIFY_LARGECAVE_END,
73 // TODO(hmmmm/paramat): make stone type selection dynamic
80 struct GenNotifyEvent {
86 class GenerateNotifier {
89 GenerateNotifier(u32 notify_on, std::set<u32> *notify_on_deco_ids);
91 void setNotifyOn(u32 notify_on);
92 void setNotifyOnDecoIds(std::set<u32> *notify_on_deco_ids);
94 bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0);
95 void getEvents(std::map<std::string, std::vector<v3s16> > &event_map,
96 bool peek_events=false);
100 std::set<u32> *m_notify_on_deco_ids;
101 std::list<GenNotifyEvent> m_notify_events;
104 struct MapgenSpecificParams {
105 virtual void readParams(const Settings *settings) = 0;
106 virtual void writeParams(Settings *settings) const = 0;
107 virtual ~MapgenSpecificParams() {}
110 struct MapgenParams {
117 NoiseParams np_biome_heat;
118 NoiseParams np_biome_heat_blend;
119 NoiseParams np_biome_humidity;
120 NoiseParams np_biome_humidity_blend;
122 MapgenSpecificParams *sparams;
125 mg_name(DEFAULT_MAPGEN),
129 flags(MG_TREES | MG_CAVES | MG_LIGHT),
130 np_biome_heat(NoiseParams(50, 50, v3f(1000.0, 1000.0, 1000.0), 5349, 3, 0.5, 2.0)),
131 np_biome_heat_blend(NoiseParams(0, 1.5, v3f(8.0, 8.0, 8.0), 13, 2, 1.0, 2.0)),
132 np_biome_humidity(NoiseParams(50, 50, v3f(1000.0, 1000.0, 1000.0), 842, 3, 0.5, 2.0)),
133 np_biome_humidity_blend(NoiseParams(0, 1.5, v3f(8.0, 8.0, 8.0), 90003, 2, 1.0, 2.0)),
137 void load(const Settings &settings);
138 void save(Settings &settings) const;
150 INodeDefManager *ndef;
159 GenerateNotifier gennotify;
162 Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge);
165 static u32 getBlockSeed(v3s16 p, int seed);
166 static u32 getBlockSeed2(v3s16 p, int seed);
167 s16 findGroundLevelFull(v2s16 p2d);
168 s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
169 void updateHeightmap(v3s16 nmin, v3s16 nmax);
170 void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
172 void setLighting(u8 light, v3s16 nmin, v3s16 nmax);
173 void lightSpread(VoxelArea &a, v3s16 p, u8 light);
175 void calcLighting(v3s16 nmin, v3s16 nmax);
176 void calcLighting(v3s16 nmin, v3s16 nmax,
177 v3s16 full_nmin, v3s16 full_nmax);
179 void propagateSunlight(v3s16 nmin, v3s16 nmax);
180 void spreadLight(v3s16 nmin, v3s16 nmax);
182 void calcLightingOld(v3s16 nmin, v3s16 nmax);
184 virtual void makeChunk(BlockMakeData *data) {}
185 virtual int getGroundLevelAtPoint(v2s16 p) { return 0; }
188 struct MapgenFactory {
189 virtual Mapgen *createMapgen(int mgid, MapgenParams *params,
190 EmergeManager *emerge) = 0;
191 virtual MapgenSpecificParams *createMapgenParams() = 0;
192 virtual ~MapgenFactory() {}