-Subproject commit 8bcc4ba04baea8f4d1f86524e58bd81d4df67bf6
+Subproject commit 164e1ed7f93e1889c36b549a995e93fc0992c888
-Subproject commit 61292ea8a973ba03f93ebf4acde705071e15ccaf
+Subproject commit 18ae77e35da46f97f3b06562a4a892ebdeeb9750
MapBlock *block = map_get_block(client_map.map, pkt->pos, true);
map_deserialize_block(block, pkt->data);
+ ((MapBlockExtraData *) block->extra)->all_air = (pkt->data.siz == 0);
client_map_block_received(block);
}
extra->queue = false;
extra->last_synced = 0;
extra->obj = NULL;
+ extra->all_air = false;
}
// callback for deleting a block
pthread_mutex_lock(&block->mtx);
MapBlockExtraData *extra = block->extra;
+
if (! extra->queue) {
- extra->queue = true;
- queue_enqueue(client_map.queue, block);
+ if (extra->all_air) {
+ if (extra->obj) {
+ extra->obj->remove = true;
+ extra->obj = NULL;
+ }
+ } else {
+ extra->queue = true;
+ queue_enqueue(client_map.queue, block);
+ }
}
pthread_mutex_unlock(&block->mtx);
}
bool queue; // whether the block is in meshgen queue
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)
Object *obj; // mesh object, generated by blockmesh file
+ bool all_air; // no thoughts brain empty
} MapBlockExtraData;
extern struct ClientMap
Blob map_serialize_block(MapBlock *block)
{
+ bool all_air = true;
+
+ ITERATE_MAPBLOCK {
+ if (block->data[x][y][z].type != NODE_AIR) {
+ all_air = false;
+ break;
+ }
+ }
+
+ if (all_air)
+ return (Blob) {0, NULL};
+
SerializedMapBlock block_data;
ITERATE_MAPBLOCK {
bool map_deserialize_block(MapBlock *block, Blob buffer)
{
+ if (buffer.siz == 0) {
+ ITERATE_MAPBLOCK
+ block->data[x][y][z] = map_node_create(NODE_AIR, (Blob) {0, NULL});
+
+ return true;
+ }
+
// it's important to copy Blobs that have been malloc'd before reading from them
// because reading from a Blob modifies its data and size pointer,
// but does not free anything