changeset 4293:d6fcf4c20a29 draft

(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920 -Codechange: store all year related variables that are _not_ stored in a savegame/transported over the network in the same format as _cur_year
author rubidium <rubidium@openttd.org>
date Wed, 16 Aug 2006 11:39:55 +0000
parents 68438568fe64
children 938a0db91fe5
files aircraft_cmd.c aircraft_gui.c bridge.h currency.c date.c disaster_cmd.c economy.c engine.c graph_gui.c industry_cmd.c misc_gui.c network.h network_server.c newgrf.c newgrf_engine.c newgrf_spritegroup.c news_gui.c openttd.c openttd.h player_gui.c players.c roadveh_cmd.c roadveh_gui.c settings.c ship_cmd.c ship_gui.c strings.c table/town_land.h train_cmd.c train_gui.c tunnelbridge_cmd.c variables.h
diffstat 32 files changed, 211 insertions(+), 203 deletions(-) [+]
line wrap: on
line diff
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -362,7 +362,7 @@
 		v->service_interval = _patches.servint_aircraft;
 
 		v->date_of_last_service = _date;
-		v->build_year = u->build_year = _cur_year;
+		v->build_year = u->build_year = _cur_year - BASE_YEAR;
 
 		v->cur_image = u->cur_image = 0xEA0;
 
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -66,7 +66,7 @@
 	y += 10;
 
 	/* Design date - Life length */
-	SetDParam(0, BASE_YEAR + ymd.year);
+	SetDParam(0, ymd.year);
 	SetDParam(1, e->lifelength);
 	DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
 	y += 10;
--- a/bridge.h
+++ b/bridge.h
@@ -12,7 +12,7 @@
 /** Struct containing information about a single bridge type
  */
 typedef struct Bridge {
-	byte avail_year;     ///< the year in which the bridge becomes available
+	Year avail_year;     ///< the year in which the bridge becomes available
 	byte min_length;     ///< the minimum length of the bridge (not counting start and end tile)
 	byte max_length;     ///< the maximum length of the bridge (not counting start and end tile)
 	uint16 price;        ///< the relative price of the bridge
--- a/currency.c
+++ b/currency.c
@@ -81,8 +81,8 @@
 	for (i = 0; i != lengthof(_currency_specs); i++) {
 		uint16 to_euro = _currency_specs[i].to_euro;
 
-		if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && BASE_YEAR + _cur_year >= to_euro) continue;
-		if (to_euro == CF_ISEURO && BASE_YEAR + _cur_year < 2000) continue;
+		if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= to_euro) continue;
+		if (to_euro == CF_ISEURO && _cur_year < 2000) continue;
 		mask |= (1 << i);
 	}
 	mask |= (1 << CUSTOM_CURRENCY_ID); // always allow custom currency
@@ -94,7 +94,7 @@
 {
 	if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
 			_currency_specs[_opt.currency].to_euro != CF_ISEURO &&
-			BASE_YEAR + _cur_year >= _currency_specs[_opt.currency].to_euro) {
+			_cur_year >= _currency_specs[_opt.currency].to_euro) {
 		_opt.currency = 2; // this is the index of euro above.
 		AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0);
 	}
--- a/date.c
+++ b/date.c
@@ -88,7 +88,7 @@
 		if (rem >= 31 + 28) rem++;
 	}
 
-	ymd->year = yr;
+	ymd->year = BASE_YEAR + yr;
 
 	x = _month_date_from_year_day[rem];
 	ymd->month = x >> 5;
@@ -104,15 +104,16 @@
 Date ConvertYMDToDate(Year year, Month month, Day day)
 {
 	uint rem;
+	uint yr = year - BASE_YEAR;
 
 	/* day in the year */
 	rem = _accum_days_for_month[month] + day - 1;
 
 	/* remove feb 29 from year 1,2,3 */
-	if (year & 3) rem += (year & 3) * 365 + (rem < 31 + 29);
+	if (yr & 3) rem += (yr & 3) * 365 + (rem < 31 + 29);
 
 	/* base date. */
-	return (year >> 2) * (365 + 365 + 365 + 366) + rem;
+	return (yr >> 2) * (365 + 365 + 365 + 366) + rem;
 }
 
 /**
@@ -130,14 +131,14 @@
 	Day   day   = 1;
 
 	if (IS_INT_INSIDE(date, 1920, MAX_YEAR + 1)) {
-		year = date - 1920;
+		year = date;
 	} else if (IS_INT_INSIDE(date, 192001, 209012 + 1)) {
 		month = date % 100 - 1;
-		year = date / 100 - 1920;
+		year = date / 100;
 	} else if (IS_INT_INSIDE(date, 19200101, 20901231 + 1)) {
 		day = date % 100; date /= 100;
 		month = date % 100 - 1;
-		year = date / 100 - 1920;
+		year = date / 100;
 	} else if (IS_INT_INSIDE(date, 2091, 65536)) {
 		return date;
 	} else {
@@ -282,10 +283,10 @@
 #endif /* ENABLE_NETWORK */
 
 	/* check if we reached end of the game */
