3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
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/container.h"
26 #include "map.h" // for ManualMapVoxelManipulator
27 #include "mapgen.h" // for MapgenParams
29 #define MGPARAMS_SET_MGNAME 1
30 #define MGPARAMS_SET_SEED 2
31 #define MGPARAMS_SET_WATER_LEVEL 4
32 #define MGPARAMS_SET_FLAGS 8
34 #define BLOCK_EMERGE_ALLOWGEN (1<<0)
36 #define EMERGE_DBG_OUT(x) \
37 { if (enable_mapgen_debug_info) \
38 infostream << "EmergeThread: " x << std::endl; }
42 //struct MapgenFactory;
44 class BiomeDefManager;
47 class INodeDefManager;
50 struct BlockMakeData {
51 ManualMapVoxelManipulator *vmanip;
55 v3s16 blockpos_requested;
56 UniqueQueue<v3s16> transforming_liquid;
57 INodeDefManager *nodedef;
65 ~BlockMakeData() { delete vmanip; }
68 struct BlockEmergeData {
75 INodeDefManager *ndef;
77 std::map<std::string, MapgenFactory *> mglist;
79 std::vector<Mapgen *> mapgen;
80 std::vector<EmergeThread *> emergethread;
86 bool mapgen_debug_info;
93 //block emerge queue data structures
95 std::map<v3s16, BlockEmergeData *> blocks_enqueued;
96 std::map<u16, u16> peer_queue_count;
98 //Mapgen-related structures
99 BiomeDefManager *biomedef;
100 std::vector<Ore *> ores;
101 std::vector<Decoration *> decorations;
103 EmergeManager(IGameDef *gamedef);
106 void loadMapgenParams();
108 Mapgen *getCurrentMapgen();
109 Mapgen *createMapgen(std::string mgname, int mgid,
110 MapgenParams *mgparams);
111 MapgenSpecificParams *createMapgenParams(std::string mgname);
114 bool enqueueBlockEmerge(u16 peer_id, v3s16 p, bool allow_generate);
116 void registerMapgen(std::string name, MapgenFactory *mgfactory);
117 void loadParamsFromSettings(Settings *settings);
118 void saveParamsToSettings(Settings *settings);
120 //mapgen helper methods
121 Biome *getBiomeAtPoint(v3s16 p);
122 int getGroundLevelAtPoint(v2s16 p);
123 bool isBlockUnderground(v3s16 blockpos);
124 u32 getBlockSeed(v3s16 p);