It's been a while since I last wrote any code for OpenTTD, but I couldn't stay away for ever. I've started playing again recently and remembered why I love this game but as always, there are things I want to fix.
Timetables have always been a bit difficult to use, especially when you have more than one timetable interacting. Although the only time unit available by default in OpenTTD is the date, trying to do mental arithmetic with dates to figure out how what the date will be when you add 47 days to another date just isn't easy.
It's not a new idea, but I decided to see if I could display timetables on a 24-hour clock rather than using dates, and this patch is the result. The basic idea is to reinterpret the date as a time by making one minute on the clock equal to one day from the date. The result is that a journey that takes 67 days is now shown as taking 1 hour, 7 minutes, and all the arrival/departure times are shown as times. The current time is also shown next to the date in the status bar at the bottom of the window. Because I didn't want to add anything to the save-game, the first midnight is the 1st Jan, 1 AD and it rolls round every 1440 days (almost 4 years) so the actual time when you start the game will look fairly arbitrary.
I wasn't sure about how this would work when you have timetables of different lengths, but decided that that's not necessarily a limitation of the in-game timetables; real rail companies have the same problem. Like in real life if you want something to happen at the same time each hour you have to add padding at the end of the line so that the journey is a multiple of 60 minutes (or days, without this patch). Then if your timetable takes 4 hours you can run 4 trains on it, evenly spaced, and you'll get an hourly timetable. If you do that to all your routes you end up with a situation where the same thing happens every hour and you can ensure things don't get blocked at junctions or at the entrances/exits to stations.
Of course you don't have to stick to an hourly service, you can have one every 2 hours, 30 minutes, 15 minutes etc. Or if your timetable doesn't interact with any others you can keep it at 1 hour, 42 minutes long if you want to.
It turns out that you don't need to change any of the mechanics of how timetables work to make this possible, you just have to change the way they are displayed. The patch changes the 'show timetables in days/ticks' setting to add a 'show as a 24 hour clock' option but it's just a display change so it doesn't change the save-game at all. If you're playing on multi-player you can all have different settings if you want and what you do won't affect anyone else.
The patch is more of a proof-of-concept than final polished code, but I thought I'd let it out into the world to see what you all think of it.
File comment: Timetables with times. These three trains are all running on separate timetables but each is part of an hourly service so this same scene will be repeated in 1 hour/60 days time and they never get in each others' way at the junction.
Nutborough Transport, 22nd Oct 1943.png [532.85 KiB]
Not downloaded yet
File comment: Patch file, applies on top of 42b43c998.
timetable-time.diff [106.83 KiB]
Downloaded 3 times