MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetStartTickFromDate

Function GetStartTickFromDate

src/timetable_cmd.cpp:29–39  ·  view source on GitHub ↗

* Get the TimerGameTick::TickCounter tick of a given date. * @param start_date The date when the timetable starts. * @return The first tick of this date. */

Source from the content-addressed store, hash-verified

27 * @return The first tick of this date.
28 */
29TimerGameTick::TickCounter GetStartTickFromDate(TimerGameEconomy::Date start_date)
30{
31 /* Calculate the offset in ticks from the current date. */
32 TimerGameTick::Ticks tick_offset = (start_date - TimerGameEconomy::date).base() * Ticks::DAY_TICKS;
33
34 /* Compensate for the current date_fract. */
35 tick_offset -= TimerGameEconomy::date_fract;
36
37 /* Return the current tick plus the offset. */
38 return TimerGameTick::counter + tick_offset;
39}
40
41/**
42 * Get a date from a given start tick of timetable.

Callers 2

OnClickMethod · 0.85
AfterLoadVehiclesPhase1Function · 0.85

Calls 1

baseMethod · 0.45

Tested by

no test coverage detected