24#include "../openttd.h"
27#include "../vehicle_base.h"
29#include "../safeguards.h"
80 if (trigger == this->period.trigger) {
88 if (this->fired)
return;
90 if (trigger == this->period.trigger) {
101 if (_game_mode == GM_MENU)
return false;
142 for (
auto timer : timers) {
143 timer->Elapsed(TimerGameCalendar::DAY);
147 for (
auto timer : timers) {
148 timer->Elapsed(TimerGameCalendar::MONTH);
153 for (
auto timer : timers) {
154 timer->Elapsed(TimerGameCalendar::YEAR);
174 if (period.priority == TimerGameCalendar::Priority::NONE)
return;
180 if (timer->period.trigger != period.trigger)
continue;
182 assert(timer->period.priority != period.priority);
void Elapsed(TElapsed count) override
Called by the timer manager to notify the timer that the given amount of time has elapsed.
static constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
void Elapsed(TElapsed count) override
Called by the timer manager to notify the timer that the given amount of time has elapsed.
Timer that is increased every 27ms, and counts towards ticks / days / months / years.
static uint16_t sub_date_fract
Subpart of date_fract that we use when calendar days are slower than economy days.
static Month month
Current month (0..11).
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
static void SetDate(Date date, DateFract fract)
Set the date.
static Date date
Current date in days (day counter).
static Year year
Current year, starting at 0.
static DateFract date_fract
Fractional part of the day.
static constexpr int DAYS_IN_YEAR
days per year
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
static constexpr int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
static YearMonthDay CalendarConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
uint16_t DateFract
The fraction of a date we're in, i.e.
static Date CalendarConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
uint8_t Day
Type for the day of the month, note: 1 based, first day of a month is 1.
uint8_t Month
Type for the month, note: 0 based, i.e.
static constexpr bool IsLeapYear(Year year)
Checks whether the given year is a leap year or not.
The TimerManager manages a single Timer-type.
static std::set< BaseTimer< TTimerType > *, base_timer_sorter > & GetTimers()
Singleton list, to store all the active timers.
static bool Elapsed(TElapsed value)
Called when time for this timer elapsed.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
uint16_t minutes_per_calendar_year
minutes per calendar year. Special value 0 means that calendar time is frozen.
EconomySettings economy
settings to change the economy
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.