6 #include "util/thread.h"
8 #define BLOCK_EMERGE_ALLOWGEN (1<<0)
10 #define EMERGE_DBG_OUT(x) \
11 { if (enable_mapgen_debug_info) \
12 infostream << "EmergeThread: " x << std::endl; }
18 class BiomeDefManager;
20 class ManualMapVoxelManipulator;
24 struct BlockMakeData {
25 ManualMapVoxelManipulator *vmanip;
29 v3s16 blockpos_requested;
30 UniqueQueue<v3s16> transforming_liquid;
31 INodeDefManager *nodedef;
39 ~BlockMakeData() { delete vmanip; }
42 struct BlockEmergeData {
49 std::map<std::string, MapgenFactory *> mglist;
51 std::vector<Mapgen *> mapgen;
52 std::vector<EmergeThread *> emergethread;
56 bool mapgen_debug_info;
61 //block emerge queue data structures
63 std::map<v3s16, BlockEmergeData *> blocks_enqueued;
64 std::map<u16, u16> peer_queue_count;
67 BiomeDefManager *biomedef;
69 EmergeManager(IGameDef *gamedef, BiomeDefManager *bdef);
72 void initMapgens(MapgenParams *mgparams);
73 Mapgen *createMapgen(std::string mgname, int mgid,
74 MapgenParams *mgparams);
75 MapgenParams *createMapgenParams(std::string mgname);
76 bool enqueueBlockEmerge(u16 peer_id, v3s16 p, bool allow_generate);
78 void registerMapgen(std::string name, MapgenFactory *mgfactory);
79 MapgenParams *getParamsFromSettings(Settings *settings);
80 void setParamsToSettings(Settings *settings);
82 //mapgen helper methods
83 Biome *getBiomeAtPoint(v3s16 p);
84 int getGroundLevelAtPoint(v2s16 p);
85 bool isBlockUnderground(v3s16 blockpos);
86 u32 getBlockSeed(v3s16 p);
89 class EmergeThread : public SimpleThread
93 EmergeManager *emerge;
95 bool enable_mapgen_debug_info;
100 std::queue<v3s16> blockqueue;
102 EmergeThread(Server *server, int ethreadid):
117 if(IsRunning() == false)
123 bool popBlockEmerge(v3s16 *pos, u8 *flags);
124 bool getBlockOrStartGen(v3s16 p, MapBlock **b,
125 BlockMakeData *data, bool allow_generate);