mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 04:15:14 -04:00
world: improve locking when retrieving neighbours
This commit is contained in:
parent
73d6f3a481
commit
7a07d7a143
@ -357,9 +357,11 @@ class World(
|
|||||||
*/
|
*/
|
||||||
fun getChunkNeighbours(neighbourPositions: Array<ChunkPosition>): Array<Chunk?> {
|
fun getChunkNeighbours(neighbourPositions: Array<ChunkPosition>): Array<Chunk?> {
|
||||||
val chunks: Array<Chunk?> = arrayOfNulls(neighbourPositions.size)
|
val chunks: Array<Chunk?> = arrayOfNulls(neighbourPositions.size)
|
||||||
|
this.chunks.lock.acquire()
|
||||||
for ((index, neighbourPosition) in neighbourPositions.withIndex()) {
|
for ((index, neighbourPosition) in neighbourPositions.withIndex()) {
|
||||||
chunks[index] = this[neighbourPosition] ?: continue
|
chunks[index] = this.chunks.unsafe[neighbourPosition] ?: continue
|
||||||
}
|
}
|
||||||
|
this.chunks.lock.release()
|
||||||
return chunks
|
return chunks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user