diff --git a/economy.c b/economy.c index 0b63c3bf65..b25e13cfad 100644 --- a/economy.c +++ b/economy.c @@ -26,8 +26,8 @@ uint GetMaskOfAllowedCurrencies(void) for (i = 0; i != lengthof(_currency_specs); i++) { uint16 to_euro = _currency_specs[i].to_euro; if (i == 23) mask |= (1 << 23); // always allow custom currency - if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= (to_euro-1920)) continue; - if (_cur_year < (2000-1920) && (to_euro == CF_ISEURO)) continue; + if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= (to_euro-MAX_YEAR_BEGIN_REAL)) continue; + if (_cur_year < (2000-MAX_YEAR_BEGIN_REAL) && (to_euro == CF_ISEURO)) continue; mask |= (1 << i); } return mask; @@ -37,7 +37,7 @@ void CheckSwitchToEuro(void) { if (_currency_specs[_opt.currency].to_euro != CF_NOEURO && _currency_specs[_opt.currency].to_euro != CF_ISEURO && - _cur_year >= (_currency_specs[_opt.currency].to_euro-1920)) { + _cur_year >= (_currency_specs[_opt.currency].to_euro-MAX_YEAR_BEGIN_REAL)) { _opt.currency = 2; // this is the index of euro above. AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0); } diff --git a/graph_gui.c b/graph_gui.c index 6a277f3869..c8d0b63e4a 100644 --- a/graph_gui.c +++ b/graph_gui.c @@ -142,7 +142,7 @@ static void DrawGraph(GraphDrawer *gw) x = gw->left + 44; y = gw->top + gw->height + 1; j = gw->month; - k = gw->year + 1920; + k = gw->year + MAX_YEAR_BEGIN_REAL; i = gw->num_on_x_axis;assert(i>0); do { SetDParam(2, k); diff --git a/main_gui.c b/main_gui.c index 2f21e7aef3..82136abdaf 100644 --- a/main_gui.c +++ b/main_gui.c @@ -25,7 +25,7 @@ /* Min/Max date for scenario editor */ -static const uint MinDate = 0; // 1920-01-01 +static const uint MinDate = 0; // 1920-01-01 (MAX_YEAR_BEGIN_REAL) static const uint MaxDate = 29220; // 2000-01-01 extern void DoTestSave(); diff --git a/misc.c b/misc.c index 8e779bcb25..578b9b4266 100644 --- a/misc.c +++ b/misc.c @@ -443,7 +443,7 @@ uint ConvertYMDToDay(uint year, uint month, uint day) } // convert a date on the form -// 1920 - 2090 +// 1920 - 2090 (MAX_YEAR_END_REAL) // 192001 - 209012 // 19200101 - 20901231 // or if > 2090 and below 65536, treat it as a daycount @@ -452,7 +452,7 @@ uint ConvertIntDate(uint date) { uint year, month = 0, day = 1; - if (IS_INT_INSIDE(date, 1920, 2090 + 1)) { + if (IS_INT_INSIDE(date, 1920, MAX_YEAR_END_REAL + 1)) { year = date - 1920; } else if (IS_INT_INSIDE(date, 192001, 209012+1)) { month = date % 100 - 1; @@ -700,10 +700,10 @@ void IncreaseDate() NetworkServerYearlyLoop(); #endif /* ENABLE_NETWORK */ - /* check if we reached 2090, that's the maximum year. */ - if (_cur_year == 171) { + /* check if we reached 2090 (MAX_YEAR_END_REAL), that's the maximum year. */ + if (_cur_year == (MAX_YEAR_END + 1)) { Vehicle *v; - _cur_year = 170; + _cur_year = MAX_YEAR_END; _date = 62093; FOR_ALL_VEHICLES(v) { v->date_of_last_service -= 365; // 1 year is 365 days long diff --git a/network_gui.c b/network_gui.c index fb266a190b..0e9893c5ce 100644 --- a/network_gui.c +++ b/network_gui.c @@ -746,7 +746,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e) DeleteName(str); y += 10; - SetDParam(0, _network_player_info[_selected_company_item].inaugurated_year + 1920); + SetDParam(0, _network_player_info[_selected_company_item].inaugurated_year + MAX_YEAR_BEGIN_REAL); DrawString(x, y, STR_NETWORK_INAUGURATION_YEAR, 2); // inauguration year y += 10; diff --git a/network_server.c b/network_server.c index b7bc8b3ed7..dfa9b0e9df 100644 --- a/network_server.c +++ b/network_server.c @@ -1281,10 +1281,10 @@ extern void SwitchMode(int new_mode); /* Check if we want to restart the map */ static void NetworkCheckRestartMap() { - if (_network_restart_game_date != 0 && _cur_year + 1920 >= _network_restart_game_date) { + if (_network_restart_game_date != 0 && _cur_year + MAX_YEAR_BEGIN_REAL >= _network_restart_game_date) { _docommand_recursive = 0; - DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year + 1920); + DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year + MAX_YEAR_BEGIN_REAL); _random_seeds[0][0] = Random(); _random_seeds[0][1] = InteractiveRandom(); diff --git a/oldloader.c b/oldloader.c index 296271968f..e8c93b62a9 100644 --- a/oldloader.c +++ b/oldloader.c @@ -941,7 +941,7 @@ static void FixPlayer(Player *n, OldPlayer *o, int num, byte town_name_type) FixEconomy(&n->cur_economy, &o->economy[0]); for(i=0; i!=24; i++) FixEconomy(&n->old_economy[i], &o->economy[i+1]); - n->inaugurated_year = o->inaugurated_date - 1920; + n->inaugurated_year = o->inaugurated_date - MAX_YEAR_BEGIN_REAL; n->last_build_coordinate = o->last_build_coordinate; n->num_valid_stat_ent = o->num_valid_stat_ent; diff --git a/settings_gui.c b/settings_gui.c index 120dfc363f..7cd2d01f0b 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -682,7 +682,7 @@ static const PatchEntry _patches_economy[] = { {PE_UINT8, 0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT, "snow_line_height", &_patches.snow_line_height, 2, 13, 1, NULL}, {PE_INT32, PF_NOCOMMA, STR_CONFIG_PATCHES_COLORED_NEWS_DATE, "colored_new_data", &_patches.colored_news_date, 1900, 2200, 5, NULL}, - {PE_INT32, PF_NOCOMMA, STR_CONFIG_PATCHES_STARTING_DATE, "starting_date", &_patches.starting_date, 1920,2100, 1, NULL}, + {PE_INT32, PF_NOCOMMA, STR_CONFIG_PATCHES_STARTING_DATE, "starting_date", &_patches.starting_date, 1920, MAX_YEAR_END_REAL, 1, NULL}, {PE_BOOL, 0, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, "smooth_economy", &_patches.smooth_economy, 0, 0, 0, NULL}, {PE_BOOL, 0, STR_CONFIG_PATCHES_ALLOW_SHARES, "allow_shares", &_patches.allow_shares, 0, 0, 0, NULL}, @@ -1403,7 +1403,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) } else { if(_currency_specs[23].to_euro == 0) _currency_specs[23].to_euro = 2000; else _currency_specs[23].to_euro++; - _currency_specs[23].to_euro = min(2090, _currency_specs[23].to_euro); + _currency_specs[23].to_euro = min(MAX_YEAR_END_REAL, _currency_specs[23].to_euro); WP(w,def_d).data_1 = (1 << (line * 2 + 1)); } } else { // enter text @@ -1452,7 +1452,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e) break; case 4: val = atoi(b); - val = clamp(val, 1999, 2090); + val = clamp(val, 1999, MAX_YEAR_END_REAL); if (val == 1999) val = 0; _currency_specs[23].to_euro = val; break; diff --git a/strings.c b/strings.c index ea2c8b3456..b5f6956d53 100644 --- a/strings.c +++ b/strings.c @@ -243,7 +243,7 @@ static byte *FormatYmdString(byte *buff, uint16 number) memcpy(buff, GetStringPtr(STR_0162_JAN + ymd.month), 4); buff[3] = ' '; - return FormatNoCommaNumber(buff+4, ymd.year + 1920); + return FormatNoCommaNumber(buff+4, ymd.year + MAX_YEAR_BEGIN_REAL); } static byte *FormatMonthAndYear(byte *buff, uint16 number) @@ -256,7 +256,7 @@ static byte *FormatMonthAndYear(byte *buff, uint16 number) for(src = GetStringPtr(STR_MONTH_JAN + ymd.month); (*buff++=*src++) != 0;) {} buff[-1] = ' '; - return FormatNoCommaNumber(buff, ymd.year + 1920); + return FormatNoCommaNumber(buff, ymd.year + MAX_YEAR_BEGIN_REAL); } uint GetCurrentCurrencyRate() { diff --git a/ttd.h b/ttd.h index d85bd9aae0..4b6a0190a0 100644 --- a/ttd.h +++ b/ttd.h @@ -42,6 +42,9 @@ typedef struct YearMonthDay { * * 1 day is thus about 2 seconds (74*27 = 1998) on a machine that can run OpenTTD normally */ #define DAY_TICKS 74 +#define MAX_YEAR_BEGIN_REAL 1920 +#define MAX_YEAR_END_REAL 2090 +#define MAX_YEAR_END 170 #include "macros.h"