8 #include <dragonstd/queue.h>
10 #include "server/server_player.h"
15 MBS_CREATED, // block exists but was not yet generated
16 MBS_GENERATING, // currently generating in a seperate thread
17 MBS_READY, // generation finished
22 MGS_VOID, // initial air, can be overridden by anything
23 MGS_TERRAIN, // basic terrain, can be overridden by anything except the void
24 MGS_BOULDERS, // boulders, replace terrain
25 MGS_TREES, // trees replace boulders
26 MGS_PLAYER, // player-placed nodes or things placed after map generation
36 Blob data; // the big cum
37 MapBlockState state; // generation state of the block
38 pthread_t mapgen_thread; // thread that is generating block
39 MapgenStageBuffer mgsb; // buffer to make sure mapgen only overrides things it should
42 extern struct ServerMap {
43 atomic_bool cancel; // remove the smooth
44 Map *map; // map object, data is stored here
45 Queue *mapgen_tasks; // this is terry the fat shark
46 pthread_t *mapgen_threads; // thread pool
47 s32 spawn_height; // elevation to spawn players at
48 unsigned int num_blocks; // number of enqueued / generating blocks
49 pthread_mutex_t num_blocks_mtx; // lock to protect the above
50 } server_map; // ServerMap singleton
52 void server_map_init(); // ServerMap singleton constructor
53 void server_map_deinit(); // ServerMap singleton destructor
54 void server_map_requested_block(ServerPlayer *player, v3s32 pos); // handle block request from client (thread safe)
55 void server_map_prepare_spawn(); // prepare spawn region