7 #include "server/server.h"
11 MBS_CREATED, // block exists but was not yet generated
12 MBS_GENERATING, // currently generating in a seperate thread
13 MBS_READY, // generation finished
18 MGS_VOID, // initial air, can be overridden by anything
19 MGS_TERRAIN, // basic terrain, can be overridden by anything except the void
20 MGS_BOULDERS, // boulders, replace terrain
21 MGS_TREES, // trees replace boulders
22 MGS_PLAYER, // player-placed nodes or things placed after map generation
25 typedef MapgenStage MapgenStageBuffer[MAPBLOCK_SIZE][MAPBLOCK_SIZE][MAPBLOCK_SIZE];
34 char *data; // cached serialized data
35 size_t size; // size of data
36 MapBlockState state; // generation state of the block
37 pthread_t mapgen_thread; // thread that is generating block
38 MapgenStageBuffer mgs_buffer; // buffer to make sure mapgen only overrides things it should
41 extern struct ServerMap {
42 Map *map; // map object, data is stored here
43 bool joining_threads; // prevent threads from removing themselves from the thread list if thread list is being cleared anyway
44 pthread_mutex_t joining_threads_mtx; // mutex to protect joining threads
45 List mapgen_threads; // a list of mapgen threads (need to be joined before shutdown)
46 pthread_mutex_t mapgen_threads_mtx; // mutex to protect mapgen thread list
47 s32 spawn_height; // height to spawn players at
48 } server_map; // ServerMap singleton
50 void server_map_init(Server *server); // ServerMap singleton constructor
51 void server_map_deinit(); // ServerMap singleton destructor
52 void server_map_requested_block(Client *client, v3s32 pos); // handle block request from client (thread safe)
53 void server_map_prepare_spawn(); // prepare spawn region