Page 1 of 1

[0.15.6] Hard crash on iterating through chunks

Posted: Thu May 04, 2017 9:05 pm
by orzelek
There seems to be a strange crash when iterating over chunks using for and LuaSurface.get_chunks().
To reproduce it you need mods and save avaialble in this thread:
viewtopic.php?p=266428#p266428

After loading the save try to run following command:

Code: Select all

/c remote.call("RSO", "regenerate")
Function called in RSO uses for loop with chunk iterator twice. First time it clears the chunks and second time it generates ores again.
I used log() statements to check that crash happens after generating a chunk when it should iterate to next one (thats during second iteration).
I'm not sure if it's something I'm doing in lua or the fact that I'm iterating twice over chunks.
Log from crash:
log

Re: [0.15.6] Hard crash on iterating through chunks

Posted: Thu May 04, 2017 10:00 pm
by Rseding91
The problem is the chunk iterator becomes invalid when chunks are generated because it points at the old data the chunks were stored in.

I'll work on it and get it fixed for the next version of 0.15 so it's capable of handling when chunks are generated while iterating. You just might not get every single chunk in those instances (ones generated after the iterator moves past that chunk position).

Re: [0.15.6] Hard crash on iterating through chunks

Posted: Thu May 04, 2017 10:10 pm
by orzelek
So one of ore placements causes chunk to be created?

I had an idea to calculate ore patch first, then check for chunks there, trigger their generation and place the patch after all are ready.
I'm not 100% sure how that would work since I would need to store whole ore patch somewhere in global and that would be quite a lot of coordinate pairs with one or two additional values.