Page 1 of 1

Timetables on a 24-hour clock

Posted: 20 May 2018 10:15
by Maedhros
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. :)
Nutborough Transport, 22nd Oct 1943.png
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.
(532.85 KiB) Not downloaded yet
timetable-time.diff
Patch file, applies on top of 42b43c998.
(106.83 KiB) Downloaded 280 times

Re: Timetables on a 24-hour clock

Posted: 20 May 2018 20:22
by jfs
This is a simple and neat idea, it does make timetables more natural to think about.

It also makes me think of other ways the timetabling features could be improved UI-wise, maybe with a more graphical view that (tries to) collect stops at the same station together. That might make it easier to attempt to sync-up multiple vehicles on the same route, e.g. if you have a single-tracked railway. Something like this drawing perhaps:
timetabling-mockup.png
timetabling-mockup.png (4.53 KiB) Viewed 6326 times

Re: Timetables on a 24-hour clock

Posted: 23 May 2018 14:14
by Vanderbildt
Well if someone will do something new!
then:
Separate the timetable from the load.
So that on the same timetable different trains can run.
Example: the round needs 48 h starts at 00
the first train deliver Food and the 2. train, 24 h later, Goods

thanks
PS

and by the way, a nice thing will be presets for wait times in stations.
i dont like that the trains only stop a minute
may a passengertrain stop 5 min but a train full with goods or livestock never unload in 5 min they need little bit longer, or?

Re: Timetables on a 24-hour clock

Posted: 27 Jun 2018 12:01
by ino
So unless I am completely wrong, this is new patch, right? How is this different from the 24hr feature present in Departure board patch? (And whatever improvements to it that landed in JGR and Joker patch pack)

Re: Timetables on a 24-hour clock

Posted: 15 Mar 2021 21:06
by De Biel
Hi Maedhros, nice idea and thanks for making this patch. I am trying to compile the patched OpenTTD 1.8 sourcefile but get an error message:

3>strings.obj : error LNK2001: unresolved external symbol "void __fastcall ConvertDateToTimeInstant(int,struct TimeTableInstant *)" (?ConvertDateToTimeInstant@@YIXHPAUTimeTableInstant@@@Z)
3>strings.obj : error LNK2001: unresolved external symbol "void __fastcall ConvertDaysToTimeDuration(int,struct TimeTableDuration *)" (?ConvertDaysToTimeDuration@@YIXHPAUTimeTableDuration@@@Z)
3>timetable_gui.obj : error LNK2001: unresolved external symbol "int __fastcall ConvertTimeInstantToDate(struct TimeTableInstant const *)" (?ConvertTimeInstantToDate@@YIHPBUTimeTableInstant@@@Z)
3>timetable_gui.obj : error LNK2001: unresolved external symbol "void __fastcall ShowSetTimeWindow(struct Window *,int,int,void (__fastcall*)(struct Window const *,struct TimeTableInstant const *))" (?ShowSetTimeWindow@@YIXPAUWindow@@HHP6IXPBU1@PBUTimeTableInstant@@@Z@Z)

Do you maybe know about this issue or do you know where it possibly went wrong? I can't find it.

Re: Timetables on a 24-hour clock

Posted: 16 Mar 2021 07:37
by jfs
There is probably a source file that isn't getting compiled for one reason or another. Check that you got the project files (or makefiles) updated correctly to list all the source files.

Re: Timetables on a 24-hour clock

Posted: 16 Mar 2021 16:12
by De Biel
Thanks, I have found the reason. The new created .cpp and .h files were not listed in the .vcxproj file

Re: Timetables on a 24-hour clock

Posted: 17 Mar 2021 10:34
by Eddi
in these old versions, there should be a "projects/generate" script, that needs to be run to fill in the .vcxproj file

Re: Timetables on a 24-hour clock

Posted: 17 Mar 2021 20:52
by De Biel
ah thanks, that is easier than doing it manual, for the next time ; )