2
* This file is part of FreeRCT.
3
* FreeRCT 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
* FreeRCT 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 FreeRCT. If not, see <http://www.gnu.org/licenses/>.
8
/** @file dates.h Declarations for dates in the game. */
13
static const int TICK_COUNT_PER_DAY = 300; ///< Number of ticks in a day (stored in #Date::frac).
15
typedef uint32 CompressedDate; ///< Compressed date for easy transfer/storage.
17
/** Bits and sizes of the compressed date format. */
18
enum CompressedDateBits {
19
CDB_DAY_LENGTH = 5, ///< Length of the 'day' field in the compressed date.
20
CDB_MONTH_LENGTH = 4, ///< Length of the 'month' field in the compressed date.
21
CDB_YEAR_LENGTH = 7, ///< Length of the 'year' field in the compressed date.
22
CDB_FRAC_LENGTH = 10, ///< Length of the 'fraction' field in the compressed date.
24
CDB_DAY_START = 0, ///< Start bit of the 'day' field.
25
CDB_MONTH_START = CDB_DAY_START + CDB_DAY_LENGTH, ///< Start bit of the 'month' field.
26
CDB_YEAR_START = CDB_MONTH_START + CDB_MONTH_LENGTH, ///< Start bit of the 'year' field.
27
CDB_FRAC_START = CDB_YEAR_START + CDB_YEAR_LENGTH, ///< Start bit of the 'fraction' field.
30
/** %Date in the game. */
34
Date(int pday, int pmonth, int pyear, int pfrac = 0);
35
Date(CompressedDate cd);
37
Date &operator=(const Date &d);
44
CompressedDate Compress() const;
46
int GetNextMonth() const;
47
int GetPreviousMonth() const;
49
int day; ///< Day of the month, 1-based.
50
int month; ///< Month of the year, 1-based.
51
int year; ///< The current year, 1-based.
52
int frac; ///< Day fraction, 0-based.
56
void LoadDate(Loader &ldr);
57
void SaveDate(Saver &svr);
60
extern const int _days_per_month[13];