I actually gave up trying to think what the exact mechanism was after I noticed that the delay command array was being mutated while it was being iterated through. I’ve seen that bug before too many times.
Interesting point: you can make the original code work by adding a dummy DEL command in…
DEL 300: SCRIPT 1
DEL 300: SCRIPT 1
TR.P
And now we have temporal recursion.
Anyway, as to the solution, I would probably be more in favour of a 2 step process, first extract the now commands into a temporary array, then execute them. Even better would be to create functions that do such things and place them in state.c, then the higher level code doesn’t need to worry about fiddling with arrays.
I’ve made an issue on GitHub. I haven’t got time to fix it yet (school holidays haven’t ended here in the UK, so things are still quite hectic). Hopefully I’ll get to it in a few weeks. (Thanks to @capogreco for reporting it.)
The code has been auto-formatted with clang-format, there is a thread somewhere on here where we discussed the options we would use.
It’s worth it for the consistency, especially with code from multiple contributors (you should have seen it beforehand). But you do end up in the situation where nobody is entirely happy with it (except me, as I choose most of the options, but then I did most of the work…).