Page 1 of 1

[boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Posted: Fri Nov 22, 2024 1:03 am
by yuu6883dev
A very long belt for storing some rocks:
image (37).jpg
image (37).jpg (675.47 KiB) Viewed 1880 times
Top left I'm reading belt content
Delete any section of the belt and the game halts (probably infinite loop)
No crash log / nothing abnormal in game log / no output after halt
100% reproducible on my side (tried at least 5 times)
Blueprint of entire ship is attached (belt.txt), don't think the save file has any use.
Issue is not seen when I'm not reading full belt content and cutting the belt

Re: [2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Posted: Fri Nov 22, 2024 1:26 am
by boskid
Its not infinite loop, it looks like it is O(N^2) where N is amount of belt belt pieces: when removing 1 belt piece there is code that tries to span transport line nicely, but before doing so it cuts the entire sequence into 1 tile long pieces (this is the first N) and when every piece is created, belt reader is propagated backward and forward (this is the second N). I may have some ideas how to improve this slightly, but this really feels like one of the "stop shooting yourself into your foot from the artillery cannot" case.

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Posted: Fri Nov 22, 2024 3:38 am
by yuu6883dev
hmm, can the belt reader be propagated after the new lines are formed? It would still be O(N).
By any means, this is a really niche situation that I can work around.

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Posted: Fri Nov 22, 2024 11:57 am
by boskid
Ok, it looks like by adding a strategic one line of code in one specifc place fixes this issue completly without even need to rewrite the remerge logic. So this issue should be now fixed for 2.0.22.

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Posted: Fri Nov 22, 2024 12:33 pm
by yuu6883dev
Thanks for the quick fix!

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Posted: Fri Nov 22, 2024 8:53 pm
by boskid
Ok, i did also another optimization on top of the previous one, a rewirite of the remerge logic and now my setup that consists of 250k of transport belts connected in sequence with belt reader active, when removing a belt takes about 8ms for the remerge operation which is hardly noticable. In 2.0.21 that same setup was taking way more than 5 minutes (i never saw it finish) so i am going to call it a success.

Re: [boskid][2.0.20] Read full belt content on very long belt loop halts the game when the belt is cut

Posted: Sat Nov 23, 2024 4:44 am
by afr33sl4ve
Resolved this too: viewtopic.php?f=49&t=121997

Ty, boskid and yuu6883dev.