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

Function GetDateFromStartTick

src/timetable_cmd.cpp:46–56  ·  view source on GitHub ↗

* Get a date from a given start tick of timetable. * @param start_tick The TimerGameTick::TickCounter when the timetable starts. * @return The date when we reach this tick. */

Source from the content-addressed store, hash-verified

44 * @return The date when we reach this tick.
45 */
46TimerGameEconomy::Date GetDateFromStartTick(TimerGameTick::TickCounter start_tick)
47{
48 /* Calculate the offset in ticks from the current counter tick. */
49 TimerGameTick::Ticks tick_offset = start_tick - TimerGameTick::counter;
50
51 /* Compensate for the current date_fract. */
52 tick_offset += TimerGameEconomy::date_fract;
53
54 /* Return the current date plus the offset in days. */
55 return TimerGameEconomy::date + (tick_offset / Ticks::DAY_TICKS);
56}
57
58/**
59 * Change/update a particular timetable entry.

Callers 2

CmdSetTimetableStartFunction · 0.85
DrawSummaryPanelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected