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/>.
8 /** @file timer_game_economy.h Definition of the game-economy-timer */
10 #ifndef TIMER_GAME_ECONOMY_H
11 #define TIMER_GAME_ECONOMY_H
13 #include "../core/strong_typedef_type.hpp"
14 #include "timer_game_common.h"
17 * Timer that is increased every 27ms, and counts towards economy time units, expressed in days / months / years.
19 * For now, this is kept in sync with the calendar date, so the amount of days in a month depends on the month and year (leap-years).
20 * There are always 74 ticks in a day (and with 27ms, this makes 1 day 1.998 seconds).
22 * Economy time is used for the regular pace of the game, including:
23 * - Industry and house production/consumption
24 * - Industry production changes, closure, and spawning
26 * - Company age and periodical finance stats
27 * - Vehicle age and profit statistics, both individual and group
28 * - Vehicle aging, depreciation, reliability, and renewal
29 * - Payment intervals for running and maintenance costs, loan interest, etc.
30 * - Cargo payment "time" calculation
31 * - Local authority and station ratings change intervals
33 class TimerGameEconomy
: public TimerGame
<struct Economy
> {
35 static Year year
; ///< Current year, starting at 0.
36 static Month month
; ///< Current month (0..11).
37 static Date date
; ///< Current date in days (day counter).
38 static DateFract date_fract
; ///< Fractional part of the day.
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);
47 * Storage class for Economy time constants.
49 class EconomyTime
: public TimerGameConst
<struct Economy
> {
51 static constexpr int DAYS_IN_ECONOMY_YEAR
= 360; ///< Days in an economy year, when in wallclock timekeeping mode.
52 static constexpr int DAYS_IN_ECONOMY_MONTH
= 30; ///< Days in an economy month, when in wallclock timekeeping mode.
55 #endif /* TIMER_GAME_ECONOMY_H */