1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-15 18:57:08 +00:00

Give the Mapgen on each EmergeThread its own Biome/Ore/Deco/SchemManager copy

This commit is contained in:
sfan5 2020-04-10 02:05:20 +02:00 committed by Loïc Blot
parent 2062c80e21
commit 3c65d1acec
27 changed files with 225 additions and 77 deletions

View file

@ -86,6 +86,30 @@ struct BlockEmergeData {
EmergeCallbackList callbacks;
};
class EmergeParams {
friend class EmergeManager;
public:
EmergeParams() = delete;
~EmergeParams();
DISABLE_CLASS_COPY(EmergeParams);
const NodeDefManager *ndef; // shared
bool enable_mapgen_debug_info;
u32 gen_notify_on;
const std::set<u32> *gen_notify_on_deco_ids; // shared
BiomeManager *biomemgr;
OreManager *oremgr;
DecorationManager *decomgr;
SchematicManager *schemmgr;
private:
EmergeParams(EmergeManager *parent, const BiomeManager *biomemgr,
const OreManager *oremgr, const DecorationManager *decomgr,
const SchematicManager *schemmgr);
};
class EmergeManager {
public:
const NodeDefManager *ndef;
@ -106,17 +130,22 @@ public:
// Environment is not created until after script initialization.
MapSettingsManager *map_settings_mgr;
// Managers of various map generation-related components
BiomeManager *biomemgr;
OreManager *oremgr;
DecorationManager *decomgr;
SchematicManager *schemmgr;
// Methods
EmergeManager(Server *server);
~EmergeManager();
DISABLE_CLASS_COPY(EmergeManager);
// no usage restrictions
const BiomeManager *getBiomeManager() const { return biomemgr; }
const OreManager *getOreManager() const { return oremgr; }
const DecorationManager *getDecorationManager() const { return decomgr; }
const SchematicManager *getSchematicManager() const { return schemmgr; }
// only usable before mapgen init
BiomeManager *getWritableBiomeManager();
OreManager *getWritableOreManager();
DecorationManager *getWritableDecorationManager();
SchematicManager *getWritableSchematicManager();
void initMapgens(MapgenParams *mgparams);
void startThreads();
@ -160,6 +189,13 @@ private:
u16 m_qlimit_diskonly;
u16 m_qlimit_generate;
// Managers of various map generation-related components
// Note that each Mapgen gets a copy(!) of these to work with
BiomeManager *biomemgr;
OreManager *oremgr;
DecorationManager *decomgr;
SchematicManager *schemmgr;
// Requires m_queue_mutex held
EmergeThread *getOptimalThread();