Page 1 of 1

[fixed] [1.18.0] Error while running event LogisticTrainNetwork::on_train_changed_state (ID 25)

Posted: Mon Dec 12, 2022 10:58 pm
by cinebum
Hello!

I love LTN. I'm deep into a playthrough and all of a sudden, this nonrecoverable error started popping up. Honestly, it happened when I wasn't doing anything with trains. I have attempted to figure out if something is off, but, with this kind of error, you don't get to explore when it happens.

A train is called to pick up coke, then anothere train is called to pick up coke at another station. The first train hits the 5000 mark loading, and the second train is about half way to the station when the error occurs. It could be another train that was unable to be marked for delivery. I don't know. I do know that this error renders this 70 hour save useless unless I can figure out what I did wrong. :(
2022-12-12_18-13-07.png
2022-12-12_18-13-07.png (72.76 KiB) Viewed 1288 times

Re: [fixed] [1.18.0] Error while running event LogisticTrainNetwork::on_train_changed_state (ID 25)

Posted: Tue Dec 13, 2022 6:47 am
by Optera
A stop entity was removed just as a train left it.
Added additional check against this for next release.

Edit:
This error only happens when other mods remove stops without raising script_raised_destroy. Otherwise entity removal is handled before train updates.

Re: [fixed] [1.18.0] Error while running event LogisticTrainNetwork::on_train_changed_state (ID 25)

Posted: Tue Dec 13, 2022 6:52 pm
by cinebum
Thanks for that! Can you give me a little more insight? When you say a stop entity was removed, what do you mean? If there's something I can do in the minute or two before it fails, then at least I can get back to playing. Thanks for the quick turnaround!

Re: [fixed] [1.18.0] Error while running event LogisticTrainNetwork::on_train_changed_state (ID 25)

Posted: Wed Dec 14, 2022 6:55 am
by Optera
Didn't 1.18.1 solve your issue?

Re: [fixed] [1.18.0] Error while running event LogisticTrainNetwork::on_train_changed_state (ID 25)

Posted: Thu Dec 15, 2022 4:35 pm
by cinebum
Yes it did! Sorry, I read your message like you'll release it when your next release window opens. I didn't realize it had already been released.

I am curious about the details though. If another mod is not playing nice, I'd like to understand it and report it. Thanks again for the fast fix!

Re: [fixed] [1.18.0] Error while running event LogisticTrainNetwork::on_train_changed_state (ID 25)

Posted: Fri Dec 16, 2022 6:25 am
by Optera
I wrote the details in the changelog
Version: 1.18.1
Date: 2022-12-13
Bugfixes:
- crash when on_train_changed_state is raised for trains stopped at invalid stops. Should only happen if scripts remove stops without raising script_raised_destroy.
For non developers:
Normally removing a stop first raises a remove event before the train state changes. Due to the no longer existing stop the train is now in a different state and a train state changed event is raised.
In your case train state changed was raised for a train leaving a no longer existing stop without a removal event for the stop.

Most likely another mod removed the stop without notifying other mods. Unlike built in removal events, script_raised_destroy has to be called explicitly.

Anyways while LTN is quite robust against it, other mods changing it's entities can result in unexpected behavior.