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 {
51 v3s16 blockpos_requested;
52 UniqueQueue<v3s16> transforming_liquid;
53 INodeDefManager *nodedef;
61 ~BlockMakeData() { delete vmanip; }
64 struct BlockEmergeData {
71 INodeDefManager *ndef;
73 std::vector<Mapgen *> mapgen;
74 std::vector<EmergeThread *> emergethread;
80 bool mapgen_debug_info;
86 std::set<u32> gen_notify_on_deco_ids;
88 //// Block emerge queue data structures
90 std::map<v3s16, BlockEmergeData *> blocks_enqueued;
91 std::map<u16, u16> peer_queue_count;
93 //// Managers of map generation-related components
94 BiomeManager *biomemgr;
96 DecorationManager *decomgr;
97 SchematicManager *schemmgr;
100 EmergeManager(IGameDef *gamedef);
103 void loadMapgenParams();
104 static MapgenSpecificParams *createMapgenParams(const std::string &mgname);
106 Mapgen *getCurrentMapgen();
107 Mapgen *createMapgen(const std::string &mgname, int mgid,
108 MapgenParams *mgparams);
109 static void getMapgenNames(std::list<const char *> &mgnames);
112 bool enqueueBlockEmerge(u16 peer_id, v3s16 p, bool allow_generate);
114 //mapgen helper methods
115 Biome *getBiomeAtPoint(v3s16 p);
116 int getGroundLevelAtPoint(v2s16 p);
117 bool isBlockUnderground(v3s16 blockpos);