boskid wrote: Sun Mar 03, 2024 10:45 pm
Khagan wrote: Sun Mar 03, 2024 9:29 pm
I'd call that a pathing bug. If the
gate can't open in time, then the
train should not be going that way.
I would not be so sure about that. Lets think about this:
1/
Train could open all gates in the braking distance on all possible branches. That would be really expensive at runtime and especially expensive when trains would be modded with extremally high speed and dense junctions. Lets say this solution is unreasonable.
That makes no sense. A
train isn't going to repath all the time. Reserving only the gates on the path the
train is actually reserving is enough. Just like it will only reserve signals along the path it is using.
When the
train repaths then it has to reserve new signals and it should at that point reserve gates. If the new path has a
gate that can't open in time then that is the same as a red signal along that path and the path finder will have to keep searching. And just like trains (now) keep their original path till they have left a chain signal segment they should also keep their original path till they have cleared a
gate. Trains should never stop in the middle of a
gate due to repathing.
Note: they could stop in the middle of a
gate if you have a normal signal close after the
gate and that stops the
train.
boskid wrote: Sun Mar 03, 2024 10:45 pm
2/ Lets think what would happen if a
train would have speed so high that it could reach from start to the end in just a 1 tick. Then there is no pathing ever possible that would give the
gate enough time to open before the
train would cross it. That case is clearly not a pathing bug, its just the execution of the path that causes
train to collide because
gate did not open in time.
Actually no. The
train already has a valid path. If every path to the new destination has a
gate on it that can't open in time then the
train should simply go into no-path state, break after leaving the current chain signal block(s) and eventually halt.
Now you might think that the tricky bit would be that as the
train breaks new paths would open up because with less speed the
gate can open in time. But that is not happening. The tricky bit should already be in the "can't open in time" calculations.
And yeah, this would make trains more complex. The game would have to calculate if the
gate can open time if the
train breaks while approaching the
gate. Simple enough and not the problem. But assuming the
gate can open in time with the
train breaking the question then is: How much? How much does the
train have to break so that it will arrive at the
gate just when it reaches open state? This would make
train behavior more complex because this wouldn't simply reuse the breaking point like signals use but would need a second point that is time based.
Thinking about it some more I now wonder: How do gates open anyway? Unless they open when the breaking point crosses the
gate, in which case just don't allow any repath where the breaking point crosses a closed
gate, there already has to be a "N-ticks before the
train" point that the game tracks that triggers opening the gates. And then the same point could be used during repath to only allow paths where that point doesn't cross closed gates.
boskid wrote: Sun Mar 03, 2024 10:45 pm
3/
Gate could be force closed be a circuit network in which case the
train will hit it anyway.
That should be simple to avoid. Just like signals can't be turned red to stop a
train that has reserved a path a circuit signal should not close a
gate that has a
train coming through, i.e. the breaking point has crossed the
gate and reserved it.
boskid wrote: Sun Mar 03, 2024 10:45 pm
Calling
train collisions with gates a pathing bug has a slight taste of saying "go fix that" and given all the reprecussions i am more likely to call it a Wont fix as the other reasonable alternative would be to get rid of the gates (or making them non colliding immediately when they are requested to open).
That is exactly what we are saying.
It should be easy to only allow repath where the breaking point doesn't cross a closed
gate. Not trivial but fairly easy. Mark every segment (block?) that has a
gate and if that flag is set then on repath check if the
gate is closed and before or after the breaking point. Is there such a flag already? I would hope so to optimize opening gates. Surely the game doesn't scan ahead of the
train every tick to see if there is a
gate to be opened.