|
1 /* $Id$ */ |
|
2 |
|
3 /** @file date_type.h Types related to the dates in OpenTTD. */ |
|
4 |
|
5 #ifndef DATE_TYPE_H |
|
6 #define DATE_TYPE_H |
|
7 |
|
8 /** |
|
9 * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On |
|
10 * an overflow the new day begun and 65535 / 885 = 74. |
|
11 * 1 tick is approximately 30 ms. |
|
12 * 1 day is thus about 2 seconds (74 * 30 = 2220) on a machine that can run OpenTTD normally |
|
13 */ |
|
14 #define DAY_TICKS 74 |
|
15 |
|
16 /* |
|
17 * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are |
|
18 * primarily used for loading newgrf and savegame data and returning some |
|
19 * newgrf (callback) functions that were in the original (TTD) inherited |
|
20 * format, where '_date == 0' meant that it was 1920-01-01. |
|
21 */ |
|
22 |
|
23 /** The minimum starting year/base year of the original TTD */ |
|
24 #define ORIGINAL_BASE_YEAR 1920 |
|
25 /** The maximum year of the original TTD */ |
|
26 #define ORIGINAL_MAX_YEAR 2090 |
|
27 |
|
28 /** |
|
29 * The offset in days from the '_date == 0' till |
|
30 * 'ConvertYMDToDate(ORIGINAL_BASE_YEAR, 0, 1)' |
|
31 */ |
|
32 #define DAYS_TILL_ORIGINAL_BASE_YEAR (365 * ORIGINAL_BASE_YEAR + ORIGINAL_BASE_YEAR / 4 - ORIGINAL_BASE_YEAR / 100 + ORIGINAL_BASE_YEAR / 400) |
|
33 |
|
34 /* The absolute minimum & maximum years in OTTD */ |
|
35 #define MIN_YEAR 0 |
|
36 /* MAX_YEAR, nicely rounded value of the number of years that can |
|
37 * be encoded in a single 32 bits date, about 2^31 / 366 years. */ |
|
38 #define MAX_YEAR 5000000 |
|
39 |
|
40 typedef int32 Date; |
|
41 typedef uint16 DateFract; |
|
42 |
|
43 typedef int32 Year; |
|
44 typedef uint8 Month; |
|
45 typedef uint8 Day; |
|
46 |
|
47 struct YearMonthDay { |
|
48 Year year; |
|
49 Month month; |
|
50 Day day; |
|
51 }; |
|
52 |
|
53 static const Year INVALID_YEAR = -1; |
|
54 static const Date INVALID_DATE = -1; |
|
55 |
|
56 #endif /* DATE_TYPE_H */ |