OpenTTD Source  20240917-master-g9ab0a47812
timer_game_economy.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_ECONOMY_H
11 #define TIMER_GAME_ECONOMY_H
12 
13 #include "../core/strong_typedef_type.hpp"
14 #include "timer_game_common.h"
15 
33 class TimerGameEconomy : public TimerGame<struct Economy> {
34 public:
35  static Year year;
36  static Month month;
37  static Date date;
39 
40  static YearMonthDay ConvertDateToYMD(Date date);
41  static Date ConvertYMDToDate(Year year, Month month, Day day);
42  static void SetDate(Date date, DateFract fract);
43  static bool UsingWallclockUnits(bool newgame = false);
44 };
45 
49 class EconomyTime : public TimerGameConst<struct Economy> {
50 public:
51  static constexpr int DAYS_IN_ECONOMY_YEAR = 360;
52  static constexpr int DAYS_IN_ECONOMY_MONTH = 30;
53 };
54 
55 #endif /* TIMER_GAME_ECONOMY_H */
TimerGameEconomy::ConvertYMDToDate
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Definition: timer_game_economy.cpp:66
TimerGameEconomy::month
static Month month
Current month (0..11).
Definition: timer_game_economy.h:36
timer_game_common.h
TimerGame
Template class for all TimerGame based timers.
Definition: timer_game_common.h:31
TimerGameEconomy::date_fract
static DateFract date_fract
Fractional part of the day.
Definition: timer_game_economy.h:38
EconomyTime
Storage class for Economy time constants.
Definition: timer_game_economy.h:49
TimerGameEconomy::UsingWallclockUnits
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Definition: timer_game_economy.cpp:97
TimerGameConst
Template class for time constants shared by both Calendar and Economy time.
Definition: timer_game_common.h:147
EconomyTime::DAYS_IN_ECONOMY_YEAR
static constexpr int DAYS_IN_ECONOMY_YEAR
Days in an economy year, when in wallclock timekeeping mode.
Definition: timer_game_economy.h:51
TimerGameEconomy::ConvertDateToYMD
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
Definition: timer_game_economy.cpp:46
TimerGameEconomy::year
static Year year
Current year, starting at 0.
Definition: timer_game_economy.h:35
TimerGameEconomy::SetDate
static void SetDate(Date date, DateFract fract)
Set the date.
Definition: timer_game_economy.cpp:81
TimerGame< struct Economy >::DateFract
uint16_t DateFract
The fraction of a date we're in, i.e.
Definition: timer_game_common.h:38
TimerGame< struct Economy >::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
EconomyTime::DAYS_IN_ECONOMY_MONTH
static constexpr int DAYS_IN_ECONOMY_MONTH
Days in an economy month, when in wallclock timekeeping mode.
Definition: timer_game_economy.h:52
TimerGameEconomy
Timer that is increased every 27ms, and counts towards economy time units, expressed in days / months...
Definition: timer_game_economy.h:33
TimerGame< struct Economy >::Month
uint8_t Month
Type for the month, note: 0 based, i.e.
Definition: timer_game_common.h:44
TimerGameEconomy::date
static Date date
Current date in days (day counter).
Definition: timer_game_economy.h:37