IncredibleHannes / TPF2-Timetables

The Timetable mod for Transport Fever 2
GNU General Public License v3.0
32 stars 19 forks source link

fixing the issue of trains not being controlled by the mod under certain circumstances #36

Closed w43322 closed 3 years ago

w43322 commented 3 years ago

force traverse through all vehicles before yielding, to fix the issue of trains not being controlled by the mod under certain circumstances

w43322 commented 3 years ago

timetable.waitingRequired() only processes a train when TimeUntilDeparture < 2. Under circumstances with a high number of lines and vehicles to traverse through and when the coroutine is not being run frequently enough, timetableCoroutine() might not be able to assume control the train in this period of time.

IncredibleHannes commented 3 years ago

Hi, unfortunately traversing all vehicles has a huge performance impact on maps with many vehicles. We were already discussing in https://github.com/IncredibleHannes/TPF2-Timetables/pull/8 a potential dynamic solution. Maybe for now, it is sufficient enough to increase the condition to TimeUntilDeparture < 5

IncredibleHannes commented 3 years ago

see https://github.com/IncredibleHannes/TPF2-Timetables/pull/38

w43322 commented 3 years ago

Hi,

If the coroutine is now traversing through timetabled vehicles only, the performance impact should be minimal.

On maps with many vehicles, it is even more likely for the mod to miss a stopped vehicle. This is exactly the case with our testing environment.

IncredibleHannes commented 3 years ago

I don't want to get rid of the co-routine mechanic completely, as this would affect the performance on big maps. As a compromise, I increased the iterations from 8 to 20 in #43 It might be worth making this parameter configurable in the future so the player can decide themself how much of a performance impact they are willing to pay for higher timetable accuracy