OpenTTD Source: src/timer/timer_game_calendar.h Source File

OpenTTD Source 14.1

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 <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef TIMER_GAME_CALENDAR_H
11 #define TIMER_GAME_CALENDAR_H
12
13 #include "../stdafx.h"
14 #include "../core/strong_typedef_type.hpp"
15 #include "timer_game_common.h"
16
30 class TimerGameCalendar : public TimerGame<struct Calendar> {
31 public:
32 static Year year;
33 static Month month;
34 static Date date;
35 static DateFract date_fract;
36 static uint16_t sub_date_fract;
37
38 static YearMonthDay ConvertDateToYMD(Date date);
39 static Date ConvertYMDToDate(Year year, Month month, Day day);
40 static void SetDate(Date date, DateFract fract);
41 };
42
46 class CalendarTime : public TimerGameConst<struct Calendar> {
47 public:
48 static constexpr int DEF_MINUTES_PER_YEAR = 12;
49 static constexpr int FROZEN_MINUTES_PER_YEAR = 0;
50 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.
51 };
52
53 #endif /* TIMER_GAME_CALENDAR_H */
TimerGameCalendar::date_fract
static DateFract date_fract
Fractional part of the day.
Definition: timer_game_calendar.h:35
timer_game_common.h
TimerGame
Template class for all TimerGame based timers.
Definition: timer_game_common.h:31
TimerGameCalendar::sub_date_fract
static uint16_t sub_date_fract
Subpart of date_fract that we use when calendar days are slower than economy days.
Definition: timer_game_calendar.h:36
TimerGameConst
Template class for time constants shared by both Calendar and Economy time.
Definition: timer_game_common.h:147
TimerGameCalendar
Timer that is increased every 27ms, and counts towards ticks / days / months / years.
Definition: timer_game_calendar.h:30
TimerGameCalendar::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: timer_game_calendar.cpp:55
TimerGameCalendar::ConvertDateToYMD
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
Definition: timer_game_calendar.cpp:42
TimerGameCalendar::month
static Month month
Current month (0..11).
Definition: timer_game_calendar.h:33
TimerGameCalendar::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition: timer_game_calendar.cpp:66
TimerGame< struct Calendar >::DateFract
uint16_t DateFract
The fraction of a date we're in, i.e.
Definition: timer_game_common.h:38
TimerGame< struct Calendar >::Day
uint8_t Day
Type for the day of the month, note: 1 based, first day of a month is 1.
Definition: timer_game_common.h:46
CalendarTime
Storage class for Calendar time constants.
Definition: timer_game_calendar.h:46
TimerGameCalendar::date
static Date date
Current date in days (day counter).
Definition: timer_game_calendar.h:34
TimerGame< struct Calendar >::Month
uint8_t Month
Type for the month, note: 0 based, i.e.
Definition: timer_game_common.h:44
TimerGameCalendar::year
static Year year
Current year, starting at 0.
Definition: timer_game_calendar.h:32