IncredibleHannes / TPF2-Timetables

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

Timetables (and Unbouncing) are sometimes not working properly. #7

Closed lenderom closed 3 years ago

lenderom commented 3 years ago

I'm using the mod on a large map and sometimes the trains on the line are waiting but sometimes they just irgnore it. Additionally i mentioned that if are train is waiting the "stop mode" of the train releases some seconds after the planned departue (5-10s). I don't know if this is a usual behavior. Is there a good way for debugging this to see why it works sometimes and why it doesn't?

IncredibleHannes commented 3 years ago

As @Grisu118 in his pull request already explained, this is due to the game only checking a certain number of vehicles each game tick (I believe it's currently 10) in order to keep performance stable. I was expecting that these parameters needed some tweaking, later on, to balance that the mod is stopping the vehicles at the right time, not misses any vehicles and doesn't affect performance too much.

lenderom commented 3 years ago

I actually never had a look on how mods for TPF2 are written. But the issue you described seems like the script is checking every vehicle on the map. Isn't it possible to just check the vehicle for wich the timetable function is activated. I don't think the most people will give each truck line a dedicated timetable.

`function timetable.waitingRequired(vehicle)

if timetableHelper.getTimeUntilDeparture(vehicle)`

I dont't know how the TPF2 mechanics work but could we add a condition in the timetable.waitingRequierd to check if the timetable function is activated?

Because the problem I experienced was with the function only on one line enabled with 6 trains. Well the map has about 300 other verhicles but they dont use the timetable function

lenderom commented 3 years ago

Ah silly me there is already such a condition...

IncredibleHannes commented 3 years ago

It might still be possible to save some computations. I will make a new Issue for that. -> https://github.com/IncredibleHannes/TPF2-Timetables/issues/16