-	if (_cur_year == _patches.ending_year - MAX_YEAR) {
+	if (_cur_year == _patches.ending_year) {
 			ShowEndGameChart();
 	/* check if we reached the maximum year, decrement dates by a year */
-	} else if (BASE_YEAR + _cur_year == MAX_YEAR + 1) {
+	} else if (_cur_year == MAX_YEAR + 1) {
 		Vehicle *v;
 
 		_cur_year--;
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -951,33 +951,30 @@
 	Disaster7_Init,
 };
 
-#define MK(a, b) { (a) - BASE_YEAR, (b) - BASE_YEAR }
 static const struct {
-	byte min;
-	byte max;
+	Year min;
+	Year max;
 } _dis_years[] = {
-	MK(1930, 1955),
-	MK(1940, 1970),
-	MK(1960, 1990),
-	MK(1970, 2000),
-	MK(2000, 2100),
-	MK(1940, 1965),
-	MK(1975, 2010),
-	MK(1950, 1985)
+	{ 1930, 1955 },
+	{ 1940, 1970 },
+	{ 1960, 1990 },
+	{ 1970, 2000 },
+	{ 2000, 2100 },
+	{ 1940, 1965 },
+	{ 1975, 2010 },
+	{ 1950, 1985 }
 };
-#undef MK
 
 
 static void DoDisaster(void)
 {
 	byte buf[lengthof(_dis_years)];
-	byte year = _cur_year;
 	uint i;
 	uint j;
 
 	j = 0;
 	for (i = 0; i != lengthof(_dis_years); i++) {
-		if (year >= _dis_years[i].min && year < _dis_years[i].max) buf[j++] = i;
+		if (_cur_year >= _dis_years[i].min && _cur_year < _dis_years[i].max) buf[j++] = i;
 	}
 
 	if (j == 0) return;
--- a/economy.c
+++ b/economy.c
@@ -1394,7 +1394,7 @@
 
 		// if last speed is 0, we treat that as if no vehicle has ever visited the station.
 		ge->last_speed = min(t, 255);
-		ge->last_age = _cur_year - v->build_year;
+		ge->last_age = (_cur_year - BASE_YEAR) - v->build_year;
 
 		// If there's goods waiting at the station, and the vehicle
 		//  has capacity for it, load it on the vehicle.
@@ -1482,7 +1482,7 @@
 void PlayersMonthlyLoop(void)
 {
 	PlayersGenStatistics();
-	if (_patches.inflation && BASE_YEAR + _cur_year < MAX_YEAR)
+	if (_patches.inflation && _cur_year < MAX_YEAR)
 		AddInflation();
 	PlayersPayInterest();
 	// Reset the _current_player flag
@@ -1546,7 +1546,7 @@
 	p = GetPlayer(p1);
 
 	/* Protect new companies from hostile takeovers */
-	if (_cur_year - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED);
+	if ((_cur_year - BASE_YEAR) - p->inaugurated_year < 6) return_cmd_error(STR_7080_PROTECTED);
 
 	/* Those lines are here for network-protection (clients can be slow) */
 	if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) return 0;
--- a/engine.c
+++ b/engine.c
@@ -238,7 +238,7 @@
 {
 	EngineID i;
 
-	if (_cur_year >= 130) return;
+	if (_cur_year >= 2050) return;
 
 	for (i = 0; i != lengthof(_engines); i++) {
 		Engine *e = &_engines[i];
@@ -359,7 +359,7 @@
 {
 	Engine *e;
 
-	if (_cur_year < 130) {
+	if (_cur_year < 2050) {
 		for (e = _engines; e != endof(_engines); e++) {
 			// Age the vehicle
 			if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) {
--- a/graph_gui.c
+++ b/graph_gui.c
@@ -30,7 +30,7 @@
 	byte num_dataset;
 	byte num_on_x_axis;
 	byte month;
-	byte year;
+	Year year;
 	bool include_neg;
 	byte num_vert_lines;
 	uint16 unk61A;
@@ -151,7 +151,7 @@
 		x = gw->left + 44;
 		y = gw->top + gw->height + 1;
 		j = gw->month;
-		k = BASE_YEAR + gw->year;
+		k = gw->year;
 		i = gw->num_on_x_axis;assert(i>0);
 		do {
 			SetDParam(2, k);
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -1330,7 +1330,7 @@
 	i->total_transported[0] = 0;
 	i->total_transported[1] = 0;
 	i->was_cargo_delivered = false;
-	i->last_prod_year = _cur_year;
+	i->last_prod_year = _cur_year - BASE_YEAR;
 	i->total_production[0] = i->production_rate[0] * 8;
 	i->total_production[1] = i->production_rate[1] * 8;
 
@@ -1531,7 +1531,7 @@
 			return;
 
 		case INDUSTRYLIFE_CLOSABLE:
-			if ((byte)(_cur_year - i->last_prod_year) < 5 || !CHANCE16(1, 180))
+			if ((byte)((_cur_year - BASE_YEAR) - i->last_prod_year) < 5 || !CHANCE16(1, 180))
 				closeit = false;
 			break;
 
@@ -1594,7 +1594,7 @@
 	if (i->produced_cargo[0] != CT_INVALID) {
 		pct = 0;
 		if (i->last_mo_production[0] != 0) {
-			i->last_prod_year = _cur_year;
+			i->last_prod_year = _cur_year - BASE_YEAR;
 			pct = min(i->last_mo_transported[0] * 256 / i->last_mo_production[0],255);
 		}
 		i->pct_transported[0] = pct;
@@ -1609,7 +1609,7 @@
 	if (i->produced_cargo[1] != CT_INVALID) {
 		pct = 0;
 		if (i->last_mo_production[1] != 0) {
-			i->last_prod_year = _cur_year;
+			i->last_prod_year = _cur_year - BASE_YEAR;
 			pct = min(i->last_mo_transported[1] * 256 / i->last_mo_production[1],255);
 		}
 		i->pct_transported[1] = pct;
@@ -1721,7 +1721,7 @@
 
 		case INDUSTRYLIFE_CLOSABLE:
 			/* maybe close */
-			if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1,2)) {
+			if ( (byte)((_cur_year - BASE_YEAR) - i->last_prod_year) >= 5 && CHANCE16(1,2)) {
 				i->prod_level = 0;
 				str = indspec->closure_text;
 			}
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -1677,7 +1677,7 @@
 	YearMonthDay ymd;
 	ConvertDateToYMD(_date, &ymd);
 
-	if ((BASE_YEAR + ymd.year == MIN_YEAR && p2 == -1) || (BASE_YEAR + ymd.year == MAX_YEAR && p2 == 1)) return _cur_year;
+	if ((ymd.year == MIN_YEAR && p2 == -1) || (ymd.year == MAX_YEAR && p2 == 1)) return _cur_year;
 
 	SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
 	EnginesMonthlyLoop();
--- a/network.h
+++ b/network.h
@@ -206,7 +206,7 @@
 VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months
 VARDEF uint8 _network_autoclean_protected;   // Unprotect a company after X months
 
-VARDEF uint16 _network_restart_game_year;    // If this year is reached, the server automaticly restarts
+VARDEF Year _network_restart_game_year;      // If this year is reached, the server automaticly restarts
 
 NetworkGameList *NetworkQueryServer(const char* host, unsigned short port, bool game_info);
 
--- a/network_server.c
+++ b/network_server.c
@@ -1208,7 +1208,7 @@
 		GetString(_network_player_info[p->index].company_name, STR_JUST_STRING);
 
 		// Check the income
-		if (_cur_year - 1 == p->inaugurated_year) {
+		if (_cur_year - 1 == BASE_YEAR + p->inaugurated_year) {
 			// The player is here just 1 year, so display [2], else display[1]
 			for (i = 0; i < 13; i++) {
 				_network_player_info[p->index].income -= p->yearly_expenses[2][i];
@@ -1313,8 +1313,8 @@
 /* Check if we want to restart the map */
 static void NetworkCheckRestartMap(void)
 {
-	if (_network_restart_game_year != 0 && BASE_YEAR + _cur_year >= _network_restart_game_year) {
-		DEBUG(net, 0)("Auto-restarting map. Year %d reached.", BASE_YEAR + _cur_year);
+	if (_network_restart_game_year != 0 && _cur_year >= _network_restart_game_year) {
+		DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year);
 
 		_random_seeds[0][0] = Random();
 		_random_seeds[0][1] = InteractiveRandom();
--- a/newgrf.c
+++ b/newgrf.c
@@ -23,6 +23,7 @@
 #include "vehicle.h"
 #include "newgrf_text.h"
 #include "table/sprites.h"
+#include "date.h"
 
 #include "newgrf_spritegroup.h"
 
@@ -1006,7 +1007,7 @@
 
 	switch (prop) {
 		case 0x08: /* Year of availability */
-			FOR_EACH_OBJECT _bridge[brid + i].avail_year = grf_load_byte(&buf);
+			FOR_EACH_OBJECT _bridge[brid + i].avail_year = BASE_YEAR + grf_load_byte(&buf);
 			break;
 
 		case 0x09: /* Minimum length */
@@ -1059,6 +1060,10 @@
 			FOR_EACH_OBJECT _bridge[brid + i].flags = grf_load_byte(&buf);
 			break;
 
+		case 0x0F: /* Long year -- must be set after property 8 */
+			FOR_EACH_OBJECT _bridge[brid + i].avail_year = grf_load_word(&buf);
+			break;
+
 		default:
 			ret = true;
 	}
--- a/newgrf_engine.c
+++ b/newgrf_engine.c
@@ -553,7 +553,7 @@
 			case 0x43: return _current_player; /* Owner information */
 			case 0x46: return 0;               /* Motion counter */
 			case 0x48: return GetVehicleTypeInfo(object->u.vehicle.self_type); /* Vehicle Type Info */
-			case 0xC4: return _cur_year;       /* Build year */
+			case 0xC4: return clamp(_cur_year, BASE_YEAR, MAX_YEAR) - BASE_YEAR; /* Build year */
 			case 0xDA: return INVALID_VEHICLE; /* Next vehicle */
 			case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); /* Read GRF parameter */
 		}
--- a/newgrf_spritegroup.c
+++ b/newgrf_spritegroup.c
@@ -76,7 +76,7 @@
 	/* Return common variables */
 	switch (variable) {
 		case 0x00: return _date;
-		case 0x01: return _cur_year;
+		case 0x01: return clamp(_cur_year, BASE_YEAR, MAX_YEAR) - BASE_YEAR;
 		case 0x02: return _cur_month;
 		case 0x03: return _opt.landscape;
 		case 0x09: return _date_fract;
--- a/news_gui.c
+++ b/news_gui.c
@@ -258,7 +258,7 @@
 	ni->flags = (byte)(flags >> 8) | NF_NOEXPIRE;
 
 	// show this news message in color?
-	if (_date >= ConvertIntDate(_patches.colored_news_year))
+	if (_cur_year >= _patches.colored_news_year)
 		ni->flags |= NF_INCOLOR;
 
 	ni->type = (byte)(flags >> 16);
--- a/openttd.c
+++ b/openttd.c
@@ -316,7 +316,7 @@
 	const char *optformat;
 	char musicdriver[16], sounddriver[16], videodriver[16];
 	int resolution[2] = {0,0};
-	uint startyear = -1;
+	Year startyear = INVALID_YEAR;
 
 	bool dedicated = false;
 	bool network   = false;
@@ -408,7 +408,7 @@
 	if (sounddriver[0]) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
 	if (videodriver[0]) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
 	if (resolution[0]) { _cur_resolution[0] = resolution[0]; _cur_resolution[1] = resolution[1]; }
-	if (startyear != (uint)-1) _patches_newgame.starting_year = startyear;
+	if (startyear != INVALID_YEAR) _patches_newgame.starting_year = startyear;
 
 	if (_dedicated_forks && !dedicated) _dedicated_forks = false;
 
--- a/openttd.h
+++ b/openttd.h
@@ -52,7 +52,12 @@
 typedef uint32 WindowNumber;
 typedef byte WindowClass;
 
-typedef uint8  Year;
+enum {
+	INVALID_YEAR = -1,
+	INVALID_DATE = (uint16)-1,
+};
+
+typedef int16  Year;
 typedef uint16 Date;
 
 
--- a/player_gui.c
+++ b/player_gui.c
@@ -46,8 +46,8 @@
 		x = 215;
 		tbl = p->yearly_expenses + 2;
 		do {
-			if (year >= p->inaugurated_year) {
-				SetDParam(0, BASE_YEAR + year);
+			if (year >= BASE_YEAR + p->inaugurated_year) {
+				SetDParam(0, year);
 				DrawStringCenterUnderline(x-17, 15, STR_7010, 0);
 				sum = 0;
 				for (i = 0; i != 13; i++) {
--- a/players.c
+++ b/players.c
@@ -490,7 +490,7 @@
 	p->share_owners[0] = p->share_owners[1] = p->share_owners[2] = p->share_owners[3] = OWNER_SPECTATOR;
 
 	p->avail_railtypes = GetPlayerRailtypes(p->index);
-	p->inaugurated_year = _cur_year;
+	p->inaugurated_year = _cur_year - BASE_YEAR;
 	p->face = Random();
 
 	/* Engine renewal settings */
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -184,7 +184,7 @@
 		v->service_interval = _patches.servint_roadveh;
 
 		v->date_of_last_service = _date;
-		v->build_year = _cur_year;
+		v->build_year = _cur_year - BASE_YEAR;
 
 		v->type = VEH_Road;
 		v->cur_image = 0xC15;
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -54,7 +54,7 @@
 	y += 10;
 
 	/* Design date - Life length */
-	SetDParam(0, BASE_YEAR + ymd.year);
+	SetDParam(0, ymd.year);
 	SetDParam(1, e->lifelength);
 	DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
 	y += 10;
--- a/settings.c
+++ b/settings.c
@@ -1206,7 +1206,7 @@
 	SDTG_BOOL("autoclean_companies",             S, 0, _network_autoclean_companies,  false,       STR_NULL, NULL),
 	 SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0,  60,  STR_NULL, NULL),
 	 SDTG_VAR("autoclean_protected",  SLE_UINT8, S, 0, _network_autoclean_protected,  36, 0, 180,  STR_NULL, NULL),
-	 SDTG_VAR("restart_game_year",   SLE_UINT16, S,D0, _network_restart_game_year,    0, MIN_YEAR, MAX_YEAR, STR_NULL, NULL),
+	 SDTG_VAR("restart_game_year",    SLE_INT16, S,D0, _network_restart_game_year,    0, MIN_YEAR, MAX_YEAR, STR_NULL, NULL),
 	 SDTG_END()
 };
 #endif /* ENABLE_NETWORK */
@@ -1320,9 +1320,9 @@
 	SDT_BOOL(Patches, same_industry_close,        0, 0, false,            STR_CONFIG_PATCHES_SAMEINDCLOSE,     NULL),
 	SDT_BOOL(Patches, bribe,                      0, 0,  true,            STR_CONFIG_PATCHES_BRIBE,            NULL),
 	 SDT_VAR(Patches, snow_line_height,SLE_UINT8, 0, 0,     7,   2,   13, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT,  NULL),
-	 SDT_VAR(Patches, colored_news_year,SLE_UINT, 0,NC,  2000, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL),
-	 SDT_VAR(Patches, starting_year,    SLE_UINT, 0,NC,  1950, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
-	 SDT_VAR(Patches, ending_year,      SLE_UINT,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_ENDING_YEAR,  NULL),
+	 SDT_VAR(Patches, colored_news_year,SLE_FILE_U32 | SLE_VAR_I16, 0,NC,  2000, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL),
+	 SDT_VAR(Patches, starting_year,    SLE_FILE_U32 | SLE_VAR_I16, 0,NC,  1950, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
+	 SDT_VAR(Patches, ending_year,      SLE_FILE_U32 | SLE_VAR_I16,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_ENDING_YEAR,  NULL),
 	SDT_BOOL(Patches, smooth_economy,             0, 0,  true,            STR_CONFIG_PATCHES_SMOOTH_ECONOMY,   NULL),
 	SDT_BOOL(Patches, allow_shares,               0, 0,  true,            STR_CONFIG_PATCHES_ALLOW_SHARES,     NULL),
 
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -901,7 +901,7 @@
 
 		v->service_interval = _patches.servint_ships;
 		v->date_of_last_service = _date;
-		v->build_year = _cur_year;
+		v->build_year = _cur_year - BASE_YEAR;
 		v->cur_image = 0x0E5E;
 		v->type = VEH_Ship;
 		v->random_bits = VehicleRandomBits();
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -54,7 +54,7 @@
 	/* Design date - Life length */
 	e = GetEngine(engine_number);
 	ConvertDateToYMD(e->intro_date, &ymd);
-	SetDParam(0, BASE_YEAR + ymd.year);
+	SetDParam(0, ymd.year);
 	SetDParam(1, e->lifelength);
 	DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
 	y += 10;
--- a/strings.c
+++ b/strings.c
@@ -339,7 +339,7 @@
 	for (src = GetStringPtr(STR_0162_JAN + ymd.month); (*buff++ = *src++) != '\0';) {}
 	buff[-1] = ' ';
 
-	return FormatNoCommaNumber(buff, BASE_YEAR + ymd.year);
+	return FormatNoCommaNumber(buff, ymd.year);
 }
 
 static char *FormatMonthAndYear(char *buff, Date date)
@@ -352,7 +352,7 @@
 	for (src = GetStringPtr(STR_MONTH_JAN + ymd.month); (*buff++ = *src++) != '\0';) {}
 	buff[-1] = ' ';
 
-	return FormatNoCommaNumber(buff, BASE_YEAR + ymd.year);
+	return FormatNoCommaNumber(buff, ymd.year);
 }
 
 static char *FormatTinyDate(char *buff, Date date)
@@ -360,7 +360,7 @@
 	YearMonthDay ymd;
 
 	ConvertDateToYMD(date, &ymd);
-	buff += sprintf(buff, " %02i-%02i-%04i", ymd.day, ymd.month + 1, BASE_YEAR + ymd.year);
+	buff += sprintf(buff, " %02i-%02i-%04i", ymd.day, ymd.month + 1, ymd.year);
 
 	return buff;
 }
--- a/table/town_land.h
+++ b/table/town_land.h
@@ -2019,120 +2019,120 @@
 
 
 typedef struct {
-	byte min,max;
+	Year min, max;
 } HousetypeYear;
 
 static const HousetypeYear _housetype_years[] = {
-	{43, 255},
-	{37, 255},
-	{48, 255},
-	{0,  255},
-	{55, 255},
-	{55, 255},
-	{0,  255},
-	{39, 255},
-	{39, 255},
-	{25, 255},
-	{25, 255},
-	{0, 255},
-	{15, 255},
-	{31, 255},
-	{10, 40},
-	{10, 40},
-	{10, 40},
-	{57, 255},
-	{63, 255},
-	{65, 255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  31},
-	{0,  32},
-	{11, 255},
-	{15, 255},
-	{43, 255},
-	{0,  35},
-	{53, 255},
-	{0,  255},
-	{38, 255},
-	{38, 255},
-	{38, 255},
-	{38, 255},
-	{80, 255},
-	{0,  40},
-	{0,  40},
-	{25, 255},
-	{63, 255},
-	{63, 255},
-	{63, 255},
-	{63, 255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  43},
-	{0,  43},
-	{46, 255},
-	{46, 255},
-	{50, 255},
-	{50, 255},
-	{54, 255},
-	{54, 255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  40},
-	{0,  40},
-	{52, 255},
-	{52, 255},
-	{52, 255},
-	{52, 255},
-	{43, 255},
-	{43, 255},
-	{58, 255},
-	{58, 255},
-	{47, 255},
-	{47, 255},
-	{47, 255},
-	{47, 255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{53, 255},
-	{42, 255},
-	{64, 255},
-	{64, 255},
-	{0,  255},
-	{73, 255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
-	{0,  255},
+	{ 1963, MAX_YEAR },
+	{ 1957, MAX_YEAR },
+	{ 1968, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{ 1975, MAX_YEAR },
+	{ 1975, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{ 1959, MAX_YEAR },
+	{ 1959, MAX_YEAR },
+	{ 1945, MAX_YEAR },
+	{ 1945, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{ 1935, MAX_YEAR },
+	{ 1951, MAX_YEAR },
+	{ 1930,     1960 },
+	{ 1930,     1960 },
+	{ 1930,     1960 },
+	{ 1977, MAX_YEAR },
+	{ 1983, MAX_YEAR },
+	{ 1985, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0,     1951 },
+	{    0,     1952 },
+	{ 1941, MAX_YEAR },
+	{ 1945, MAX_YEAR },
+	{ 1963, MAX_YEAR },
+	{    0,     1955 },
+	{ 1973, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{ 1958, MAX_YEAR },
+	{ 1958, MAX_YEAR },
+	{ 1958, MAX_YEAR },
+	{ 1958, MAX_YEAR },
+	{ 1950, MAX_YEAR },
+	{    0,     1960 },
+	{    0,     1960 },
+	{ 1945, MAX_YEAR },
+	{ 1983, MAX_YEAR },
+	{ 1983, MAX_YEAR },
+	{ 1983, MAX_YEAR },
+	{ 1983, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0,     1963 },
+	{    0,     1963 },
+	{ 1966, MAX_YEAR },
+	{ 1966, MAX_YEAR },
+	{ 1970, MAX_YEAR },
+	{ 1970, MAX_YEAR },
+	{ 1974, MAX_YEAR },
+	{ 1974, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0,     1960 },
+	{    0,     1960 },
+	{ 1972, MAX_YEAR },
+	{ 1972, MAX_YEAR },
+	{ 1972, MAX_YEAR },
+	{ 1972, MAX_YEAR },
+	{ 1963, MAX_YEAR },
+	{ 1963, MAX_YEAR },
+	{ 1978, MAX_YEAR },
+	{ 1978, MAX_YEAR },
+	{ 1967, MAX_YEAR },
+	{ 1967, MAX_YEAR },
+	{ 1967, MAX_YEAR },
+	{ 1967, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{ 1973, MAX_YEAR },
+	{ 1962, MAX_YEAR },
+	{ 1984, MAX_YEAR },
+	{ 1984, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{ 1993, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
+	{    0, MAX_YEAR },
 };
 assert_compile(lengthof(_housetype_years) == HOUSE_MAX);
 
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -623,7 +623,7 @@
 
 			v->u.rail.railtype = GetEngine(engine)->railtype;
 
-			v->build_year = _cur_year;
+			v->build_year = _cur_year - BASE_YEAR;
 			v->type = VEH_Train;
 			v->cur_image = 0xAC2;
 			v->random_bits = VehicleRandomBits();
@@ -783,7 +783,7 @@
 
 			v->service_interval = _patches.servint_trains;
 			v->date_of_last_service = _date;
-			v->build_year = _cur_year;
+			v->build_year = _cur_year - BASE_YEAR;
 			v->type = VEH_Train;
 			v->cur_image = 0xAC2;
 			v->random_bits = VehicleRandomBits();
--- a/train_gui.c
+++ b/train_gui.c
@@ -73,7 +73,7 @@
 	y += 10;
 
 	/* Design date - Life length */
-	SetDParam(0, BASE_YEAR + ymd.year);
+	SetDParam(0, ymd.year);
 	SetDParam(1, e->lifelength);
 	DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
 	y += 10;
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -38,26 +38,26 @@
 
 const Bridge orig_bridge[] = {
 /*
-	   year of availablity
-	   |  minimum length
-	   |  |   maximum length
-	   |  |   |    price
-	   |  |   |    |    maximum speed
-	   |  |   |    |    |  sprite to use in GUI                string with description
-	   |  |   |    |    |  |                                   |                            */
-	{  0, 0, 16,  80,  32, 0xA24                             , STR_5012_WOODEN             , NULL, 0 },
-	{  0, 0,  2, 112,  48, 0xA26 | PALETTE_TO_STRUCT_RED     , STR_5013_CONCRETE           , NULL, 0 },
-	{ 10, 0,  5, 144,  64, 0xA25                             , STR_500F_GIRDER_STEEL       , NULL, 0 },
-	{  0, 2, 10, 168,  80, 0xA22 | PALETTE_TO_STRUCT_CONCRETE, STR_5011_SUSPENSION_CONCRETE, NULL, 0 },
-	{ 10, 3, 16, 185,  96, 0xA22                             , STR_500E_SUSPENSION_STEEL   , NULL, 0 },
-	{ 10, 3, 16, 192, 112, 0xA22 | PALETTE_TO_STRUCT_YELLOW  , STR_500E_SUSPENSION_STEEL   , NULL, 0 },
-	{ 10, 3,  7, 224, 160, 0xA23                             , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
-	{ 10, 3,  8, 232, 208, 0xA23 | PALETTE_TO_STRUCT_BROWN   , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
-	{ 10, 3,  9, 248, 240, 0xA23 | PALETTE_TO_STRUCT_RED     , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
-	{ 10, 0,  2, 240, 256, 0xA27                             , STR_500F_GIRDER_STEEL       , NULL, 0 },
-	{ 75, 2, 16, 255, 320, 0xA28                             , STR_5014_TUBULAR_STEEL      , NULL, 0 },
-	{ 85, 2, 32, 380, 512, 0xA28 | PALETTE_TO_STRUCT_YELLOW  , STR_5014_TUBULAR_STEEL      , NULL, 0 },
-	{ 90, 2, 32, 510, 608, 0xA28 | PALETTE_TO_STRUCT_GREY    , STR_BRIDGE_TUBULAR_SILICON  , NULL, 0 }
+	     year of availablity
+	     |  minimum length
+	     |  |   maximum length
+	     |  |   |    price
+	     |  |   |    |    maximum speed
+	     |  |   |    |    |  sprite to use in GUI                string with description
+	     |  |   |    |    |  |                                   |                            */
+	{    0, 0, 16,  80,  32, 0xA24                             , STR_5012_WOODEN             , NULL, 0 },
+	{    0, 0,  2, 112,  48, 0xA26 | PALETTE_TO_STRUCT_RED     , STR_5013_CONCRETE           , NULL, 0 },
+	{ 1930, 0,  5, 144,  64, 0xA25                             , STR_500F_GIRDER_STEEL       , NULL, 0 },
+	{    0, 2, 10, 168,  80, 0xA22 | PALETTE_TO_STRUCT_CONCRETE, STR_5011_SUSPENSION_CONCRETE, NULL, 0 },
+	{ 1930, 3, 16, 185,  96, 0xA22                             , STR_500E_SUSPENSION_STEEL   , NULL, 0 },
+	{ 1930, 3, 16, 192, 112, 0xA22 | PALETTE_TO_STRUCT_YELLOW  , STR_500E_SUSPENSION_STEEL   , NULL, 0 },
+	{ 1930, 3,  7, 224, 160, 0xA23                             , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
+	{ 1930, 3,  8, 232, 208, 0xA23 | PALETTE_TO_STRUCT_BROWN   , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
+	{ 1930, 3,  9, 248, 240, 0xA23 | PALETTE_TO_STRUCT_RED     , STR_5010_CANTILEVER_STEEL   , NULL, 0 },
+	{ 1930, 0,  2, 240, 256, 0xA27                             , STR_500F_GIRDER_STEEL       , NULL, 0 },
+	{ 1995, 2, 16, 255, 320, 0xA28                             , STR_5014_TUBULAR_STEEL      , NULL, 0 },
+	{ 2005, 2, 32, 380, 512, 0xA28 | PALETTE_TO_STRUCT_YELLOW  , STR_5014_TUBULAR_STEEL      , NULL, 0 },
+	{ 2010, 2, 32, 510, 608, 0xA28 | PALETTE_TO_STRUCT_GREY    , STR_BRIDGE_TUBULAR_SILICON  , NULL, 0 }
 };
 
 Bridge _bridge[MAX_BRIDGES];
--- a/variables.h
+++ b/variables.h
@@ -147,9 +147,9 @@
 	bool ai_disable_veh_roadveh;		// disable types for AI
 	bool ai_disable_veh_aircraft;		// disable types for AI
 	bool ai_disable_veh_ship;		// disable types for AI
-	uint32 starting_year;		// starting date
-	uint32 ending_year;		// end of the game (just show highscore)
-	uint32 colored_news_year; // when does newspaper become colored?
+	Year starting_year;				// starting date
+	Year ending_year;					// end of the game (just show highscore)
+	Year colored_news_year;		// when does newspaper become colored?
 
 	bool keep_all_autosave;		// name the autosave in a different way.
 	bool autosave_on_exit;		// save an autosave when you quit the game, but do not ask "Do you really want to quit?"