kaomoneus / OpenTTD

OpenTTD is an open source simulation game based upon Transport Tycoon Deluxe
https://www.openttd.org/
Other
4 stars 1 forks source link

[Bug]: Days set in time table appear one day shorter than typed #16

Open KeithWM opened 3 weeks ago

KeithWM commented 3 weeks ago

Version of OpenTTD

OpenTTD 13.4-slowpace-1.3.1 (on MacOS Monterrey 12.7.6)

Expected result

When setting a timetable entry to a particular value, I expect the result to be stored as that value.

Actual result

Each value is stored as 1 less than I set.

Steps to reproduce

  1. Start game with a game year lasting one week
  2. Create a vehicle with orders
  3. Set the time for a stop or travel to 5 minutes
  4. Observe that a "4" appears in the timetable.

FYI: If I set it to 1, I see a 0 appear, but 34 ticks if I switch to showing ticks. If I increase this to 35 ticks, and then switch back to showing the time table in minutes, it does show 1. It might just be a rounding or integer division issue. If I set it to 2 minutes, I see a 1 appear, but 69 ticks. Again, changing it to 70 does update the minutes to 2.

KeithWM commented 2 weeks ago

With a game in "daily" mode I have a related issue that setting timetable entries in minutes, results in a total timetable length that is not equal to the sum of the minutes. In "hourly" mode, the issue with the "off by one" only occurs for smaller numbers of hours in the timetable.

I'm not sure how exactly the scaling of time is implemented, but I suspect there should be a slightly different scaling to avoid non-divisble integers being divided. E.g. I can imagine that in the switch from Vanilla pace with "day" as the unit to Hourly with "hour" as the unit, we are effectively doing something like 74 4 / 24 (vanilla ticks times scaling divided by unit switch). Perhaps the best one can do here is introduce the "3 hourly" where 74 4 * 3 / 24 = 37 is exact.

Similarly for daily 74 (4 24) / (24 60) = 74 4 / 60 is also not exact. English does not have a convenient word for "quarter-hour" (kwartier in Dutch, Viertelstunde in German), but that time unit would allow for an exact match as 74 (4 24) / (24 4) = 74. Then for weekly 74 (4 24 7) / (24 60) = 74 28 / 60 is also not exact. Here making the play-time week 7.5 days helps by achieving 74 (4 24 7.5) / (24 60) = 37 exactly.

I could of course be completely off in my assumptions on what is happening here, and I sincerely apologize if my suggestions do you any injustice.

KeithWM commented 2 weeks ago

So then I discovered the custom mode... ...I started a game with 720 minutes, following my 7.5 day week plan and that works like a charm!

And I can recreate the three-hourly approach successfully too, but for 24 hours (even for 21 hours) the choice of the "minute" unit of time is problematic.