Page 1 of 1

[Genhis][2.0.41] Crash setting train schedule of moving train (RollingStock::checkConsistency) (speed == 0 || closing)

Posted: Sat Mar 15, 2025 1:00 am
by Ashier
I will attempt to explain as best I can. The relevant lua code for my mod can be found here: https://github.com/AtelierAmber/RSAD-Tr ... r.lua#L281 Linked to the line that I think is causing it.
Also attached is a save file to test it on. It is extremely easy to reproduce if timed correctly and will happen every time. I have included a small video to demonstrate it as well.

Steps to repro:
- Click the train and send it to the already scheduled station. This, similar to cybersyn, will register the train with the RSAD train system and send it to deliver the wagon.
- After the train has picked up the wagon, place another one at the back of the remaining wagon. This may not be necessary to crash it.
- Once the train is returning to the station, and after it has passed the crossing (such that it can path to the wagon pick up stop), delete the wagon at the drop off stop. This will trigger the linked code above to run and set a new schedule for the train.

Mod list:
- Base Mod
- Elevated Rails
- Debug Adapter for Factorio Mods (via vscode)
- Editor Extensions
- Factorio Library
- Pipe Visualizer 2.0 (Likely not required)
- RSAD Train Yards (My in-dev mod linked above)

Let me know if you require anything else.

Video
2025-03-14 18-48-50.mp4
(12.85 MiB) Downloaded 67 times
Log
factorio-current.log
(11.5 KiB) Downloaded 64 times
Dump
factorio-dump-current.dmp
(1.12 MiB) Downloaded 64 times
Save
default test-.zip
(881.02 KiB) Downloaded 65 times

Re: [2.0.41] Crash setting train schedule of moving train (RollingStock::checkConsistency) (speed == 0 || closing)

Posted: Thu Apr 17, 2025 12:02 am
by BurninSun
+1 [v2.0.45]

Code: Select all

Error RollingStock.cpp:1431: this->getSpeed() == 0.0 || this->closing was not true
Working with Space Exploration's space elevators where the mod will split up a train upon reaching the elevator's train stop.

Re: [2.0.41] Crash setting train schedule of moving train (RollingStock::checkConsistency) (speed == 0 || closing)

Posted: Fri Apr 18, 2025 8:48 am
by xane256
I have also been experiencing this issue while testing with space exploration. The issue happened for me when a large train went into the space elevator entrance on Nauvis, but a workaround that seems to work for now, is to remove all the locomotives from the big train, keeping only one locomotive. With 3 locomotives it would crash when entering the space elevator, but with 1 locomotive I haven't had a crash yet.

Re: [2.0.41] Crash setting train schedule of moving train (RollingStock::checkConsistency) (speed == 0 || closing)

Posted: Sat Apr 19, 2025 1:18 am
by BurninSun
I found the crash can be avoided by setting the trains speed to 0 before setting the train to its intended speed, even if doing so is done in the line previous to setting its actual speed. eg.
This will crash in Space Exploration's code:

Code: Select all

...
train_a.speed = -1
...
This will not crash:

Code: Select all

...
train_a.speed = 0
train_a.speed = -1
...

Re: [Genhis][2.0.41] Crash setting train schedule of moving train (RollingStock::checkConsistency) (speed == 0 || closin

Posted: Sun Apr 20, 2025 5:56 am
by BurninSun
Stripped down, simple save and reproduction in vanilla. Base mod only, no SA.

Load the attached save and run the following:

Code: Select all

/c storage.FRONT.train.schedule = nil storage.FRONT.destroy() storage.BACK.train.speed = 1
storage.FRONT is the front locomotive entity. storage.BACK is the back locomotive entity.

Result is immediate crash with

Code: Select all

Error RollingStock.cpp:1431: this->getSpeed() == 0.0 || this->closing was not true
Also, adding in a speed = 0 before the speed = 1 avoids the crash.

Re: [Genhis][2.0.41] Crash setting train schedule of moving train (RollingStock::checkConsistency) (speed == 0 || closin

Posted: Mon Apr 21, 2025 7:52 am
by Genhis
Thank you all for reproduction steps. The issue is fixed for 2.0.46.