diff --git a/world/voxel_chunk.cpp b/world/voxel_chunk.cpp index 907b1f8..022edca 100644 --- a/world/voxel_chunk.cpp +++ b/world/voxel_chunk.cpp @@ -242,6 +242,8 @@ int VoxelChunk::get_current_job_index() { return _current_job; } void VoxelChunk::next_job() { + _THREAD_SAFE_METHOD_ + ++_current_job; if (_current_job >= _jobs.size()) { @@ -270,6 +272,8 @@ void VoxelChunk::next_job() { } } Ref VoxelChunk::get_current_job() { + _THREAD_SAFE_METHOD_ + if (_current_job < 0 || _current_job >= _jobs.size()) { return Ref(); } @@ -1021,7 +1025,10 @@ void VoxelChunk::_exit_tree() { } void VoxelChunk::_generation_process(const float delta) { - ERR_FAIL_INDEX(_current_job, _jobs.size()); + _THREAD_SAFE_METHOD_ + + if (_current_job < 0 || _current_job >= _jobs.size()) + return; Ref job = _jobs[_current_job]; @@ -1043,7 +1050,10 @@ void VoxelChunk::_generation_process(const float delta) { } } void VoxelChunk::_generation_physics_process(const float delta) { - ERR_FAIL_INDEX(_current_job, _jobs.size()); + _THREAD_SAFE_METHOD_ + + if (_current_job < 0 || _current_job >= _jobs.size()) + return; Ref job = _jobs[_current_job]; diff --git a/world/voxel_chunk.h b/world/voxel_chunk.h index 899b1b3..ef91fe6 100644 --- a/world/voxel_chunk.h +++ b/world/voxel_chunk.h @@ -66,6 +66,8 @@ class VoxelWorld; class VoxelChunk : public Resource { GDCLASS(VoxelChunk, Resource); + _THREAD_SAFE_CLASS_ + public: enum { VOXEL_CHUNK_STATE_OK = 0,