Page 1 of 1

[0.17.79] Train line (with multiple same name stops) counts same station twice

Posted: Tue Dec 24, 2019 9:32 pm
by kaijyuu
So for my mining operations, I have a single long track for each metal where each mining stop has the same name. I noticed that the last stop in my copper line is often (but not always!) skipped by my trains. After some tracing, I found that one of my stops is counted twice by my trains when another train is in front of it preventing it from moving from its current stop.

Linked is a save showing the issue (the forum upload wasn't working for some reason, despite the file being smaller than 128 mb). The train I'm inside stops at the train stop, its timer counts down, then it starts waiting for the train in front of it to get out of the way. When the way is clear...the train thinks it already reached the next station, despite not moving! This effectively counts the same stop twice, resulting in my final stop being skipped.

https://drive.google.com/open?id=1ykEK- ... UjFVJOuDRC

(some other things break shortly afterward, but that's because I disabled all my mods to test the issue and make the example save. I'm fairly certain it'd happen mod-less from the beginning)

Re: [0.17.79] Train line (with multiple same name stops) counts same station twice

Posted: Tue Dec 24, 2019 11:14 pm
by boskid
Technicaly this is Not a bug since next schedule entry is to go "Copper plate pickup" and train is already there. There is no rule saying train must leave station it is already in.

You may use Circuit Network to disable train station until train leaves.

Re: [0.17.79] Train line (with multiple same name stops) counts same station twice

Posted: Wed Dec 25, 2019 12:37 am
by kaijyuu
That seems fairly inconsistent with regular behavior. If there's no rule that a train must leave the station it's already in, I'd expect that the trains would wait all 11 scheduled stops at the first station.

Re: [0.17.79] Train line (with multiple same name stops) counts same station twice

Posted: Wed Dec 25, 2019 12:42 am
by boskid
i looked into code and i have exact explanation why it happens:
- pathfinding from train stop is implemented in a way to exclude given train stop. This should prevent this behavior.
- rail signal is so close to train station it prevents train from moving when next block is occupied
- when train in front passes signal at {1458.5, -1936.5}, rail signal switches state and this causes train to repath
- repath because of signal change does not exclude any train stops because train could be already on route and may need to go back to previous station. No train stop exclusion and no change in position means train can path to same station it already is in.
- train arrives to same station because it is not forced to not path to this station.

If you want to prevent this behavior from happening, you may move rail signal right after train stop to be 2 tiles ahead so train when leaving is allowed to go 2 tiles ahead so it is no longer aligned with station it left. This means in case of repath it will choose to go to next station.

-- edit:
above solution will not solve your use case 100% since placing rail signal on trains path on next tick after train found path will force it to repath again when it did not move yet. In this case it will reach same train stop second time.