OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
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);
A connected component of a link graph.
static std::set< BaseTimer< TTimerType > *, base_timer_sorter > & GetTimers()
Singleton list, to store all the active timers.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static Month month
Current month (0..11).
TimekeepingUnits timekeeping_units
time units to use for the game economy, either calendar or wallclock
static DateFract date_fract
Fractional part of the day.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
static constexpr int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
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.
void Elapsed(TElapsed count) override
Called by the timer manager to notify the timer that the given amount of time has elapsed.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
EconomySettings economy
settings to change the economy
The TimerManager manages a single Timer-type.
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 bool Elapsed(TElapsed value)
Called when time for this timer elapsed.
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static Year year
Current year, starting at 0.
static constexpr int MONTHS_IN_YEAR
months per year
static Date CalendarConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static constexpr bool IsLeapYear(Year year)
Checks whether the given year is a leap year or not.
static void SetDate(Date date, DateFract fract)
Set the 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 constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
static constexpr int DAYS_IN_ECONOMY_MONTH
Days in an economy month, when in wallclock timekeeping mode.
static constexpr int DAYS_IN_YEAR
days per year
static YearMonthDay CalendarConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
uint8_t Month
Type for the month, note: 0 based, i.e.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
static Date date
Current date in days (day counter).