6 #include <dragontype/queue.h>
8 #include "client/object.h"
9 #define NUM_MESHGEN_THREADS 4
13 MBS_RECIEVING, // currently deserializing
14 MBS_FRESH, // first deserialisation finished, not processed by sync thread yet
15 MBS_READY, // ready to use and processed by sync thread
20 MapBlockState state; // keep track of the deserialisation and sync processing state
21 bool queue; // whether the block is in meshgen queue
22 u64 last_synced; // keep track of when a block was synced the last time (used to detect when a block got out of and then back into range)
23 Object *obj; // mesh object, generated by blockmesh file
26 extern struct ClientMap
28 Map *map; // map object
29 Queue *queue; // MapBlock * queue (thread safe)
30 bool cancel; // used to notify meshgen and sync thread about quit
31 pthread_t meshgen_threads[NUM_MESHGEN_THREADS]; // consumer threads for meshgen queue
32 pthread_t sync_thread; // this thread requests new / changed blocks from server
33 u32 simulation_distance; // simulation distance sent by server
34 size_t blocks_count; // cached number of facecache positions to process every sync step (matches simulation distance)
37 void client_map_init(); // ClientMap singleton constructor
38 void client_map_deinit(); // ClientMap singleton destructor
39 void client_map_set_simulation_distance(u32 simulation_distance); // update simulation distance
40 void client_map_start(); // start meshgen and sync threads
41 void client_map_stop(); // stop meshgen and sync threads
42 void client_map_block_received(MapBlock *block); // called when a block was actually recieved from server
43 void client_map_schedule_update_block_mesh(MapBlock *block); // enqueue block to mesh update queue