Page 1 of 1
[1.1.80] asking to generate chunks while forcing chunk generation fails
Posted: Sun Apr 02, 2023 8:15 pm
by mrvn
I'm generating a fractal map in the on_chunk_generated event but I don't want to loose resources when I replace land with water. I want to move ore patches and for that I need the whole ore patch generated. So every time I hit a chunk with resources on it I check and generate all chunks around it using
Code: Select all
surface.request_to_generate_chunks({x0, y0}, 32)
surface.force_generate_chunk_requests()
The forcing causes more chunks to be generated and that adds more chunks to the queue and forces the generation again. This run for quite a while until it didn't:
81.003 Error MapGenerationManager.cpp:252: MapGenerationHelper::applyTaskResult(..., force) didn't finish all requests.
81.003 Error CrashHandler.cpp:637: Received 6
Logger::writeStacktrace skipped.
81.003 Error CrashHandler.cpp:191: Map tick at moment of crash: 2313
Re: [1.1.80] asking to generate chunks while forcing chunk generation fails
Posted: Sun Apr 02, 2023 8:22 pm
by lyvgbfh
Isn't this causing infinite recursion? Assuming one chunk in 9 has resources, won't your code just continue forever?
Re: [1.1.80] asking to generate chunks while forcing chunk generation fails
Posted: Sun Apr 02, 2023 10:37 pm
by Rseding91
Thanks for the report however this is expected. You can not queue more chunks to generate during the chunk generated event because it leads to potential infinite recursion.
Re: [1.1.80] asking to generate chunks while forcing chunk generation fails
Posted: Sun Apr 02, 2023 10:44 pm
by mrvn
lyvgbfh wrote: Sun Apr 02, 2023 8:22 pm
Isn't this causing infinite recursion? Assuming one chunk in 9 has resources, won't your code just continue forever?
Assuming resources are somewhat separated this will recourse over all chunks till it has a border of chunks without resources.
Re: [1.1.80] asking to generate chunks while forcing chunk generation fails
Posted: Sun Apr 02, 2023 10:47 pm
by mrvn
Rseding91 wrote: Sun Apr 02, 2023 10:37 pm
Thanks for the report however this is expected. You can not queue more chunks to generate during the chunk generated event because it leads to potential infinite recursion.
Then what is the solution for this problem?
Note that I only need the chunks to be generated to see if there are resources on them. I don't need the on_chunk_generated to have been run for them.
I tried writing out the chunks into a variable and then generating them in in_tick(). But in on_tick() the surface.force_generate_chunk_requests() somehow doesn't block and generate the chunks but simply returns.
Re: [1.1.80] asking to generate chunks while forcing chunk generation fails
Posted: Sun Apr 02, 2023 11:03 pm
by mrvn
mrvn wrote: Sun Apr 02, 2023 10:47 pm
I tried writing out the chunks into a variable and then generating them in in_tick(). But in on_tick() the surface.force_generate_chunk_requests() somehow doesn't block and generate the chunks but simply returns.
Never mind that. I confused myself because
surface.request_to_generate_chunks(position, radius) takes a MapPosition and a number of chunks
surface.is_chunk_generated(position) takes ChunkPosition
If you use the same position in both calls then that won't work. The first function really shouldn't take a MapPosition when it takes the radius in chunks.