]> git.lizzy.rs Git - dragonblocks_alpha.git/blobdiff - src/server/terrain_gen.c
Fix client terrain crashes and performance
[dragonblocks_alpha.git] / src / server / terrain_gen.c
index b5ed20911b503d755a93a77c3697a66891a9da28..b9131674ca56aefe15983e20f334344a652100aa 100644 (file)
@@ -1,3 +1,4 @@
+#include <assert.h>
 #include <math.h>
 #include <stdlib.h>
 #include "environment.h"
@@ -106,12 +107,12 @@ void terrain_gen_chunk(TerrainChunk *chunk, List *changed_chunks)
                                        }
                                }
 
-                               terrain_lock_chunk(chunk);
+                               assert(pthread_rwlock_wrlock(&chunk->lock) == 0);
                                if (meta->tgsb.raw.nodes[x][y][z] <= STAGE_TERRAIN) {
                                        chunk->data[x][y][z] = server_node_create(node);
                                        meta->tgsb.raw.nodes[x][y][z] = STAGE_TERRAIN;
                                }
-                               pthread_mutex_unlock(&chunk->mtx);
+                               pthread_rwlock_unlock(&chunk->lock);
                        }
 
                        if (biome_def->after_row)