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 "mapgen.h" // for MapgenParams
29 #define BLOCK_EMERGE_ALLOWGEN (1<<0)
31 #define EMERGE_DBG_OUT(x) \
33 if (enable_mapgen_debug_info) \
34 infostream << "EmergeThread: " x << std::endl; \
38 class INodeDefManager;
43 class DecorationManager;
44 class SchematicManager;
46 struct BlockMakeData {
47 ManualMapVoxelManipulator *vmanip;
51 v3s16 blockpos_requested;
52 UniqueQueue<v3s16> transforming_liquid;
53 INodeDefManager *nodedef;
61 ~BlockMakeData() { delete vmanip; }
64 struct BlockEmergeData {
71 INodeDefManager *ndef;
73 std::map<std::string, MapgenFactory *> mglist;
75 std::vector<Mapgen *> mapgen;
76 std::vector<EmergeThread *> emergethread;
82 bool mapgen_debug_info;
88 std::set<u32> gen_notify_on_deco_ids;
90 //// Block emerge queue data structures
92 std::map<v3s16, BlockEmergeData *> blocks_enqueued;
93 std::map<u16, u16> peer_queue_count;
95 //// Managers of map generation-related components
96 BiomeManager *biomemgr;
98 DecorationManager *decomgr;
99 SchematicManager *schemmgr;
102 EmergeManager(IGameDef *gamedef);
105 void loadMapgenParams();
107 Mapgen *getCurrentMapgen();
108 Mapgen *createMapgen(std::string mgname, int mgid,
109 MapgenParams *mgparams);
110 MapgenSpecificParams *createMapgenParams(std::string mgname);
113 bool enqueueBlockEmerge(u16 peer_id, v3s16 p, bool allow_generate);
115 void registerMapgen(std::string name, MapgenFactory *mgfactory);
116 void loadParamsFromSettings(Settings *settings);
117 void saveParamsToSettings(Settings *settings);
119 //mapgen helper methods
120 Biome *getBiomeAtPoint(v3s16 p);
121 int getGroundLevelAtPoint(v2s16 p);
122 bool isBlockUnderground(v3s16 blockpos);
123 u32 getBlockSeed(v3s16 p);