OpenTTD Source 20251213-master-g1091fa6071
timer_game_calendar.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef TIMER_GAME_CALENDAR_H
11#define TIMER_GAME_CALENDAR_H
12
13#include "timer_game_common.h"
14
28class TimerGameCalendar : public TimerGame<struct Calendar> {
29public:
30 static Year year;
31 static Month month;
32 static Date date;
34 static uint16_t sub_date_fract;
36 static YearMonthDay ConvertDateToYMD(Date date);
38 static void SetDate(Date date, DateFract fract);
39};
40
44class CalendarTime : public TimerGameConst<struct Calendar> {
45public:
46 static constexpr int DEF_MINUTES_PER_YEAR = 12;
47 static constexpr int FROZEN_MINUTES_PER_YEAR = 0;
48 static constexpr int MAX_MINUTES_PER_YEAR = 10080; // One week of real time. The actual max that doesn't overflow TimerGameCalendar::sub_date_fract is 10627, but this is neater.
49};
50
51#endif /* TIMER_GAME_CALENDAR_H */
Storage class for Calendar time constants.
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.
Template class for time constants shared by both Calendar and Economy time.
Template class for all TimerGame based timers.
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.
uint8_t Month
Type for the month, note: 0 based, i.e.
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition of the common class inherited by both calendar and economy timers.