26 #include "../stdafx.h"
27 #include "../openttd.h"
31 #include "../vehicle_base.h"
32 #include "../linkgraph/linkgraph.h"
34 #include "../safeguards.h"
52 TimerGameEconomy::YearMonthDay ymd;
107 if (trigger == this->period.trigger) {
115 if (this->fired)
return;
117 if (trigger == this->period.trigger) {
128 if (_game_mode == GM_MENU)
return false;
152 for (
auto timer : timers) {
153 timer->Elapsed(TimerGameEconomy::DAY);
157 for (
auto timer : timers) {
158 timer->Elapsed(TimerGameEconomy::WEEK);
163 for (
auto timer : timers) {
164 timer->Elapsed(TimerGameEconomy::MONTH);
168 for (
auto timer : timers) {
169 timer->Elapsed(TimerGameEconomy::QUARTER);
175 for (
auto timer : timers) {
176 timer->Elapsed(TimerGameEconomy::YEAR);
198 if (period.priority == TimerGameEconomy::Priority::NONE)
return;
204 if (timer->period.trigger != period.trigger)
continue;
206 assert(timer->period.priority != period.priority);
static constexpr int DAYS_IN_ECONOMY_MONTH
Days in an economy month, when in wallclock timekeeping mode.
static constexpr int DAYS_IN_ECONOMY_YEAR
Days in an economy year, when in wallclock timekeeping mode.
void Elapsed(TElapsed count) override
Called by the timer manager to notify the timer that the given amount of time has elapsed.
A connected component of a link graph.
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.
static constexpr int MONTHS_IN_YEAR
months per year
static constexpr int DAYS_IN_YEAR
days per year
static constexpr TimerGame< struct Economy >::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 Date date
Current date in days (day counter).
static Year year
Current year, starting at 0.
static Month month
Current month (0..11).
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
static DateFract date_fract
Fractional part of the day.
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 ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
uint16_t DateFract
The fraction of a date we're in, i.e.
uint8_t Day
Type for the day of the month, note: 1 based, first day of a month is 1.
static Date CalendarConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
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.
static YearMonthDay CalendarConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
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.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
TimekeepingUnits timekeeping_units
time units to use for the game economy, either calendar or wallclock
EconomySettings economy
settings to change the economy
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition of Interval and OneShot timers.
Definition of the game-economy-timer.
Definition of the tick-based game-timer.