OpenTTD Source
20241120-master-g6d3adc6169
|
Timer that is increased every 27ms, and counts towards ticks / days / months / years. More...
#include <timer_game_calendar.h>
Static Public Member Functions | |
static YearMonthDay | ConvertDateToYMD (Date date) |
Converts a Date to a Year, Month & Day. More... | |
static Date | ConvertYMDToDate (Year year, Month month, Day day) |
Converts a tuple of Year, Month and Day to a Date. More... | |
static void | SetDate (Date date, DateFract fract) |
Set the date. More... | |
Static Public Member Functions inherited from TimerGame< struct Calendar > | |
static constexpr bool | IsLeapYear (Year year) |
Checks whether the given year is a leap year or not. More... | |
static YearMonthDay | CalendarConvertDateToYMD (Date date) |
Converts a Date to a Year, Month & Day. More... | |
static Date | CalendarConvertYMDToDate (Year year, Month month, Day day) |
Converts a tuple of Year, Month and Day to a Date. More... | |
static constexpr Year | DateToYear (Date date) |
Calculate the year of a given date. More... | |
static constexpr Date | DateAtStartOfYear (Year year) |
Calculate the date of the first day of a given year. More... | |
Static Public Attributes | |
static Year | year = {} |
Current year, starting at 0. More... | |
static Month | month = {} |
Current month (0..11). | |
static Date | date = {} |
Current date in days (day counter). | |
static DateFract | date_fract = {} |
Fractional part of the day. | |
static uint16_t | sub_date_fract = {} |
Subpart of date_fract that we use when calendar days are slower than economy days. | |
Additional Inherited Members | |
Public Types inherited from TimerGame< struct Calendar > | |
enum | Trigger |
enum | Priority |
using | Date = StrongType::Typedef< int32_t, DateTag< struct Calendar >, StrongType::Compare, StrongType::Integer > |
using | DateFract = uint16_t |
The fraction of a date we're in, i.e. More... | |
using | Year = StrongType::Typedef< int32_t, struct YearTag< struct Calendar >, StrongType::Compare, StrongType::Integer > |
using | Month = uint8_t |
Type for the month, note: 0 based, i.e. More... | |
using | Day = uint8_t |
Type for the day of the month, note: 1 based, first day of a month is 1. | |
using | TElapsed = uint |
Timer that is increased every 27ms, and counts towards ticks / days / months / years.
The amount of days in a month depends on the month and year (leap-years). There are always 74 ticks in a day (and with 27ms, this makes 1 day 1.998 seconds).
Calendar time is used for technology and time-of-year changes, including:
Definition at line 30 of file timer_game_calendar.h.
|
static |
Converts a Date to a Year, Month & Day.
date | the date to convert from |
Definition at line 42 of file timer_game_calendar.cpp.
References TimerGame< struct Calendar >::CalendarConvertDateToYMD(), and date.
Referenced by ClickChangeDateCheat(), GetGlobalVariable(), GetSnowLine(), SetDate(), SetYearEngineAgingStops(), StartupEngines(), SurveyRecentNews(), and SurveyTimers().
|
static |
Converts a tuple of Year, Month and Day to a Date.
year | is a number between 0..MAX_YEAR |
month | is a number between 0..11 |
day | is a number between 1..31 |
Definition at line 55 of file timer_game_calendar.cpp.
References TimerGame< struct Calendar >::CalendarConvertYMDToDate(), month, and year.
Referenced by ClickChangeDateCheat(), GetGlobalVariable(), LoadNewGRF(), ServerNetworkAdminSocketHandler::SendWelcome(), SetStartingYear(), and StartupEngines().
|
static |
Set the date.
date | New date |
fract | The number of ticks that have passed on this date. |
Definition at line 66 of file timer_game_calendar.cpp.
References ConvertDateToYMD(), date, date_fract, Ticks::DAY_TICKS, month, and year.
Referenced by ClickChangeDateCheat(), and SetStartingYear().
|
static |
Current year, starting at 0.
Calendar time is used for technology and time-of-year changes, including:
Definition at line 32 of file timer_game_calendar.h.
Referenced by CalendarEnginesMonthlyLoop(), CheckBridgeAvailability(), ClickChangeDateCheat(), ConvertYMDToDate(), GetGlobalVariable(), GetMaskOfAllowedCurrencies(), VehicleScopeResolver::GetVariable(), AirportSpec::IsAvailable(), LoadNewGRF(), NetworkCheckRestartMapYear(), NewsItem::NewsItem(), ResetSignalVariant(), and SetDate().