Changeset - r27884:803962be0328
[Not reviewed]
master
! ! !
Tyler Trahan - 10 months ago 2023-08-16 13:43:31
tyler@tylertrahan.com
Codechange: Move date consts and functions to CalendarTime and TimerGameCalendar classes
66 files changed with 401 insertions and 394 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -450,13 +450,13 @@ void Aircraft::OnNewDay()
 
	CheckVehicleBreakdown(this);
 
	AgeVehicle(this);
 
	CheckIfAircraftNeedsService(this);
 

	
 
	if (this->running_ticks == 0) return;
 

	
 
	CommandCost cost(EXPENSES_AIRCRAFT_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * Ticks::DAY_TICKS));
 
	CommandCost cost(EXPENSES_AIRCRAFT_RUN, this->GetRunningCost() * this->running_ticks / (CalendarTime::DAYS_IN_YEAR * Ticks::DAY_TICKS));
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
 

	
 
	SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -964,13 +964,13 @@ int DrawVehiclePurchaseInfo(int left, in
 
	}
 

	
 
	/* Draw details that apply to all types except rail wagons. */
 
	if (e->type != VEH_TRAIN || e->u.rail.railveh_type != RAILVEH_WAGON) {
 
		/* Design date - Life length */
 
		SetDParam(0, ymd.year);
 
		SetDParam(1, DateToYear(e->GetLifeLengthInDays()));
 
		SetDParam(1, TimerGameCalendar::DateToYear(e->GetLifeLengthInDays()));
 
		DrawString(left, right, y, STR_PURCHASE_INFO_DESIGNED_LIFE);
 
		y += FONT_HEIGHT_NORMAL;
 

	
 
		/* Reliability */
 
		SetDParam(0, ToPercent16(e->reliability));
 
		DrawString(left, right, y, STR_PURCHASE_INFO_RELIABILITY);
src/cheat_gui.cpp
Show inline comments
 
@@ -101,13 +101,13 @@ extern void EnginesMonthlyLoop();
 
 * @param change_direction +1 (increase) or -1 (decrease).
 
 * @return New year.
 
 */
 
static int32_t ClickChangeDateCheat(int32_t new_value, int32_t change_direction)
 
{
 
	/* Don't allow changing to an invalid year, or the current year. */
 
	auto new_year = Clamp(TimerGameCalendar::Year(new_value), MIN_YEAR, MAX_YEAR);
 
	auto new_year = Clamp(TimerGameCalendar::Year(new_value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
 
	if (new_year == TimerGameCalendar::year) return static_cast<int32_t>(TimerGameCalendar::year);
 

	
 
	TimerGameCalendar::YearMonthDay ymd;
 
	TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date, &ymd);
 
	TimerGameCalendar::Date new_date = TimerGameCalendar::ConvertYMDToDate(new_year, ymd.month, ymd.day);
 

	
 
@@ -317,13 +317,13 @@ struct CheatWindow : Window {
 
					break;
 

	
 
				default:
 
					switch (ce->str) {
 
						/* Display date for change date cheat */
 
						case STR_CHEAT_CHANGE_DATE:
 
							SetDParam(0, TimerGameCalendar::ConvertYMDToDate(MAX_YEAR, 11, 31));
 
							SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 11, 31));
 
							width = std::max(width, GetStringBoundingBox(ce->str).width);
 
							break;
 

	
 
						/* Draw coloured flag for change company cheat */
 
						case STR_CHEAT_CHANGE_COMPANY:
 
							SetDParamMaxValue(0, MAX_COMPANIES);
src/company_gui.cpp
Show inline comments
 
@@ -1858,23 +1858,23 @@ struct CompanyInfrastructureWindow : Win
 
			if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
 

	
 
			this->railtypes |= GetRailTypeInfo(e->u.rail.railtype)->introduces_railtypes;
 
		}
 

	
 
		/* Get the date introduced railtypes as well. */
 
		this->railtypes = AddDateIntroducedRailTypes(this->railtypes, MAX_DATE);
 
		this->railtypes = AddDateIntroducedRailTypes(this->railtypes, CalendarTime::MAX_DATE);
 

	
 
		/* Find the used roadtypes. */
 
		for (const Engine *e : Engine::IterateType(VEH_ROAD)) {
 
			if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
 

	
 
			this->roadtypes |= GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes;
 
		}
 

	
 
		/* Get the date introduced roadtypes as well. */
 
		this->roadtypes = AddDateIntroducedRoadTypes(this->roadtypes, MAX_DATE);
 
		this->roadtypes = AddDateIntroducedRoadTypes(this->roadtypes, CalendarTime::MAX_DATE);
 
		this->roadtypes &= ~_roadtypes_hidden_mask;
 
	}
 

	
 
	/** Get total infrastructure maintenance cost. */
 
	Money GetTotalMaintenanceCost() const
 
	{
src/date_gui.cpp
Show inline comments
 
@@ -41,14 +41,14 @@ struct SetDateWindow : Window {
 
	 * @param callback the callback to call once a date has been selected
 
	 */
 
	SetDateWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, TimerGameCalendar::Date initial_date, TimerGameCalendar::Year min_year, TimerGameCalendar::Year max_year, SetDateCallback *callback, void *callback_data) :
 
			Window(desc),
 
			callback(callback),
 
			callback_data(callback_data),
 
			min_year(std::max(MIN_YEAR, min_year)),
 
			max_year(std::min(MAX_YEAR, max_year))
 
			min_year(std::max(CalendarTime::MIN_YEAR, min_year)),
 
			max_year(std::min(CalendarTime::MAX_YEAR, max_year))
 
	{
 
		assert(this->min_year <= this->max_year);
 
		this->parent = parent;
 
		this->InitNested(window_number);
 

	
 
		if (initial_date == 0) initial_date = TimerGameCalendar::date;
src/date_type.h
Show inline comments
 
@@ -9,75 +9,8 @@
 

	
 
#ifndef DATE_TYPE_H
 
#define DATE_TYPE_H
 

	
 
#include "timer/timer_game_calendar.h"
 

	
 
static const int DAYS_IN_YEAR      = 365; ///< days per year
 
static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more...
 
static const int MONTHS_IN_YEAR    =  12; ///< months per year
 

	
 
static const int SECONDS_PER_DAY   = 2;   ///< approximate seconds per day, not for precise calculations
 

	
 
/*
 
 * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
 
 * primarily used for loading newgrf and savegame data and returning some
 
 * newgrf (callback) functions that were in the original (TTD) inherited
 
 * format, where 'TimerGameCalendar::date == 0' meant that it was 1920-01-01.
 
 */
 

	
 
/** The minimum starting year/base year of the original TTD */
 
static constexpr TimerGameCalendar::Year ORIGINAL_BASE_YEAR = 1920;
 
/** The original ending year */
 
static constexpr TimerGameCalendar::Year ORIGINAL_END_YEAR = 2051;
 
/** The maximum year of the original TTD */
 
static constexpr TimerGameCalendar::Year ORIGINAL_MAX_YEAR = 2090;
 

	
 
/**
 
 * Calculate the date of the first day of a given year.
 
 * @param year the year to get the first day of.
 
 * @return the date.
 
 */
 
static constexpr TimerGameCalendar::Date DateAtStartOfYear(TimerGameCalendar::Year year)
 
{
 
	int32_t year_as_int = static_cast<int32_t>(year);
 
	uint number_of_leap_years = (year == 0) ? 0 : ((year_as_int - 1) / 4 - (year_as_int - 1) / 100 + (year_as_int - 1) / 400 + 1);
 

	
 
	return (DAYS_IN_YEAR * year_as_int) + number_of_leap_years;
 
}
 

	
 
/**
 
 * Calculate the year of a given date.
 
 * @param date The date to consider.
 
 * @return the year.
 
 */
 
static inline TimerGameCalendar::Year DateToYear(TimerGameCalendar::Date date)
 
{
 
	return static_cast<int32_t>(date) / DAYS_IN_LEAP_YEAR;
 
}
 

	
 
/**
 
 * The date of the first day of the original base year.
 
 */
 
static constexpr TimerGameCalendar::Date DAYS_TILL_ORIGINAL_BASE_YEAR = DateAtStartOfYear(ORIGINAL_BASE_YEAR);
 

	
 
/** The absolute minimum & maximum years in OTTD */
 
static constexpr TimerGameCalendar::Year MIN_YEAR = 0;
 

	
 
/** The default starting year */
 
static constexpr TimerGameCalendar::Year DEF_START_YEAR = 1950;
 
/** The default scoring end year */
 
static constexpr TimerGameCalendar::Year DEF_END_YEAR = ORIGINAL_END_YEAR - 1;
 

	
 
/**
 
 * MAX_YEAR, nicely rounded value of the number of years that can
 
 * be encoded in a single 32 bits date, about 2^31 / 366 years.
 
 */
 
static constexpr TimerGameCalendar::Year MAX_YEAR = 5000000;
 

	
 
/** The date of the last day of the max year. */
 
static constexpr TimerGameCalendar::Date MAX_DATE = DateAtStartOfYear(MAX_YEAR + 1) - 1;
 

	
 
static constexpr TimerGameCalendar::Year INVALID_YEAR = -1; ///< Representation of an invalid year
 
static constexpr TimerGameCalendar::Date INVALID_DATE = -1; ///< Representation of an invalid date
 

	
 
#endif /* DATE_TYPE_H */
src/depot_gui.cpp
Show inline comments
 
@@ -357,13 +357,13 @@ struct DepotWindow : Window {
 
			DrawString(text, STR_DEPOT_NO_ENGINE);
 
		} else {
 
			Rect flag = r.WithWidth(this->flag_size.width, rtl).WithHeight(this->flag_size.height).Translate(0, diff_y);
 
			DrawSpriteIgnorePadding((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, flag, false, SA_CENTER);
 

	
 
			SetDParam(0, v->unitnumber);
 
			DrawString(text, STR_JUST_COMMA, (v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED);
 
			DrawString(text, STR_JUST_COMMA, (v->max_age - CalendarTime::DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED);
 
		}
 
	}
 

	
 
	void DrawWidget(const Rect &r, int widget) const override
 
	{
 
		if (widget != WID_D_MATRIX) return;
src/economy.cpp
Show inline comments
 
@@ -732,13 +732,13 @@ bool AddInflation(bool check_year)
 
	 * inflation mechanism during the first 170 years (the amount of years that
 
	 * one had in the original TTD) and stop doing the inflation after that
 
	 * because it only causes problems that can't be solved nicely and the
 
	 * inflation doesn't add anything after that either; it even makes playing
 
	 * it impossible due to the diverging cost and income rates.
 
	 */
 
	if (check_year && (TimerGameCalendar::year < ORIGINAL_BASE_YEAR || TimerGameCalendar::year >= ORIGINAL_MAX_YEAR)) return true;
 
	if (check_year && (TimerGameCalendar::year < CalendarTime::ORIGINAL_BASE_YEAR || TimerGameCalendar::year >= CalendarTime::ORIGINAL_MAX_YEAR)) return true;
 

	
 
	if (_economy.inflation_prices == MAX_INFLATION || _economy.inflation_payment == MAX_INFLATION) return true;
 

	
 
	/* Approximation for (100 + infl_amount)% ** (1 / 12) - 100%
 
	 * scaled by 65536
 
	 * 12 -> months per year
 
@@ -925,13 +925,13 @@ void StartupEconomy()
 
	_economy.infl_amount = _settings_game.difficulty.initial_interest;
 
	_economy.infl_amount_pr = std::max(0, _settings_game.difficulty.initial_interest - 1);
 
	_economy.fluct = GB(Random(), 0, 8) + 168;
 

	
 
	if (_settings_game.economy.inflation) {
 
		/* Apply inflation that happened before our game start year. */
 
		int months = static_cast<int32_t>(std::min(TimerGameCalendar::year, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR) * 12;
 
		int months = static_cast<int32_t>(std::min(TimerGameCalendar::year, CalendarTime::ORIGINAL_MAX_YEAR) - CalendarTime::ORIGINAL_BASE_YEAR) * 12;
 
		for (int i = 0; i < months; i++) {
 
			AddInflation(false);
 
		}
 
	}
 

	
 
	/* Set up prices */
src/engine.cpp
Show inline comments
 
@@ -435,13 +435,13 @@ uint Engine::GetDisplayMaxTractiveEffort
 
/**
 
 * Returns the vehicle's (not model's!) life length in days.
 
 * @return the life length
 
 */
 
TimerGameCalendar::Date Engine::GetLifeLengthInDays() const
 
{
 
	return DateAtStartOfYear(this->info.lifelength + _settings_game.vehicle.extend_vehicle_life);
 
	return TimerGameCalendar::DateAtStartOfYear(this->info.lifelength + _settings_game.vehicle.extend_vehicle_life);
 
}
 

	
 
/**
 
 * Get the range of an aircraft type.
 
 * @return Range of the aircraft type in tiles or 0 if unlimited range.
 
 */
 
@@ -660,13 +660,13 @@ void SetYearEngineAgingStops()
 
		/* Exclude certain engines */
 
		if (!HasBit(ei->climates, _settings_game.game_creation.landscape)) continue;
 
		if (e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON) continue;
 

	
 
		/* Base year ending date on half the model life */
 
		TimerGameCalendar::YearMonthDay ymd;
 
		TimerGameCalendar::ConvertDateToYMD(ei->base_intro + static_cast<int32_t>(DateAtStartOfYear(ei->lifelength)) / 2, &ymd);
 
		TimerGameCalendar::ConvertDateToYMD(ei->base_intro + static_cast<int32_t>(TimerGameCalendar::DateAtStartOfYear(ei->lifelength)) / 2, &ymd);
 

	
 
		_year_engine_aging_stops = std::max(_year_engine_aging_stops, ymd.year);
 
	}
 
}
 

	
 
/**
 
@@ -1100,13 +1100,13 @@ void EnginesMonthlyLoop()
 
				refresh = true;
 
			}
 

	
 
			/* Do not introduce invalid engines */
 
			if (!e->IsEnabled()) continue;
 

	
 
			if (!(e->flags & ENGINE_AVAILABLE) && TimerGameCalendar::date >= (e->intro_date + DAYS_IN_YEAR)) {
 
			if (!(e->flags & ENGINE_AVAILABLE) && TimerGameCalendar::date >= (e->intro_date + CalendarTime::DAYS_IN_YEAR)) {
 
				/* Introduce it to all companies */
 
				NewVehicleAvailable(e);
 
			} else if (!(e->flags & (ENGINE_AVAILABLE | ENGINE_EXCLUSIVE_PREVIEW)) && TimerGameCalendar::date >= e->intro_date) {
 
				/* Introduction date has passed...
 
				 * Check if it is allowed to build this vehicle type at all
 
				 * based on the current game settings. If not, it does not
src/genworld_gui.cpp
Show inline comments
 
@@ -566,14 +566,14 @@ struct GenerateLandscapeWindow : public 
 

	
 
		/* Update availability of decreasing / increasing start date and snow level */
 
		if (mode == GLWM_HEIGHTMAP) {
 
			this->SetWidgetDisabledState(WID_GL_HEIGHTMAP_HEIGHT_DOWN, _settings_newgame.game_creation.heightmap_height <= MIN_HEIGHTMAP_HEIGHT);
 
			this->SetWidgetDisabledState(WID_GL_HEIGHTMAP_HEIGHT_UP, _settings_newgame.game_creation.heightmap_height >= GetMapHeightLimit());
 
		}
 
		this->SetWidgetDisabledState(WID_GL_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
 
		this->SetWidgetDisabledState(WID_GL_START_DATE_UP,   _settings_newgame.game_creation.starting_year >= MAX_YEAR);
 
		this->SetWidgetDisabledState(WID_GL_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= CalendarTime::MIN_YEAR);
 
		this->SetWidgetDisabledState(WID_GL_START_DATE_UP,   _settings_newgame.game_creation.starting_year >= CalendarTime::MAX_YEAR);
 
		this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_DOWN, _settings_newgame.game_creation.snow_coverage <= 0 || _settings_newgame.game_creation.landscape != LT_ARCTIC);
 
		this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_UP,   _settings_newgame.game_creation.snow_coverage >= 100 || _settings_newgame.game_creation.landscape != LT_ARCTIC);
 
		this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_DOWN, _settings_newgame.game_creation.desert_coverage <= 0 || _settings_newgame.game_creation.landscape != LT_TROPIC);
 
		this->SetWidgetDisabledState(WID_GL_DESERT_COVERAGE_UP,   _settings_newgame.game_creation.desert_coverage >= 100 || _settings_newgame.game_creation.landscape != LT_TROPIC);
 

	
 
		/* Do not allow a custom sea level or terrain type with the original land generator. */
 
@@ -596,13 +596,13 @@ struct GenerateLandscapeWindow : public 
 
			case WID_GL_HEIGHTMAP_HEIGHT_TEXT:
 
				SetDParam(0, MAX_TILE_HEIGHT);
 
				d = GetStringBoundingBox(STR_JUST_INT);
 
				break;
 

	
 
			case WID_GL_START_DATE_TEXT:
 
				SetDParam(0, TimerGameCalendar::ConvertYMDToDate(MAX_YEAR, 0, 1));
 
				SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1));
 
				d = GetStringBoundingBox(STR_JUST_DATE_LONG);
 
				break;
 

	
 
			case WID_GL_MAPSIZE_X_PULLDOWN:
 
			case WID_GL_MAPSIZE_Y_PULLDOWN:
 
				SetDParamMaxValue(0, MAX_MAP_SIZE);
 
@@ -760,13 +760,13 @@ struct GenerateLandscapeWindow : public 
 
			case WID_GL_START_DATE_DOWN:
 
			case WID_GL_START_DATE_UP: // Year buttons
 
				/* Don't allow too fast scrolling */
 
				if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
 
					this->HandleButtonClick(widget);
 

	
 
					_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - WID_GL_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 
					_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - WID_GL_START_DATE_TEXT, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
 
					this->InvalidateData();
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case WID_GL_START_DATE_TEXT: // Year text
 
@@ -965,13 +965,13 @@ struct GenerateLandscapeWindow : public 
 
		if (!StrEmpty(str)) {
 
			value = atoi(str);
 
		} else {
 
			/* An empty string means revert to the default */
 
			switch (this->widget_id) {
 
				case WID_GL_HEIGHTMAP_HEIGHT_TEXT: value = MAP_HEIGHT_LIMIT_AUTO_MINIMUM; break;
 
				case WID_GL_START_DATE_TEXT: value = static_cast<int32_t>(DEF_START_YEAR); break;
 
				case WID_GL_START_DATE_TEXT: value = static_cast<int32_t>(CalendarTime::DEF_START_YEAR); break;
 
				case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
 
				case WID_GL_DESERT_COVERAGE_TEXT: value = DEF_DESERT_COVERAGE; break;
 
				case WID_GL_TOWN_PULLDOWN: value = 1; break;
 
				case WID_GL_INDUSTRY_PULLDOWN: value = 1; break;
 
				case WID_GL_TERRAIN_PULLDOWN: value = MIN_MAP_HEIGHT_LIMIT; break;
 
				case WID_GL_WATER_PULLDOWN: value = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE; break;
 
@@ -984,13 +984,13 @@ struct GenerateLandscapeWindow : public 
 
				this->SetWidgetDirty(WID_GL_HEIGHTMAP_HEIGHT_TEXT);
 
				_settings_newgame.game_creation.heightmap_height = Clamp(value, MIN_HEIGHTMAP_HEIGHT, GetMapHeightLimit());
 
				break;
 

	
 
			case WID_GL_START_DATE_TEXT:
 
				this->SetWidgetDirty(WID_GL_START_DATE_TEXT);
 
				_settings_newgame.game_creation.starting_year = Clamp(TimerGameCalendar::Year(value), MIN_YEAR, MAX_YEAR);
 
				_settings_newgame.game_creation.starting_year = Clamp(TimerGameCalendar::Year(value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
 
				break;
 

	
 
			case WID_GL_SNOW_COVERAGE_TEXT:
 
				this->SetWidgetDirty(WID_GL_SNOW_COVERAGE_TEXT);
 
				_settings_newgame.game_creation.snow_coverage = Clamp(value, 0, 100);
 
				break;
 
@@ -1122,14 +1122,14 @@ struct CreateScenarioWindow : public Win
 
				break;
 
		}
 
	}
 

	
 
	void OnPaint() override
 
	{
 
		this->SetWidgetDisabledState(WID_CS_START_DATE_DOWN,       _settings_newgame.game_creation.starting_year <= MIN_YEAR);
 
		this->SetWidgetDisabledState(WID_CS_START_DATE_UP,         _settings_newgame.game_creation.starting_year >= MAX_YEAR);
 
		this->SetWidgetDisabledState(WID_CS_START_DATE_DOWN,       _settings_newgame.game_creation.starting_year <= CalendarTime::MIN_YEAR);
 
		this->SetWidgetDisabledState(WID_CS_START_DATE_UP,         _settings_newgame.game_creation.starting_year >= CalendarTime::MAX_YEAR);
 
		this->SetWidgetDisabledState(WID_CS_FLAT_LAND_HEIGHT_DOWN, _settings_newgame.game_creation.se_flat_world_height <= 0);
 
		this->SetWidgetDisabledState(WID_CS_FLAT_LAND_HEIGHT_UP,   _settings_newgame.game_creation.se_flat_world_height >= GetMapHeightLimit());
 

	
 
		this->SetWidgetLoweredState(WID_CS_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
 
		this->SetWidgetLoweredState(WID_CS_ARCTIC,    _settings_newgame.game_creation.landscape == LT_ARCTIC);
 
		this->SetWidgetLoweredState(WID_CS_TROPICAL,  _settings_newgame.game_creation.landscape == LT_TROPIC);
 
@@ -1140,13 +1140,13 @@ struct CreateScenarioWindow : public Win
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		StringID str = STR_JUST_INT;
 
		switch (widget) {
 
			case WID_CS_START_DATE_TEXT:
 
				SetDParam(0, TimerGameCalendar::ConvertYMDToDate(MAX_YEAR, 0, 1));
 
				SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1));
 
				str = STR_JUST_DATE_LONG;
 
				break;
 

	
 
			case WID_CS_MAPSIZE_X_PULLDOWN:
 
			case WID_CS_MAPSIZE_Y_PULLDOWN:
 
				SetDParamMaxValue(0, MAX_MAP_SIZE);
 
@@ -1196,13 +1196,13 @@ struct CreateScenarioWindow : public Win
 
			case WID_CS_START_DATE_UP: // Year buttons
 
				/* Don't allow too fast scrolling */
 
				if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
 
					this->HandleButtonClick(widget);
 
					this->SetDirty();
 

	
 
					_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - WID_CS_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
 
					_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - WID_CS_START_DATE_TEXT, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
 
				}
 
				_left_button_clicked = false;
 
				break;
 

	
 
			case WID_CS_START_DATE_TEXT: // Year text
 
				this->widget_id = WID_CS_START_DATE_TEXT;
 
@@ -1255,13 +1255,13 @@ struct CreateScenarioWindow : public Win
 
		if (!StrEmpty(str)) {
 
			int32_t value = atoi(str);
 

	
 
			switch (this->widget_id) {
 
				case WID_CS_START_DATE_TEXT:
 
					this->SetWidgetDirty(WID_CS_START_DATE_TEXT);
 
					_settings_newgame.game_creation.starting_year = Clamp(TimerGameCalendar::Year(value), MIN_YEAR, MAX_YEAR);
 
					_settings_newgame.game_creation.starting_year = Clamp(TimerGameCalendar::Year(value), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
 
					break;
 

	
 
				case WID_CS_FLAT_LAND_HEIGHT_TEXT:
 
					this->SetWidgetDirty(WID_CS_FLAT_LAND_HEIGHT_TEXT);
 
					_settings_newgame.game_creation.se_flat_world_height = Clamp(value, 0, GetMapHeightLimit());
 
					break;
src/linkgraph/flowmapper.cpp
Show inline comments
 
@@ -47,13 +47,13 @@ void FlowMapper::Run(LinkGraphJob &job) 
 
		FlowStatMap &flows = node.flows;
 
		flows.FinalizeLocalConsumption(node.base.station);
 
		if (this->scale) {
 
			/* Scale by time the graph has been running without being compressed. Add 1 to avoid
 
			 * division by 0 if spawn date == last compression date. This matches
 
			 * LinkGraph::Monthly(). */
 
			auto runtime = job.JoinDate() - job.Settings().recalc_time / SECONDS_PER_DAY - job.LastCompression() + 1;
 
			auto runtime = job.JoinDate() - job.Settings().recalc_time / CalendarTime::SECONDS_PER_DAY - job.LastCompression() + 1;
 
			for (auto &it : flows) {
 
				it.second.ScaleToMonthly(static_cast<int32_t>(runtime));
 
			}
 
		}
 
		/* Clear paths. */
 
		for (Path *i : node.paths) delete i;
src/linkgraph/linkgraph.cpp
Show inline comments
 
@@ -26,25 +26,25 @@ INSTANTIATE_POOL_METHODS(LinkGraph)
 
LinkGraph::BaseNode::BaseNode(TileIndex xy, StationID st, uint demand)
 
{
 
	this->xy = xy;
 
	this->supply = 0;
 
	this->demand = demand;
 
	this->station = st;
 
	this->last_update = INVALID_DATE;
 
	this->last_update = CalendarTime::INVALID_DATE;
 
}
 

	
 
/**
 
 * Create an edge.
 
 */
 
LinkGraph::BaseEdge::BaseEdge(NodeID dest_node)
 
{
 
	this->capacity = 0;
 
	this->usage = 0;
 
	this->travel_time_sum = 0;
 
	this->last_unrestricted_update = INVALID_DATE;
 
	this->last_restricted_update = INVALID_DATE;
 
	this->last_unrestricted_update = CalendarTime::INVALID_DATE;
 
	this->last_restricted_update = CalendarTime::INVALID_DATE;
 
	this->dest_node = dest_node;
 
}
 

	
 
/**
 
 * Shift all dates by given interval.
 
 * This is useful if the date has been modified with the cheat menu.
 
@@ -52,16 +52,16 @@ LinkGraph::BaseEdge::BaseEdge(NodeID des
 
 */
 
void LinkGraph::ShiftDates(TimerGameCalendar::Date interval)
 
{
 
	this->last_compression += interval;
 
	for (NodeID node1 = 0; node1 < this->Size(); ++node1) {
 
		BaseNode &source = this->nodes[node1];
 
		if (source.last_update != INVALID_DATE) source.last_update += interval;
 
		if (source.last_update != CalendarTime::INVALID_DATE) source.last_update += interval;
 
		for (BaseEdge &edge : this->nodes[node1].edges) {
 
			if (edge.last_unrestricted_update != INVALID_DATE) edge.last_unrestricted_update += interval;
 
			if (edge.last_restricted_update != INVALID_DATE) edge.last_restricted_update += interval;
 
			if (edge.last_unrestricted_update != CalendarTime::INVALID_DATE) edge.last_unrestricted_update += interval;
 
			if (edge.last_restricted_update != CalendarTime::INVALID_DATE) edge.last_restricted_update += interval;
 
		}
 
	}
 
}
 

	
 
void LinkGraph::Compress()
 
{
src/linkgraph/linkgraph.h
Show inline comments
 
@@ -60,14 +60,14 @@ public:
 
		 * Get the date of the last update to any part of the edge's capacity.
 
		 * @return Last update.
 
		 */
 
		TimerGameCalendar::Date LastUpdate() const { return std::max(this->last_unrestricted_update, this->last_restricted_update); }
 

	
 
		void Update(uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode);
 
		void Restrict() { this->last_unrestricted_update = INVALID_DATE; }
 
		void Release() { this->last_restricted_update = INVALID_DATE; }
 
		void Restrict() { this->last_unrestricted_update = CalendarTime::INVALID_DATE; }
 
		void Release() { this->last_restricted_update = CalendarTime::INVALID_DATE; }
 

	
 
		/** Comparison operator based on \c dest_node. */
 
		bool operator <(const BaseEdge &rhs) const
 
		{
 
			return this->dest_node < rhs.dest_node;
 
		}
src/linkgraph/linkgraphjob.cpp
Show inline comments
 
@@ -34,13 +34,13 @@ INSTANTIATE_POOL_METHODS(LinkGraphJob)
 
 */
 
LinkGraphJob::LinkGraphJob(const LinkGraph &orig) :
 
		/* Copying the link graph here also copies its index member.
 
		 * This is on purpose. */
 
		link_graph(orig),
 
		settings(_settings_game.linkgraph),
 
		join_date(TimerGameCalendar::date + (_settings_game.linkgraph.recalc_time / SECONDS_PER_DAY)),
 
		join_date(TimerGameCalendar::date + (_settings_game.linkgraph.recalc_time / CalendarTime::SECONDS_PER_DAY)),
 
		job_completed(false),
 
		job_aborted(false)
 
{
 
}
 

	
 
/**
 
@@ -128,20 +128,20 @@ LinkGraphJob::~LinkGraphJob()
 
			NodeID dest_id = edge.base.dest_node;
 
			StationID to = this->nodes[dest_id].base.station;
 
			Station *st2 = Station::GetIfValid(to);
 
			if (st2 == nullptr || st2->goods[this->Cargo()].link_graph != this->link_graph.index ||
 
					st2->goods[this->Cargo()].node != dest_id ||
 
					!(*lg)[node_id].HasEdgeTo(dest_id) ||
 
					(*lg)[node_id][dest_id].LastUpdate() == INVALID_DATE) {
 
					(*lg)[node_id][dest_id].LastUpdate() == CalendarTime::INVALID_DATE) {
 
				/* Edge has been removed. Delete flows. */
 
				StationIDStack erased = flows.DeleteFlows(to);
 
				/* Delete old flows for source stations which have been deleted
 
				 * from the new flows. This avoids flow cycles between old and
 
				 * new flows. */
 
				while (!erased.IsEmpty()) ge.flows.erase(erased.Pop());
 
			} else if ((*lg)[node_id][dest_id].last_restricted_update == INVALID_DATE) {
 
			} else if ((*lg)[node_id][dest_id].last_restricted_update == CalendarTime::INVALID_DATE) {
 
				/* Edge is fully restricted. */
 
				flows.RestrictFlows(to);
 
			}
 
		}
 

	
 
		/* Swap shares and invalidate ones that are completely deleted. Don't
src/linkgraph/linkgraphjob.h
Show inline comments
 
@@ -175,13 +175,13 @@ protected:
 
public:
 
	/**
 
	 * Bare constructor, only for save/load. link_graph, join_date and actually
 
	 * settings have to be brutally const-casted in order to populate them.
 
	 */
 
	LinkGraphJob() : settings(_settings_game.linkgraph),
 
			join_date(INVALID_DATE), job_completed(false), job_aborted(false) {}
 
			join_date(CalendarTime::INVALID_DATE), job_completed(false), job_aborted(false) {}
 

	
 
	LinkGraphJob(const LinkGraph &orig);
 
	~LinkGraphJob();
 

	
 
	void Init();
 

	
src/linkgraph/linkgraphschedule.cpp
Show inline comments
 
@@ -175,13 +175,13 @@ void StateGameLoop_LinkGraphPauseControl
 
		/* We are paused waiting on a job, check the job every tick. */
 
		if (!LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) {
 
			Command<CMD_PAUSE>::Post(PM_PAUSED_LINK_GRAPH, false);
 
		}
 
	} else if (_pause_mode == PM_UNPAUSED &&
 
			TimerGameCalendar::date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 2 &&
 
			static_cast<int32_t>(TimerGameCalendar::date) % (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY) == (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY) / 2 &&
 
			static_cast<int32_t>(TimerGameCalendar::date) % (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) == (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) / 2 &&
 
			LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) {
 
		/* Perform check two TimerGameCalendar::date_fract ticks before we would join, to make
 
		 * sure it also works in multiplayer. */
 
		Command<CMD_PAUSE>::Post(PM_PAUSED_LINK_GRAPH, true);
 
	}
 
}
 
@@ -202,16 +202,16 @@ void AfterLoad_LinkGraphPauseControl()
 
 * Spawn or join a link graph job or compress a link graph if any link graph is
 
 * due to do so.
 
 */
 
void OnTick_LinkGraph()
 
{
 
	if (TimerGameCalendar::date_fract != LinkGraphSchedule::SPAWN_JOIN_TICK) return;
 
	TimerGameCalendar::Date offset = static_cast<int32_t>(TimerGameCalendar::date) % (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY);
 
	TimerGameCalendar::Date offset = static_cast<int32_t>(TimerGameCalendar::date) % (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY);
 
	if (offset == 0) {
 
		LinkGraphSchedule::instance.SpawnNext();
 
	} else if (offset == (_settings_game.linkgraph.recalc_interval / SECONDS_PER_DAY) / 2) {
 
	} else if (offset == (_settings_game.linkgraph.recalc_interval / CalendarTime::SECONDS_PER_DAY) / 2) {
 
		if (!_networking || _network_server) {
 
			PerformanceMeasurer::SetInactive(PFE_GL_LINKGRAPH);
 
			LinkGraphSchedule::instance.JoinNext();
 
		} else {
 
			PerformanceMeasurer framerate(PFE_GL_LINKGRAPH);
 
			LinkGraphSchedule::instance.JoinNext();
src/misc_gui.cpp
Show inline comments
 
@@ -135,13 +135,13 @@ public:
 
	{
 
		Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
 

	
 
		/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
 
		TileDesc td;
 

	
 
		td.build_date = INVALID_DATE;
 
		td.build_date = CalendarTime::INVALID_DATE;
 

	
 
		/* Most tiles have only one owner, but
 
		 *  - drivethrough roadstops can be build on town owned roads (up to 2 owners) and
 
		 *  - roads can have up to four owners (railroad, road, tram, 3rd-roadtype "highway").
 
		 */
 
		td.owner_type[0] = STR_LAND_AREA_INFORMATION_OWNER; // At least one owner is displayed, though it might be "N/A".
 
@@ -221,13 +221,13 @@ public:
 
			SetDParam(0, STR_TOWN_NAME);
 
			SetDParam(1, t->index);
 
		}
 
		this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY));
 

	
 
		/* Build date */
 
		if (td.build_date != INVALID_DATE) {
 
		if (td.build_date != CalendarTime::INVALID_DATE) {
 
			SetDParam(0, td.build_date);
 
			this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_BUILD_DATE));
 
		}
 

	
 
		/* Station class */
 
		if (td.station_class != STR_NULL) {
src/network/core/network_game_info.cpp
Show inline comments
 
@@ -252,14 +252,12 @@ void SerializeNetworkGameInfo(Packet *p,
 
 * Deserializes the NetworkGameInfo struct from the packet.
 
 * @param p    the packet to read the data from.
 
 * @param info the NetworkGameInfo to deserialize into.
 
 */
 
void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfoNewGRFLookupTable *newgrf_lookup_table)
 
{
 
	static const TimerGameCalendar::Date MAX_DATE = TimerGameCalendar::ConvertYMDToDate(MAX_YEAR, 11, 31); // December is month 11
 

	
 
	byte game_info_version = p->Recv_uint8();
 
	NewGRFSerializationType newgrf_serialisation = NST_GRFID_MD5;
 

	
 
	/*
 
	 *              Please observe the order.
 
	 * The parts must be read in the same order as they are sent!
 
@@ -320,14 +318,14 @@ void DeserializeNetworkGameInfo(Packet *
 
				dst = &c->next;
 
			}
 
			FALLTHROUGH;
 
		}
 

	
 
		case 3:
 
			info->game_date      = Clamp(p->Recv_uint32(), 0, static_cast<int32_t>(MAX_DATE));
 
			info->start_date     = Clamp(p->Recv_uint32(), 0, static_cast<int32_t>(MAX_DATE));
 
			info->game_date      = Clamp(p->Recv_uint32(), 0, static_cast<int32_t>(CalendarTime::MAX_DATE));
 
			info->start_date     = Clamp(p->Recv_uint32(), 0, static_cast<int32_t>(CalendarTime::MAX_DATE));
 
			FALLTHROUGH;
 

	
 
		case 2:
 
			info->companies_max  = p->Recv_uint8 ();
 
			info->companies_on   = p->Recv_uint8 ();
 
			p->Recv_uint8(); // Used to contain max-spectators.
 
@@ -339,14 +337,14 @@ void DeserializeNetworkGameInfo(Packet *
 
			if (game_info_version < 6) p->Recv_uint8 (); // Used to contain server-lang.
 
			info->use_password   = p->Recv_bool  ();
 
			info->clients_max    = p->Recv_uint8 ();
 
			info->clients_on     = p->Recv_uint8 ();
 
			info->spectators_on  = p->Recv_uint8 ();
 
			if (game_info_version < 3) { // 16 bits dates got scrapped and are read earlier
 
				info->game_date    = p->Recv_uint16() + DAYS_TILL_ORIGINAL_BASE_YEAR;
 
				info->start_date   = p->Recv_uint16() + DAYS_TILL_ORIGINAL_BASE_YEAR;
 
				info->game_date    = p->Recv_uint16() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
				info->start_date   = p->Recv_uint16() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			}
 
			if (game_info_version < 6) while (p->Recv_uint8() != 0) {} // Used to contain the map-name.
 
			info->map_width      = p->Recv_uint16();
 
			info->map_height     = p->Recv_uint16();
 
			info->landscape      = p->Recv_uint8 ();
 
			info->dedicated      = p->Recv_bool  ();
src/newgrf.cpp
Show inline comments
 
@@ -993,13 +993,13 @@ typedef ChangeInfoResult (*VCI_Handler)(
 
 * @return ChangeInfoResult.
 
 */
 
static ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteReader *buf)
 
{
 
	switch (prop) {
 
		case 0x00: // Introduction date
 
			ei->base_intro = buf->ReadWord() + DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			ei->base_intro = buf->ReadWord() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			break;
 

	
 
		case 0x02: // Decay speed
 
			ei->decay_speed = buf->ReadByte();
 
			break;
 

	
 
@@ -2194,13 +2194,13 @@ static ChangeInfoResult BridgeChangeInfo
 
		BridgeSpec *bridge = &_bridge[brid + i];
 

	
 
		switch (prop) {
 
			case 0x08: { // Year of availability
 
				/* We treat '0' as always available */
 
				byte year = buf->ReadByte();
 
				bridge->avail_year = (year > 0 ? ORIGINAL_BASE_YEAR + year : 0);
 
				bridge->avail_year = (year > 0 ? CalendarTime::ORIGINAL_BASE_YEAR + year : 0);
 
				break;
 
			}
 

	
 
			case 0x09: // Minimum length
 
				bridge->min_length = buf->ReadByte();
 
				break;
 
@@ -2254,13 +2254,13 @@ static ChangeInfoResult BridgeChangeInfo
 

	
 
			case 0x0E: // Flags; bit 0 - disable far pillars
 
				bridge->flags = buf->ReadByte();
 
				break;
 

	
 
			case 0x0F: // Long format year of availability (year since year 0)
 
				bridge->avail_year = Clamp(TimerGameCalendar::Year(buf->ReadDWord()), MIN_YEAR, MAX_YEAR);
 
				bridge->avail_year = Clamp(TimerGameCalendar::Year(buf->ReadDWord()), CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
 
				break;
 

	
 
			case 0x10: { // purchase string
 
				StringID newone = GetGRFStringID(_cur.grffile->grfid, buf->ReadWord());
 
				if (newone != STR_UNDEFINED) bridge->material = newone;
 
				break;
 
@@ -2427,14 +2427,14 @@ static ChangeInfoResult TownHouseChangeI
 
			case 0x09: // Building flags
 
				housespec->building_flags = (BuildingFlags)buf->ReadByte();
 
				break;
 

	
 
			case 0x0A: { // Availability years
 
				uint16_t years = buf->ReadWord();
 
				housespec->min_year = GB(years, 0, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 0, 8);
 
				housespec->max_year = GB(years, 8, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 8, 8);
 
				housespec->min_year = GB(years, 0, 8) > 150 ? CalendarTime::MAX_YEAR : CalendarTime::ORIGINAL_BASE_YEAR + GB(years, 0, 8);
 
				housespec->max_year = GB(years, 8, 8) > 150 ? CalendarTime::MAX_YEAR : CalendarTime::ORIGINAL_BASE_YEAR + GB(years, 8, 8);
 
				break;
 
			}
 

	
 
			case 0x0B: // Population
 
				housespec->population = buf->ReadByte();
 
				break;
 
@@ -3988,13 +3988,13 @@ static ChangeInfoResult AirportChangeInf
 
				break;
 
			}
 

	
 
			case 0x0C:
 
				as->min_year = buf->ReadWord();
 
				as->max_year = buf->ReadWord();
 
				if (as->max_year == 0xFFFF) as->max_year = MAX_YEAR;
 
				if (as->max_year == 0xFFFF) as->max_year = CalendarTime::MAX_YEAR;
 
				break;
 

	
 
			case 0x0D:
 
				as->ttd_airport_type = (TTDPAirportType)buf->ReadByte();
 
				break;
 

	
 
@@ -6509,17 +6509,17 @@ static void SkipAct5(ByteReader *buf)
 
 * @return true iff the variable is known and the value is returned in 'value'.
 
 */
 
bool GetGlobalVariable(byte param, uint32_t *value, const GRFFile *grffile)
 
{
 
	switch (param) {
 
		case 0x00: // current date
 
			*value = static_cast<int32_t>(std::max(TimerGameCalendar::date - DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::Date(0)));
 
			*value = static_cast<int32_t>(std::max(TimerGameCalendar::date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::Date(0)));
 
			return true;
 

	
 
		case 0x01: // current year
 
			*value = static_cast<int32_t>(Clamp(TimerGameCalendar::year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR);
 
			*value = static_cast<int32_t>(Clamp(TimerGameCalendar::year, CalendarTime::ORIGINAL_BASE_YEAR, CalendarTime::ORIGINAL_MAX_YEAR) - CalendarTime::ORIGINAL_BASE_YEAR);
 
			return true;
 

	
 
		case 0x02: { // detailed date information: month of year (bit 0-7), day of month (bit 8-12), leap year (bit 15), day of year (bit 16-24)
 
			TimerGameCalendar::YearMonthDay ymd;
 
			TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::date, &ymd);
 
			TimerGameCalendar::Date start_of_year = TimerGameCalendar::ConvertYMDToDate(ymd.year, 0, 1);
 
@@ -7225,13 +7225,13 @@ static void SafeParamSet(ByteReader *buf
 

	
 

	
 
static uint32_t GetPatchVariable(uint8_t param)
 
{
 
	switch (param) {
 
		/* start year - 1920 */
 
		case 0x0B: return static_cast<int32_t>(std::max(_settings_game.game_creation.starting_year, ORIGINAL_BASE_YEAR) - ORIGINAL_BASE_YEAR);
 
		case 0x0B: return static_cast<int32_t>(std::max(_settings_game.game_creation.starting_year, CalendarTime::ORIGINAL_BASE_YEAR) - CalendarTime::ORIGINAL_BASE_YEAR);
 

	
 
		/* freight trains weight factor */
 
		case 0x0E: return _settings_game.vehicle.freight_trains;
 

	
 
		/* empty wagon speed increase */
 
		case 0x0F: return 0;
 
@@ -9234,13 +9234,13 @@ static bool IsHouseSpecValid(HouseSpec *
 
 * climate / housezone combination.
 
 * @param bitmask The climate and housezone to check for. Exactly one climate
 
 *   bit and one housezone bit should be set.
 
 */
 
static void EnsureEarlyHouse(HouseZones bitmask)
 
{
 
	TimerGameCalendar::Year min_year = MAX_YEAR;
 
	TimerGameCalendar::Year min_year = CalendarTime::MAX_YEAR;
 

	
 
	for (int i = 0; i < NUM_HOUSES; i++) {
 
		HouseSpec *hs = HouseSpec::Get(i);
 
		if (hs == nullptr || !hs->enabled) continue;
 
		if ((hs->building_availability & bitmask) != bitmask) continue;
 
		if (hs->min_year < min_year) min_year = hs->min_year;
src/newgrf_airport.cpp
Show inline comments
 
@@ -209,13 +209,13 @@ void AirportOverrideManager::SetEntitySp
 

	
 
	switch (variable) {
 
		/* Get a variable from the persistent storage */
 
		case 0x7C: return (this->st->airport.psa != nullptr) ? this->st->airport.psa->GetValue(parameter) : 0;
 

	
 
		case 0xF0: return this->st->facilities;
 
		case 0xFA: return ClampTo<uint16_t>(this->st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR);
 
		case 0xFA: return ClampTo<uint16_t>(this->st->build_date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR);
 
	}
 

	
 
	return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
 
}
 

	
 
GrfSpecFeature AirportResolverObject::GetFeature() const
src/newgrf_engine.cpp
Show inline comments
 
@@ -764,14 +764,14 @@ static uint32_t VehicleGetVariable(Vehic
 
					case VEH_AIRCRAFT: ticks = Aircraft::From(v)->turn_counter; break;
 
					default:           ticks = 0; break;
 
				}
 
			}
 
			return (variable - 0x80) == 0x10 ? ticks : GB(ticks, 8, 8);
 
		}
 
		case 0x12: return ClampTo<uint16_t>(v->date_of_last_service_newgrf - DAYS_TILL_ORIGINAL_BASE_YEAR);
 
		case 0x13: return GB(ClampTo<uint16_t>(v->date_of_last_service_newgrf - DAYS_TILL_ORIGINAL_BASE_YEAR), 8, 8);
 
		case 0x12: return ClampTo<uint16_t>(v->date_of_last_service_newgrf - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR);
 
		case 0x13: return GB(ClampTo<uint16_t>(v->date_of_last_service_newgrf - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR), 8, 8);
 
		case 0x14: return v->GetServiceInterval();
 
		case 0x15: return GB(v->GetServiceInterval(), 8, 8);
 
		case 0x16: return v->last_station_visited;
 
		case 0x17: return v->tick_counter;
 
		case 0x18:
 
		case 0x19: {
 
@@ -826,13 +826,13 @@ static uint32_t VehicleGetVariable(Vehic
 
		case 0x3E: return v->cargo.GetFirstStation();
 
		case 0x3F: return ClampTo<uint8_t>(v->cargo.PeriodsInTransit());
 
		case 0x40: return ClampTo<uint16_t>(v->age);
 
		case 0x41: return GB(ClampTo<uint16_t>(v->age), 8, 8);
 
		case 0x42: return ClampTo<uint16_t>(v->max_age);
 
		case 0x43: return GB(ClampTo<uint16_t>(v->max_age), 8, 8);
 
		case 0x44: return static_cast<int32_t>(Clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR);
 
		case 0x44: return static_cast<int32_t>(Clamp(v->build_year, CalendarTime::ORIGINAL_BASE_YEAR, CalendarTime::ORIGINAL_MAX_YEAR) - CalendarTime::ORIGINAL_BASE_YEAR);
 
		case 0x45: return v->unitnumber;
 
		case 0x46: return v->GetEngine()->grf_prop.local_id;
 
		case 0x47: return GB(v->GetEngine()->grf_prop.local_id, 8, 8);
 
		case 0x48:
 
			if (v->type != VEH_TRAIN || v->spritenum != 0xFD) return v->spritenum;
 
			return HasBit(Train::From(v)->flags, VRF_REVERSE_DIRECTION) ? 0xFE : 0xFD;
 
@@ -971,15 +971,15 @@ static uint32_t VehicleGetVariable(Vehic
 
					return 0x000000FF;
 
				}
 
			}
 
			case 0x48: return Engine::Get(this->self_type)->flags; // Vehicle Type Info
 
			case 0x49: return static_cast<int32_t>(TimerGameCalendar::year); // 'Long' format build year
 
			case 0x4B: return static_cast<int32_t>(TimerGameCalendar::date); // Long date of last service
 
			case 0x92: return ClampTo<uint16_t>(TimerGameCalendar::date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Date of last service
 
			case 0x93: return GB(ClampTo<uint16_t>(TimerGameCalendar::date - DAYS_TILL_ORIGINAL_BASE_YEAR), 8, 8);
 
			case 0xC4: return static_cast<int32_t>(Clamp(TimerGameCalendar::year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR); // Build year
 
			case 0x92: return ClampTo<uint16_t>(TimerGameCalendar::date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Date of last service
 
			case 0x93: return GB(ClampTo<uint16_t>(TimerGameCalendar::date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR), 8, 8);
 
			case 0xC4: return static_cast<int32_t>(Clamp(TimerGameCalendar::year, CalendarTime::ORIGINAL_BASE_YEAR, CalendarTime::ORIGINAL_MAX_YEAR) - CalendarTime::ORIGINAL_BASE_YEAR); // Build year
 
			case 0xC6: return Engine::Get(this->self_type)->grf_prop.local_id;
 
			case 0xC7: return GB(Engine::Get(this->self_type)->grf_prop.local_id, 8, 8);
 
			case 0xDA: return INVALID_VEHICLE; // Next vehicle
 
			case 0xF2: return 0; // Cargo subtype
 
		}
 

	
src/newgrf_industries.cpp
Show inline comments
 
@@ -393,22 +393,22 @@ static uint32_t GetCountAndDistanceOfClo
 
		case 0xA4: return this->industry->produced[1].history[LAST_MONTH].transported;
 
		case 0xA5: return GB(this->industry->produced[1].history[LAST_MONTH].transported, 8, 8);
 

	
 
		case 0xA6: return indspec->grf_prop.local_id;
 
		case 0xA7: return this->industry->founder;
 
		case 0xA8: return this->industry->random_colour;
 
		case 0xA9: return ClampTo<uint8_t>(this->industry->last_prod_year - ORIGINAL_BASE_YEAR);
 
		case 0xA9: return ClampTo<uint8_t>(this->industry->last_prod_year - CalendarTime::ORIGINAL_BASE_YEAR);
 
		case 0xAA: return this->industry->counter;
 
		case 0xAB: return GB(this->industry->counter, 8, 8);
 
		case 0xAC: return this->industry->was_cargo_delivered;
 

	
 
		case 0xB0: return ClampTo<uint16_t>(this->industry->construction_date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Date when built since 1920 (in days)
 
		case 0xB0: return ClampTo<uint16_t>(this->industry->construction_date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Date when built since 1920 (in days)
 
		case 0xB3: return this->industry->construction_type; // Construction type
 
		case 0xB4: {
 
			auto it = std::max_element(std::begin(this->industry->accepted), std::end(this->industry->accepted), [](const auto &a, const auto &b) { return a.last_accepted < b.last_accepted; });
 
			return ClampTo<uint16_t>(it->last_accepted - DAYS_TILL_ORIGINAL_BASE_YEAR); // Date last cargo accepted since 1920 (in days)
 
			return ClampTo<uint16_t>(it->last_accepted - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Date last cargo accepted since 1920 (in days)
 
		}
 
	}
 

	
 
	Debug(grf, 1, "Unhandled industry variable 0x{:X}", variable);
 

	
 
	*available = false;
src/newgrf_roadstop.cpp
Show inline comments
 
@@ -170,13 +170,13 @@ uint32_t RoadStopScopeResolver::GetVaria
 
			const RoadStopSpecList ssl = BaseStation::GetByTile(nearby_tile)->roadstop_speclist[GetCustomRoadStopSpecIndex(nearby_tile)];
 
			return ssl.grfid;
 
		}
 

	
 
		case 0xF0: return this->st == nullptr ? 0 : this->st->facilities; // facilities
 

	
 
		case 0xFA: return ClampTo<uint16_t>((this->st == nullptr ? TimerGameCalendar::date : this->st->build_date) - DAYS_TILL_ORIGINAL_BASE_YEAR); // build date
 
		case 0xFA: return ClampTo<uint16_t>((this->st == nullptr ? TimerGameCalendar::date : this->st->build_date) - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // build date
 
	}
 

	
 
	if (this->st != nullptr) return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
 

	
 
	*available = false;
 
	return UINT_MAX;
src/newgrf_station.cpp
Show inline comments
 
@@ -288,13 +288,13 @@ TownScopeResolver *StationResolverObject
 
					bool swap = (this->axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
 

	
 
					return GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
 
				}
 
				break;
 

	
 
			case 0xFA: return ClampTo<uint16_t>(TimerGameCalendar::date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value
 
			case 0xFA: return ClampTo<uint16_t>(TimerGameCalendar::date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value
 
		}
 

	
 
		*available = false;
 
		return UINT_MAX;
 
	}
 

	
 
@@ -378,13 +378,13 @@ TownScopeResolver *StationResolverObject
 

	
 
		/* General station variables */
 
		case 0x82: return 50;
 
		case 0x84: return this->st->string_id;
 
		case 0x86: return 0;
 
		case 0xF0: return this->st->facilities;
 
		case 0xFA: return ClampTo<uint16_t>(this->st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR);
 
		case 0xFA: return ClampTo<uint16_t>(this->st->build_date - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR);
 
	}
 

	
 
	return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
 
}
 

	
 
uint32_t Station::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
src/newgrf_text.cpp
Show inline comments
 
@@ -20,12 +20,13 @@
 
#include "newgrf.h"
 
#include "strings_internal.h"
 
#include "newgrf_storage.h"
 
#include "newgrf_text.h"
 
#include "newgrf_cargo.h"
 
#include "string_func.h"
 
#include "timer/timer_game_calendar.h"
 
#include "date_type.h"
 
#include "debug.h"
 
#include "core/alloc_type.hpp"
 
#include "language.h"
 
#include <sstream>
 

	
 
@@ -909,13 +910,13 @@ uint RemapNewGRFStringControlCode(uint s
 
			case SCC_NEWGRF_PRINT_DWORD_DATE_LONG:
 
			case SCC_NEWGRF_PRINT_DWORD_DATE_SHORT:
 
			case SCC_NEWGRF_PRINT_DWORD_HEX:        parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedDWord()); break;
 

	
 
			/* Dates from NewGRFs have 1920-01-01 as their zero point, convert it to OpenTTD's epoch. */
 
			case SCC_NEWGRF_PRINT_WORD_DATE_LONG:
 
			case SCC_NEWGRF_PRINT_WORD_DATE_SHORT:  parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedWord() + DAYS_TILL_ORIGINAL_BASE_YEAR); break;
 
			case SCC_NEWGRF_PRINT_WORD_DATE_SHORT:  parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedWord() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); break;
 

	
 
			case SCC_NEWGRF_DISCARD_WORD:           _newgrf_textrefstack.PopUnsignedWord(); break;
 

	
 
			case SCC_NEWGRF_ROTATE_TOP_4_WORDS:     _newgrf_textrefstack.RotateTop4Words(); break;
 
			case SCC_NEWGRF_PUSH_WORD:              _newgrf_textrefstack.PushWord(Utf8Consume(str)); break;
 

	
src/news_gui.cpp
Show inline comments
 
@@ -1131,13 +1131,13 @@ struct MessageHistoryWindow : Window {
 
		if (widget == WID_MH_BACKGROUND) {
 
			this->line_height = FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
 
			resize->height = this->line_height;
 

	
 
			/* Months are off-by-one, so it's actually 8. Not using
 
			 * month 12 because the 1 is usually less wide. */
 
			SetDParam(0, TimerGameCalendar::ConvertYMDToDate(ORIGINAL_MAX_YEAR, 7, 30));
 
			SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::ORIGINAL_MAX_YEAR, 7, 30));
 
			this->date_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width + WidgetDimensions::scaled.hsep_wide;
 

	
 
			size->height = 4 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); // At least 4 lines are visible.
 
			size->width = std::max(200u, size->width); // At least 200 pixels wide.
 
		}
 
	}
src/openttd.cpp
Show inline comments
 
@@ -377,13 +377,13 @@ void OpenBrowser(const char *url)
 
		OSOpenBrowser(url);
 
	}
 
}
 

	
 
/** Callback structure of statements to be executed after the NewGRF scan. */
 
struct AfterNewGRFScan : NewGRFScanCallback {
 
	TimerGameCalendar::Year startyear = INVALID_YEAR; ///< The start year.
 
	TimerGameCalendar::Year startyear = CalendarTime::INVALID_YEAR; ///< The start year.
 
	uint32_t generation_seed = GENERATE_NEW_SEED; ///< Seed for the new game.
 
	std::string dedicated_host;                 ///< Hostname for the dedicated server.
 
	uint16_t dedicated_port = 0;                  ///< Port for the dedicated server.
 
	std::string connection_string;              ///< Information about the server to connect to
 
	std::string join_server_password;           ///< The password to join the server with.
 
	std::string join_company_password;          ///< The password to join the company with.
 
@@ -426,13 +426,13 @@ struct AfterNewGRFScan : NewGRFScanCallb
 
		_save_config = save_config;
 

	
 
		/* restore saved music and effects volumes */
 
		MusicDriver::GetInstance()->SetVolume(_settings_client.music.music_vol);
 
		SetEffectVolume(_settings_client.music.effect_vol);
 

	
 
		if (startyear != INVALID_YEAR) IConsoleSetSetting("game_creation.starting_year", static_cast<int32_t>(startyear));
 
		if (startyear != CalendarTime::INVALID_YEAR) IConsoleSetSetting("game_creation.starting_year", static_cast<int32_t>(startyear));
 
		if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
 

	
 
		if (!dedicated_host.empty()) {
 
			_network_bind_list.clear();
 
			_network_bind_list.emplace_back(dedicated_host);
 
		}
src/order_base.h
Show inline comments
 
@@ -364,14 +364,14 @@ public:
 

	
 
	void RemoveVehicle(Vehicle *v);
 

	
 
	bool IsCompleteTimetable() const;
 

	
 
	/**
 
	 * Gets the total duration of the vehicles timetable or Tick::INVALID_TICKS is the timetable is not complete.
 
	 * @return total timetable duration or Tick::INVALID_TICKS for incomplete timetables
 
	 * Gets the total duration of the vehicles timetable or Ticks::INVALID_TICKS is the timetable is not complete.
 
	 * @return total timetable duration or Ticks::INVALID_TICKS for incomplete timetables
 
	 */
 
	inline TimerGameTick::Ticks GetTimetableTotalDuration() const { return this->IsCompleteTimetable() ? this->timetable_duration : Ticks::INVALID_TICKS; }
 

	
 
	/**
 
	 * Gets the known duration of the vehicles timetable even if the timetable is not complete.
 
	 * @return known timetable duration
src/order_cmd.cpp
Show inline comments
 
@@ -1944,16 +1944,16 @@ VehicleOrderID ProcessConditionalOrder(c
 

	
 
	switch (order->GetConditionVariable()) {
 
		case OCV_LOAD_PERCENTAGE:    skip_order = OrderConditionCompare(occ, CalcPercentVehicleFilled(v, nullptr), value); break;
 
		case OCV_RELIABILITY:        skip_order = OrderConditionCompare(occ, ToPercent16(v->reliability),       value); break;
 
		case OCV_MAX_RELIABILITY:    skip_order = OrderConditionCompare(occ, ToPercent16(v->GetEngine()->reliability),   value); break;
 
		case OCV_MAX_SPEED:          skip_order = OrderConditionCompare(occ, v->GetDisplayMaxSpeed() * 10 / 16, value); break;
 
		case OCV_AGE:                skip_order = OrderConditionCompare(occ, DateToYear(v->age),                value); break;
 
		case OCV_AGE:                skip_order = OrderConditionCompare(occ, TimerGameCalendar::DateToYear(v->age),                value); break;
 
		case OCV_REQUIRES_SERVICE:   skip_order = OrderConditionCompare(occ, v->NeedsServicing(),               value); break;
 
		case OCV_UNCONDITIONALLY:    skip_order = true; break;
 
		case OCV_REMAINING_LIFETIME: skip_order = OrderConditionCompare(occ, std::max(DateToYear(v->max_age - v->age + DAYS_IN_LEAP_YEAR - 1), TimerGameCalendar::Year(0)), value); break;
 
		case OCV_REMAINING_LIFETIME: skip_order = OrderConditionCompare(occ, std::max(TimerGameCalendar::DateToYear(v->max_age - v->age + CalendarTime::DAYS_IN_LEAP_YEAR - 1), TimerGameCalendar::Year(0)), value); break;
 
		default: NOT_REACHED();
 
	}
 

	
 
	return skip_order ? order->GetConditionSkipToOrder() : (VehicleOrderID)INVALID_VEH_ORDER_ID;
 
}
 

	
src/rail.cpp
Show inline comments
 
@@ -222,13 +222,13 @@ RailTypes AddDateIntroducedRailTypes(Rai
 
	for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
 
		const RailtypeInfo *rti = GetRailTypeInfo(rt);
 
		/* Unused rail type. */
 
		if (rti->label == 0) continue;
 

	
 
		/* Not date introduced. */
 
		if (!IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(MAX_DATE))) continue;
 
		if (!IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(CalendarTime::MAX_DATE))) continue;
 

	
 
		/* Not yet introduced at this date. */
 
		if (rti->introduction_date > date) continue;
 

	
 
		/* Have we introduced all required railtypes? */
 
		RailTypes required = rti->introduction_required_railtypes;
 
@@ -253,13 +253,13 @@ RailTypes GetCompanyRailtypes(CompanyID 
 
	RailTypes rts = RAILTYPES_NONE;
 

	
 
	for (const Engine *e : Engine::IterateType(VEH_TRAIN)) {
 
		const EngineInfo *ei = &e->info;
 

	
 
		if (HasBit(ei->climates, _settings_game.game_creation.landscape) &&
 
				(HasBit(e->company_avail, company) || TimerGameCalendar::date >= e->intro_date + DAYS_IN_YEAR)) {
 
				(HasBit(e->company_avail, company) || TimerGameCalendar::date >= e->intro_date + CalendarTime::DAYS_IN_YEAR)) {
 
			const RailVehicleInfo *rvi = &e->u.rail;
 

	
 
			if (rvi->railveh_type != RAILVEH_WAGON) {
 
				assert(rvi->railtype < RAILTYPE_END);
 
				if (introduces) {
 
					rts |= GetRailTypeInfo(rvi->railtype)->introduces_railtypes;
 
@@ -295,13 +295,13 @@ RailTypes GetRailTypes(bool introduces)
 
			} else {
 
				SetBit(rts, rvi->railtype);
 
			}
 
		}
 
	}
 

	
 
	if (introduces) return AddDateIntroducedRailTypes(rts, MAX_DATE);
 
	if (introduces) return AddDateIntroducedRailTypes(rts, CalendarTime::MAX_DATE);
 
	return rts;
 
}
 

	
 
/**
 
 * Get the rail type for a given label.
 
 * @param label the railtype label.
src/road.cpp
Show inline comments
 
@@ -112,13 +112,13 @@ bool HasRoadTypeAvail(const CompanyID co
 
{
 
	if (company == OWNER_DEITY || company == OWNER_TOWN || _game_mode == GM_EDITOR || _generating_world) {
 
		const RoadTypeInfo *rti = GetRoadTypeInfo(roadtype);
 
		if (rti->label == 0) return false;
 

	
 
		/* Not yet introduced at this date. */
 
		if (IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(MAX_DATE)) && rti->introduction_date > TimerGameCalendar::date) return false;
 
		if (IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(CalendarTime::MAX_DATE)) && rti->introduction_date > TimerGameCalendar::date) return false;
 

	
 
		/*
 
		 * Do not allow building hidden road types, except when a town may build it.
 
		 * The GS under deity mode, as well as anybody in the editor builds roads that are
 
		 * owned by towns. So if a town may build it, it should be buildable by them too.
 
		 */
 
@@ -170,13 +170,13 @@ RoadTypes AddDateIntroducedRoadTypes(Roa
 
	for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
 
		const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
 
		/* Unused road type. */
 
		if (rti->label == 0) continue;
 

	
 
		/* Not date introduced. */
 
		if (!IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(MAX_DATE))) continue;
 
		if (!IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(CalendarTime::MAX_DATE))) continue;
 

	
 
		/* Not yet introduced at this date. */
 
		if (rti->introduction_date > date) continue;
 

	
 
		/* Have we introduced all required roadtypes? */
 
		RoadTypes required = rti->introduction_required_roadtypes;
 
@@ -201,13 +201,13 @@ RoadTypes GetCompanyRoadTypes(CompanyID 
 
	RoadTypes rts = ROADTYPES_NONE;
 

	
 
	for (const Engine *e : Engine::IterateType(VEH_ROAD)) {
 
		const EngineInfo *ei = &e->info;
 

	
 
		if (HasBit(ei->climates, _settings_game.game_creation.landscape) &&
 
				(HasBit(e->company_avail, company) || TimerGameCalendar::date >= e->intro_date + DAYS_IN_YEAR)) {
 
				(HasBit(e->company_avail, company) || TimerGameCalendar::date >= e->intro_date + CalendarTime::DAYS_IN_YEAR)) {
 
			const RoadVehicleInfo *rvi = &e->u.road;
 
			assert(rvi->roadtype < ROADTYPE_END);
 
			if (introduces) {
 
				rts |= GetRoadTypeInfo(rvi->roadtype)->introduces_roadtypes;
 
			} else {
 
				SetBit(rts, rvi->roadtype);
 
@@ -238,13 +238,13 @@ RoadTypes GetRoadTypes(bool introduces)
 
			rts |= GetRoadTypeInfo(rvi->roadtype)->introduces_roadtypes;
 
		} else {
 
			SetBit(rts, rvi->roadtype);
 
		}
 
	}
 

	
 
	if (introduces) return AddDateIntroducedRoadTypes(rts, MAX_DATE);
 
	if (introduces) return AddDateIntroducedRoadTypes(rts, CalendarTime::MAX_DATE);
 
	return rts;
 
}
 

	
 
/**
 
 * Get the road type for a given label.
 
 * @param label the roadtype label.
 
@@ -299,10 +299,10 @@ RoadTypes ExistingRoadTypes(CompanyID c)
 
		if (e->company_avail != MAX_UVALUE(CompanyMask)) continue;
 

	
 
		known_roadtypes |= GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes;
 
	}
 

	
 
	/* Get the date introduced roadtypes as well. */
 
	known_roadtypes = AddDateIntroducedRoadTypes(known_roadtypes, MAX_DATE);
 
	known_roadtypes = AddDateIntroducedRoadTypes(known_roadtypes, CalendarTime::MAX_DATE);
 

	
 
	return known_roadtypes;
 
}
src/road_cmd.cpp
Show inline comments
 
@@ -147,13 +147,13 @@ RoadType AllocateRoadType(RoadTypeLabel 
 
		if (rti->label == 0) {
 
			/* Set up new road type */
 
			*rti = _original_roadtypes[(rtt == RTT_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD];
 
			rti->label = label;
 
			rti->alternate_labels.clear();
 
			rti->flags = ROTFB_NONE;
 
			rti->introduction_date = INVALID_DATE;
 
			rti->introduction_date = CalendarTime::INVALID_DATE;
 

	
 
			/* Make us compatible with ourself. */
 
			rti->powered_roadtypes = (RoadTypes)(1ULL << rt);
 

	
 
			/* We also introduce ourself. */
 
			rti->introduces_roadtypes = (RoadTypes)(1ULL << rt);
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1717,13 +1717,13 @@ void RoadVehicle::OnNewDay()
 
	CheckIfRoadVehNeedsService(this);
 

	
 
	CheckOrders(this);
 

	
 
	if (this->running_ticks == 0) return;
 

	
 
	CommandCost cost(EXPENSES_ROADVEH_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * Ticks::DAY_TICKS));
 
	CommandCost cost(EXPENSES_ROADVEH_RUN, this->GetRunningCost() * this->running_ticks / (CalendarTime::DAYS_IN_YEAR * Ticks::DAY_TICKS));
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
 

	
 
	SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
src/saveload/afterload.cpp
Show inline comments
 
@@ -256,13 +256,13 @@ static void InitializeWindowsAndCaches()
 
	ScriptObject::InitializeRandomizers();
 

	
 
	for (Company *c : Company::Iterate()) {
 
		/* For each company, verify (while loading a scenario) that the inauguration date is the current year and set it
 
		 * accordingly if it is not the case.  No need to set it on companies that are not been used already,
 
		 * thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */
 
		if (_file_to_saveload.abstract_ftype == FT_SCENARIO && c->inaugurated_year != MIN_YEAR) {
 
		if (_file_to_saveload.abstract_ftype == FT_SCENARIO && c->inaugurated_year != CalendarTime::MIN_YEAR) {
 
			c->inaugurated_year = TimerGameCalendar::year;
 
		}
 
	}
 

	
 
	/* Count number of objects per type */
 
	for (Object *o : Object::Iterate()) {
 
@@ -773,19 +773,19 @@ bool AfterLoadGame()
 
		_settings_game.linkgraph.distribution_mail = DT_MANUAL;
 
		_settings_game.linkgraph.distribution_armoured = DT_MANUAL;
 
		_settings_game.linkgraph.distribution_default = DT_MANUAL;
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_ENDING_YEAR)) {
 
		_settings_game.game_creation.ending_year = DEF_END_YEAR;
 
		_settings_game.game_creation.ending_year = CalendarTime::DEF_END_YEAR;
 
	}
 

	
 
	/* Convert linkgraph update settings from days to seconds. */
 
	if (IsSavegameVersionBefore(SLV_LINKGRAPH_SECONDS)) {
 
		_settings_game.linkgraph.recalc_interval *= SECONDS_PER_DAY;
 
		_settings_game.linkgraph.recalc_time     *= SECONDS_PER_DAY;
 
		_settings_game.linkgraph.recalc_interval *= CalendarTime::SECONDS_PER_DAY;
 
		_settings_game.linkgraph.recalc_time     *= CalendarTime::SECONDS_PER_DAY;
 
	}
 

	
 
	/* Load the sprites */
 
	GfxLoadSprites();
 
	LoadStringWidthTable();
 

	
 
@@ -1419,24 +1419,24 @@ bool AfterLoadGame()
 

	
 
	AfterLoadStations();
 

	
 
	/* Time starts at 0 instead of 1920.
 
	 * Account for this in older games by adding an offset */
 
	if (IsSavegameVersionBefore(SLV_31)) {
 
		TimerGameCalendar::date += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		TimerGameCalendar::year += ORIGINAL_BASE_YEAR;
 

	
 
		for (Station *st : Station::Iterate())   st->build_date      += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Waypoint *wp : Waypoint::Iterate()) wp->build_date      += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Engine *e : Engine::Iterate())      e->intro_date       += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Company *c : Company::Iterate()) c->inaugurated_year += ORIGINAL_BASE_YEAR;
 
		for (Industry *i : Industry::Iterate())  i->last_prod_year   += ORIGINAL_BASE_YEAR;
 
		TimerGameCalendar::date += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		TimerGameCalendar::year += CalendarTime::ORIGINAL_BASE_YEAR;
 

	
 
		for (Station *st : Station::Iterate())   st->build_date      += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Waypoint *wp : Waypoint::Iterate()) wp->build_date      += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Engine *e : Engine::Iterate())      e->intro_date       += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		for (Company *c : Company::Iterate()) c->inaugurated_year += CalendarTime::ORIGINAL_BASE_YEAR;
 
		for (Industry *i : Industry::Iterate())  i->last_prod_year   += CalendarTime::ORIGINAL_BASE_YEAR;
 

	
 
		for (Vehicle *v : Vehicle::Iterate()) {
 
			v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			v->build_year += ORIGINAL_BASE_YEAR;
 
			v->date_of_last_service += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			v->build_year += CalendarTime::ORIGINAL_BASE_YEAR;
 
		}
 
	}
 

	
 
	/* From 32 on we save the industry who made the farmland.
 
	 *  To give this prettiness to old savegames, we remove all farmfields and
 
	 *  plant new ones. */
 
@@ -1922,13 +1922,13 @@ bool AfterLoadGame()
 
					SetWaterClass(t, WATER_CLASS_INVALID);
 
				}
 
			}
 

	
 
			/* Replace "house construction year" with "house age" */
 
			if (IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)) {
 
				t.m5() = ClampTo<uint8_t>(TimerGameCalendar::year - (t.m5() + ORIGINAL_BASE_YEAR));
 
				t.m5() = ClampTo<uint8_t>(TimerGameCalendar::year - (t.m5() + CalendarTime::ORIGINAL_BASE_YEAR));
 
			}
 
		}
 
	}
 

	
 
	/* Move the signal variant back up one bit for PBS. We don't convert the old PBS
 
	 * format here, as an old layout wouldn't work properly anyway. To be safe, we
src/saveload/misc_sl.cpp
Show inline comments
 
@@ -132,13 +132,13 @@ struct DATEChunkHandler : ChunkHandler {
 

	
 
	void LoadCheck(size_t) const override
 
	{
 
		this->LoadCommon(_date_check_desc, _date_check_sl_compat);
 

	
 
		if (IsSavegameVersionBefore(SLV_31)) {
 
			_load_check_data.current_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			_load_check_data.current_date += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
		}
 
	}
 
};
 

	
 
static const SaveLoad _view_desc[] = {
 
	SLEG_CONDVAR("x",    _saved_scrollpos_x,    SLE_FILE_I16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_6),
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -395,25 +395,25 @@ static bool FixTTOEngines()
 
		for (uint i = 0; i < lengthof(_orig_rail_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_TRAIN, i);
 
		for (uint i = 0; i < lengthof(_orig_road_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_ROAD, i);
 
		for (uint i = 0; i < lengthof(_orig_ship_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_SHIP, i);
 
		for (uint i = 0; i < lengthof(_orig_aircraft_vehicle_info); i++, j++) new (GetTempDataEngine(j)) Engine(VEH_AIRCRAFT, i);
 
	}
 

	
 
	TimerGameCalendar::Date aging_date = std::min(TimerGameCalendar::date + DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::ConvertYMDToDate(2050, 0, 1));
 
	TimerGameCalendar::Date aging_date = std::min(TimerGameCalendar::date + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::ConvertYMDToDate(2050, 0, 1));
 

	
 
	for (EngineID i = 0; i < 256; i++) {
 
		int oi = ttd_to_tto[i];
 
		Engine *e = GetTempDataEngine(i);
 

	
 
		if (oi == 255) {
 
			/* Default engine is used */
 
			TimerGameCalendar::date += DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			TimerGameCalendar::date += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			StartupOneEngine(e, aging_date, 0);
 
			CalcEngineReliability(e, false);
 
			e->intro_date -= DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			TimerGameCalendar::date -= DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			e->intro_date -= CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			TimerGameCalendar::date -= CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
 

	
 
			/* Make sure for example monorail and maglev are available when they should be */
 
			if (TimerGameCalendar::date >= e->intro_date && HasBit(e->info.climates, 0)) {
 
				e->flags |= ENGINE_AVAILABLE;
 
				e->company_avail = MAX_UVALUE(CompanyMask);
 
				e->age = TimerGameCalendar::date > e->intro_date ? static_cast<int32_t>(TimerGameCalendar::date - e->intro_date) / 30 : 0;
 
@@ -1017,13 +1017,13 @@ static bool LoadOldCompany(LoadgameState
 
		 * Ps: this also means that if you had exact 893288 pounds, you will go back
 
		 * to 100000.. this is a very VERY small chance ;) */
 
		if (c->money == 893288) c->money = c->current_loan = 100000;
 
	}
 

	
 
	_company_colours[num] = (Colours)c->colour;
 
	c->inaugurated_year -= ORIGINAL_BASE_YEAR;
 
	c->inaugurated_year -= CalendarTime::ORIGINAL_BASE_YEAR;
 

	
 
	return true;
 
}
 

	
 
static uint32_t _old_order_ptr;
 
static uint16_t _old_next_ptr;
src/script/api/script_date.cpp
Show inline comments
 
@@ -53,13 +53,13 @@
 
}
 

	
 
/* static */ ScriptDate::Date ScriptDate::GetDate(SQInteger year, SQInteger month, SQInteger day_of_month)
 
{
 
	if (month < 1 || month > 12) return DATE_INVALID;
 
	if (day_of_month < 1 || day_of_month > 31) return DATE_INVALID;
 
	if (year < 0 || year > MAX_YEAR) return DATE_INVALID;
 
	if (year < 0 || year > CalendarTime::MAX_YEAR) return DATE_INVALID;
 

	
 
	return (ScriptDate::Date)(int32_t)::TimerGameCalendar::ConvertYMDToDate(year, month - 1, day_of_month);
 
}
 

	
 
/* static */ SQInteger ScriptDate::GetSystemTime()
 
{
src/script/api/script_date.hpp
Show inline comments
 
@@ -8,12 +8,13 @@
 
/** @file script_date.hpp Everything to query and manipulate date related information. */
 

	
 
#ifndef SCRIPT_DATE_HPP
 
#define SCRIPT_DATE_HPP
 

	
 
#include "script_object.hpp"
 
#include "timer/timer_game_calendar.h"
 
#include "../../date_type.h"
 

	
 
/**
 
 * Class that handles all date related (calculation) functions.
 
 * @api ai game
 
 *
 
@@ -28,13 +29,13 @@ class ScriptDate : public ScriptObject {
 
public:
 
	/**
 
	 * Date data type is an integer value. Use ScriptDate::GetDate to
 
	 * compose valid date values for a known year, month and day.
 
	 */
 
	enum Date {
 
		DATE_INVALID = (int32_t)::INVALID_DATE, ///< A value representing an invalid date.
 
		DATE_INVALID = (int32_t)::CalendarTime::INVALID_DATE, ///< A value representing an invalid date.
 
	};
 

	
 
	/**
 
	 * Validates if a date value represent a valid date.
 
	 * @param date The date to validate.
 
	 * @return True if the date is valid, otherwise false
src/settings.cpp
Show inline comments
 
@@ -1280,14 +1280,14 @@ void LoadFromConfig(bool startup)
 
		HandleSettingDescs(generic_ini, private_ini, secrets_ini, IniLoadSettings, IniLoadSettingList, startup);
 
	}
 

	
 
	/* Load basic settings only during bootstrap, load other settings not during bootstrap */
 
	if (!startup) {
 
		if (generic_version < IFV_LINKGRAPH_SECONDS) {
 
			_settings_newgame.linkgraph.recalc_interval *= SECONDS_PER_DAY;
 
			_settings_newgame.linkgraph.recalc_time     *= SECONDS_PER_DAY;
 
			_settings_newgame.linkgraph.recalc_interval *= CalendarTime::SECONDS_PER_DAY;
 
			_settings_newgame.linkgraph.recalc_time     *= CalendarTime::SECONDS_PER_DAY;
 
		}
 

	
 
		/* Move no_http_content_downloads and use_relay_service from generic_ini to private_ini. */
 
		if (generic_version < IFV_NETWORK_PRIVATE_SETTINGS) {
 
			IniGroup *network = generic_ini.GetGroup("network", false);
 
			if (network != nullptr) {
src/settings_gui.cpp
Show inline comments
 
@@ -2748,13 +2748,13 @@ struct CustomCurrencyWindow : Window {
 

	
 
	void SetButtonState()
 
	{
 
		this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
 
		this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
 
		this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
 
		this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR);
 
		this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == CalendarTime::MAX_YEAR);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CC_RATE:      SetDParam(0, 1); SetDParam(1, 1);            break;
 
@@ -2847,14 +2847,14 @@ struct CustomCurrencyWindow : Window {
 
				_custom_currency.to_euro = (_custom_currency.to_euro <= MIN_EURO_YEAR) ? CF_NOEURO : _custom_currency.to_euro - 1;
 
				if (_custom_currency.to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
 
				this->EnableWidget(WID_CC_YEAR_UP);
 
				break;
 

	
 
			case WID_CC_YEAR_UP:
 
				_custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, MIN_EURO_YEAR, MAX_YEAR);
 
				if (_custom_currency.to_euro == MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
 
				_custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, MIN_EURO_YEAR, CalendarTime::MAX_YEAR);
 
				if (_custom_currency.to_euro == CalendarTime::MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
 
				this->EnableWidget(WID_CC_YEAR_DOWN);
 
				break;
 

	
 
			case WID_CC_YEAR:
 
				SetDParam(0, _custom_currency.to_euro);
 
				str = STR_JUST_INT;
 
@@ -2894,13 +2894,13 @@ struct CustomCurrencyWindow : Window {
 
				_custom_currency.suffix = str;
 
				break;
 

	
 
			case WID_CC_YEAR: { // Year to switch to euro
 
				TimerGameCalendar::Year val = atoi(str);
 

	
 
				_custom_currency.to_euro = (val < MIN_EURO_YEAR ? CF_NOEURO : std::min(val, MAX_YEAR));
 
				_custom_currency.to_euro = (val < MIN_EURO_YEAR ? CF_NOEURO : std::min(val, CalendarTime::MAX_YEAR));
 
				break;
 
			}
 
		}
 
		MarkWholeScreenDirty();
 
		SetButtonState();
 
	}
src/ship_cmd.cpp
Show inline comments
 
@@ -233,13 +233,13 @@ void Ship::OnNewDay()
 
	CheckIfShipNeedsService(this);
 

	
 
	CheckOrders(this);
 

	
 
	if (this->running_ticks == 0) return;
 

	
 
	CommandCost cost(EXPENSES_SHIP_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR * Ticks::DAY_TICKS));
 
	CommandCost cost(EXPENSES_SHIP_RUN, this->GetRunningCost() * this->running_ticks / (CalendarTime::DAYS_IN_YEAR * Ticks::DAY_TICKS));
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
 

	
 
	SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
src/station.cpp
Show inline comments
 
@@ -102,13 +102,13 @@ Station::~Station()
 
		LinkGraph *lg = LinkGraph::GetIfValid(this->goods[c].link_graph);
 
		if (lg == nullptr) continue;
 

	
 
		for (NodeID node = 0; node < lg->Size(); ++node) {
 
			Station *st = Station::Get((*lg)[node].station);
 
			st->goods[c].flows.erase(this->index);
 
			if ((*lg)[node].HasEdgeTo(this->goods[c].node) && (*lg)[node][this->goods[c].node].LastUpdate() != INVALID_DATE) {
 
			if ((*lg)[node].HasEdgeTo(this->goods[c].node) && (*lg)[node][this->goods[c].node].LastUpdate() != CalendarTime::INVALID_DATE) {
 
				st->goods[c].flows.DeleteFlows(this->index);
 
				RerouteCargo(st, c, this->index, st->index);
 
			}
 
		}
 
		lg->RemoveNode(this->goods[c].node);
 
		if (lg->Size() == 0) {
src/station_cmd.cpp
Show inline comments
 
@@ -3860,17 +3860,17 @@ void DeleteStaleLinks(Station *from)
 
				if (!updated) {
 
					/* If it's still considered dead remove it. */
 
					to_remove.emplace_back(to->goods[c].node);
 
					ge.flows.DeleteFlows(to->index);
 
					RerouteCargo(from, c, to->index, from->index);
 
				}
 
			} else if (edge.last_unrestricted_update != INVALID_DATE && TimerGameCalendar::date - edge.last_unrestricted_update > timeout) {
 
			} else if (edge.last_unrestricted_update != CalendarTime::INVALID_DATE && TimerGameCalendar::date - edge.last_unrestricted_update > timeout) {
 
				edge.Restrict();
 
				ge.flows.RestrictFlows(to->index);
 
				RerouteCargo(from, c, to->index, from->index);
 
			} else if (edge.last_restricted_update != INVALID_DATE && TimerGameCalendar::date - edge.last_restricted_update > timeout) {
 
			} else if (edge.last_restricted_update != CalendarTime::INVALID_DATE && TimerGameCalendar::date - edge.last_restricted_update > timeout) {
 
				edge.Release();
 
			}
 
		}
 
		/* Remove dead edges. */
 
		for (NodeID r : to_remove) (*lg)[ge.node].RemoveEdge(r);
 

	
src/statusbar_gui.cpp
Show inline comments
 
@@ -86,13 +86,13 @@ struct StatusBarWindow : Window {
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		Dimension d;
 
		switch (widget) {
 
			case WID_S_LEFT:
 
				SetDParamMaxValue(0, DateAtStartOfYear(MAX_YEAR));
 
				SetDParamMaxValue(0, TimerGameCalendar::DateAtStartOfYear(CalendarTime::MAX_YEAR));
 
				d = GetStringBoundingBox(STR_JUST_DATE_LONG);
 
				break;
 

	
 
			case WID_S_RIGHT: {
 
				int64_t max_money = UINT32_MAX;
 
				for (const Company *c : Company::Iterate()) max_money = std::max<int64_t>(c->money, max_money);
src/story_gui.cpp
Show inline comments
 
@@ -696,13 +696,13 @@ public:
 
		fr = fr.Translate(-fr.left, -fr.top);
 
		int line_height = FONT_HEIGHT_NORMAL;
 
		const int scrollpos = this->vscroll->GetPosition();
 
		int y_offset = -scrollpos;
 

	
 
		/* Date */
 
		if (page->date != INVALID_DATE) {
 
		if (page->date != CalendarTime::INVALID_DATE) {
 
			SetDParam(0, page->date);
 
			DrawString(0, fr.right, y_offset, STR_JUST_DATE_LONG, TC_BLACK);
 
		}
 
		y_offset += line_height;
 

	
 
		/* Title */
src/subsidy.cpp
Show inline comments
 
@@ -42,13 +42,13 @@ INSTANTIATE_POOL_METHODS(Subsidy)
 
 */
 
void Subsidy::AwardTo(CompanyID company)
 
{
 
	assert(!this->IsAwarded());
 

	
 
	this->awarded = company;
 
	this->remaining = _settings_game.difficulty.subsidy_duration * MONTHS_IN_YEAR;
 
	this->remaining = _settings_game.difficulty.subsidy_duration * CalendarTime::MONTHS_IN_YEAR;
 

	
 
	SetDParam(0, company);
 
	NewsStringData *company_name = new NewsStringData(GetString(STR_COMPANY_NAME));
 

	
 
	/* Add a news item */
 
	std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(this, SubsidyDecodeParamType::NewsAwarded, 1);
src/table/airport_defaults.h
Show inline comments
 
@@ -7,13 +7,13 @@
 

	
 
/** @file airport_defaults.h Tables with default values for airports and airport tiles. */
 

	
 
#ifndef AIRPORT_DEFAULTS_H
 
#define AIRPORT_DEFAULTS_H
 

	
 
#include "date_type.h"
 
#include "timer/timer_game_calendar.h"
 

	
 
/**
 
 * Definition of an airport tiles layout.
 
 * @param x offset x of this tile
 
 * @param y offset y of this tile
 
 * @param m StationGfx of the tile
 
@@ -394,26 +394,26 @@ static const Direction _default_airports
 
	AS_GENERIC(&_airportfta_##ap_name, _tile_table_##ap_name, _default_airports_rotation, lengthof(_tile_table_##ap_name), _airport_depots_##ap_name, lengthof(_airport_depots_##ap_name), \
 
		size_x, size_y, noise, catchment, min_year, max_year, maint_cost, ttdpatch_type, class_id, name, preview, true)
 

	
 
/* The helidepot and helistation have ATP_TTDP_SMALL because they are at ground level */
 
extern const AirportSpec _origin_airport_specs[] = {
 
	AS(country,          4, 3,     0,     1959,  4,  3,  7, ATP_TTDP_SMALL,    APC_SMALL,    STR_AIRPORT_SMALL,            SPR_AIRPORT_PREVIEW_SMALL),
 
	AS(city,             6, 6,  1955, MAX_YEAR,  5,  5, 24, ATP_TTDP_LARGE,    APC_LARGE,    STR_AIRPORT_CITY,             SPR_AIRPORT_PREVIEW_LARGE),
 
	AS_ND(heliport,      1, 1,  1963, MAX_YEAR,  4,  1,  4, ATP_TTDP_HELIPORT, APC_HELIPORT, STR_AIRPORT_HELIPORT,         SPR_AIRPORT_PREVIEW_HELIPORT),
 
	AS(metropolitan,     6, 6,  1980, MAX_YEAR,  6,  8, 28, ATP_TTDP_LARGE,    APC_LARGE,    STR_AIRPORT_METRO,            SPR_AIRPORT_PREVIEW_METROPOLITAN),
 
	AS(international,    7, 7,  1990, MAX_YEAR,  8, 17, 42, ATP_TTDP_LARGE,    APC_HUB,      STR_AIRPORT_INTERNATIONAL,    SPR_AIRPORT_PREVIEW_INTERNATIONAL),
 
	AS(commuter,         5, 4,  1983, MAX_YEAR,  4,  4, 20, ATP_TTDP_SMALL,    APC_SMALL,    STR_AIRPORT_COMMUTER,         SPR_AIRPORT_PREVIEW_COMMUTER),
 
	AS(helidepot,        2, 2,  1976, MAX_YEAR,  4,  2,  7, ATP_TTDP_SMALL,    APC_HELIPORT, STR_AIRPORT_HELIDEPOT,        SPR_AIRPORT_PREVIEW_HELIDEPOT),
 
	AS(intercontinental, 9, 11, 2002, MAX_YEAR, 10, 25, 72, ATP_TTDP_LARGE,    APC_HUB,      STR_AIRPORT_INTERCONTINENTAL, SPR_AIRPORT_PREVIEW_INTERCONTINENTAL),
 
	AS(helistation,      4, 2,  1980, MAX_YEAR,  4,  3, 14, ATP_TTDP_SMALL,    APC_HELIPORT, STR_AIRPORT_HELISTATION,      SPR_AIRPORT_PREVIEW_HELISTATION),
 
	AS(city,             6, 6,  1955, CalendarTime::MAX_YEAR,  5,  5, 24, ATP_TTDP_LARGE,    APC_LARGE,    STR_AIRPORT_CITY,             SPR_AIRPORT_PREVIEW_LARGE),
 
	AS_ND(heliport,      1, 1,  1963, CalendarTime::MAX_YEAR,  4,  1,  4, ATP_TTDP_HELIPORT, APC_HELIPORT, STR_AIRPORT_HELIPORT,         SPR_AIRPORT_PREVIEW_HELIPORT),
 
	AS(metropolitan,     6, 6,  1980, CalendarTime::MAX_YEAR,  6,  8, 28, ATP_TTDP_LARGE,    APC_LARGE,    STR_AIRPORT_METRO,            SPR_AIRPORT_PREVIEW_METROPOLITAN),
 
	AS(international,    7, 7,  1990, CalendarTime::MAX_YEAR,  8, 17, 42, ATP_TTDP_LARGE,    APC_HUB,      STR_AIRPORT_INTERNATIONAL,    SPR_AIRPORT_PREVIEW_INTERNATIONAL),
 
	AS(commuter,         5, 4,  1983, CalendarTime::MAX_YEAR,  4,  4, 20, ATP_TTDP_SMALL,    APC_SMALL,    STR_AIRPORT_COMMUTER,         SPR_AIRPORT_PREVIEW_COMMUTER),
 
	AS(helidepot,        2, 2,  1976, CalendarTime::MAX_YEAR,  4,  2,  7, ATP_TTDP_SMALL,    APC_HELIPORT, STR_AIRPORT_HELIDEPOT,        SPR_AIRPORT_PREVIEW_HELIDEPOT),
 
	AS(intercontinental, 9, 11, 2002, CalendarTime::MAX_YEAR, 10, 25, 72, ATP_TTDP_LARGE,    APC_HUB,      STR_AIRPORT_INTERCONTINENTAL, SPR_AIRPORT_PREVIEW_INTERCONTINENTAL),
 
	AS(helistation,      4, 2,  1980, CalendarTime::MAX_YEAR,  4,  3, 14, ATP_TTDP_SMALL,    APC_HELIPORT, STR_AIRPORT_HELISTATION,      SPR_AIRPORT_PREVIEW_HELISTATION),
 
	AS_GENERIC(&_airportfta_oilrig, nullptr, _default_airports_rotation, 0, nullptr, 0, 1, 1, 0, 4, 0, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false),
 
};
 

	
 
static_assert(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs));
 

	
 
const AirportSpec AirportSpec::dummy = AS_GENERIC(&_airportfta_dummy, nullptr, _default_airports_rotation, 0, nullptr, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false);
 
const AirportSpec AirportSpec::dummy = AS_GENERIC(&_airportfta_dummy, nullptr, _default_airports_rotation, 0, nullptr, 0, 0, 0, 0, 0, CalendarTime::MIN_YEAR, CalendarTime::MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false);
 

	
 
#undef AS
 
#undef AS_ND
 
#undef AS_GENERIC
 

	
 
#endif /* AIRPORT_DEFAULTS_H */
src/table/engines.h
Show inline comments
 
@@ -21,75 +21,75 @@
 
 * @param c life length (years)
 
 * @param d base life (years)
 
 * @param e cargo type
 
 * @param f Bitmask of the climates
 
 * @note the 5 between b and f is the load amount
 
 */
 
#define MT(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, f, e, 0, 8, 0, 0, 0, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 
#define MT(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, f, e, 0, 8, 0, 0, 0, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 

	
 
/**
 
 * Writes the properties of a multiple-unit train into the EngineInfo struct.
 
 * @see EngineInfo
 
 * @param a base introduction date (days since 1920-01-01)
 
 * @param b decay speed
 
 * @param c life length (years)
 
 * @param d base life (years)
 
 * @param e cargo type
 
 * @param f Bitmask of the climates
 
 * @note the 5 between b and f is the load amount
 
 */
 
#define MM(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, f, e, 0, 8, 1 << EF_RAIL_IS_MU, 0, 0, STR_EMPTY, Tick::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 
#define MM(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, f, e, 0, 8, 1 << EF_RAIL_IS_MU, 0, 0, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 

	
 
/**
 
 * Writes the properties of a train carriage into the EngineInfo struct.
 
 * @param a base introduction date (days since 1920-01-01)
 
 * @param b decay speed
 
 * @param c life length (years)
 
 * @param d base life (years)
 
 * @param e cargo type
 
 * @param f Bitmask of the climates
 
 * @see MT
 
 * @note the 5 between b and f is the load amount
 
 */
 
#define MW(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, f, e, 0, 8, 0, 0, 0, STR_EMPTY, Tick::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 
#define MW(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, f, e, 0, 8, 0, 0, 0, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 

	
 
/**
 
 * Writes the properties of a road vehicle into the EngineInfo struct.
 
 * @see EngineInfo
 
 * @param a base introduction date (days since 1920-01-01)
 
 * @param b decay speed
 
 * @param c life length (years)
 
 * @param d base life (years)
 
 * @param e cargo type
 
 * @param f Bitmask of the climates
 
 * @note the 5 between b and f is the load amount
 
 */
 
#define MR(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, f, e, 0, 8, 0, 0, 0, STR_EMPTY, Tick::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 
#define MR(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, f, e, 0, 8, 0, 0, 0, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 

	
 
/**
 
 * Writes the properties of a ship into the EngineInfo struct.
 
 * @param a base introduction date (days since 1920-01-01)
 
 * @param b decay speed
 
 * @param c life length (years)
 
 * @param d base life (years)
 
 * @param e cargo type
 
 * @param f Bitmask of the climates
 
 * @note the 10 between b and f is the load amount
 
 */
 
#define MS(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 10, f, e, 0, 8, 0, 0, 0, STR_EMPTY, Tick::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 
#define MS(a, b, c, d, e, f) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 10, f, e, 0, 8, 0, 0, 0, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 

	
 
/**
 
 * Writes the properties of an aeroplane into the EngineInfo struct.
 
 * @param a base introduction date (days since 1920-01-01)
 
 * @param b decay speed
 
 * @param c life length (years)
 
 * @param d base life (years)
 
 * @param e Bitmask of the climates
 
 * @note the 20 between b and e is the load amount
 
 */
 
#define MA(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 20, e, CT_INVALID, 0, 8, 0, 0, 0, STR_EMPTY, Tick::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 
#define MA(a, b, c, d, e) { CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 20, e, CT_INVALID, 0, 8, 0, 0, 0, STR_EMPTY, Ticks::CARGO_AGING_TICKS, INVALID_ENGINE, ExtraEngineFlags::None }
 

	
 
/* Climates
 
 * T = Temperate
 
 * A = Sub-Arctic
 
 * S = Sub-Tropic
 
 * Y = Toyland */
src/table/object_land.h
Show inline comments
 
@@ -118,13 +118,13 @@ static const DrawTileSprites _object_hq[
 
	TILE_SPRITE_LINE(SPR_HUGEHQ_EAST_GROUND,   _object_hq_huge_east)
 
	TILE_SPRITE_LINE(SPR_HUGEHQ_SOUTH,         _object_nothing)
 
};
 

	
 
#undef TILE_SPRITE_LINE
 

	
 
#define M(name, size, build_cost_multiplier, clear_cost_multiplier, height, climate, gen_amount, flags) { GRFFilePropsBase<2>(), {0, 0, 0, 0}, INVALID_OBJECT_CLASS, name, climate, size, build_cost_multiplier, clear_cost_multiplier, 0, MAX_DATE + 1, flags, 0, height, 1, gen_amount }
 
#define M(name, size, build_cost_multiplier, clear_cost_multiplier, height, climate, gen_amount, flags) { GRFFilePropsBase<2>(), {0, 0, 0, 0}, INVALID_OBJECT_CLASS, name, climate, size, build_cost_multiplier, clear_cost_multiplier, 0, CalendarTime::MAX_DATE + 1, flags, 0, height, 1, gen_amount }
 

	
 
/* Climates
 
 * T = Temperate
 
 * A = Sub-Arctic
 
 * S = Sub-Tropic
 
 * Y = Toyland */
src/table/railtypes.h
Show inline comments
 
@@ -96,13 +96,13 @@ static const RailtypeInfo _original_rail
 
		RailTypeLabelList(),
 

	
 
		/* map colour */
 
		0x0A,
 

	
 
		/* introduction date */
 
		INVALID_DATE,
 
		CalendarTime::INVALID_DATE,
 

	
 
		/* railtypes required for this to be introduced */
 
		RAILTYPES_NONE,
 

	
 
		/* introduction rail types */
 
		RAILTYPES_RAIL,
 
@@ -197,13 +197,13 @@ static const RailtypeInfo _original_rail
 
		RailTypeLabelList(),
 

	
 
		/* map colour */
 
		0x0A,
 

	
 
		/* introduction date */
 
		INVALID_DATE,
 
		CalendarTime::INVALID_DATE,
 

	
 
		/* railtypes required for this to be introduced */
 
		RAILTYPES_NONE,
 

	
 
		/* introduction rail types */
 
		RAILTYPES_ELECTRIC,
 
@@ -294,13 +294,13 @@ static const RailtypeInfo _original_rail
 
		RailTypeLabelList(),
 

	
 
		/* map colour */
 
		0x0A,
 

	
 
		/* introduction date */
 
		INVALID_DATE,
 
		CalendarTime::INVALID_DATE,
 

	
 
		/* railtypes required for this to be introduced */
 
		RAILTYPES_NONE,
 

	
 
		/* introduction rail types */
 
		RAILTYPES_MONO,
 
@@ -391,13 +391,13 @@ static const RailtypeInfo _original_rail
 
		RailTypeLabelList(),
 

	
 
		/* map colour */
 
		0x0A,
 

	
 
		/* introduction date */
 
		INVALID_DATE,
 
		CalendarTime::INVALID_DATE,
 

	
 
		/* railtypes required for this to be introduced */
 
		RAILTYPES_NONE,
 

	
 
		/* introduction rail types */
 
		RAILTYPES_MAGLEV,
src/table/roadtypes.h
Show inline comments
 
@@ -79,13 +79,13 @@ static const RoadTypeInfo _original_road
 
		RoadTypeLabelList(),
 

	
 
		/* map colour */
 
		0x01,
 

	
 
		/* introduction date */
 
		static_cast<int32_t>(MIN_YEAR),
 
		static_cast<int32_t>(CalendarTime::MIN_YEAR),
 

	
 
		/* roadtypes required for this to be introduced */
 
		ROADTYPES_NONE,
 

	
 
		/* introduction road types */
 
		ROADTYPES_ROAD,
 
@@ -159,13 +159,13 @@ static const RoadTypeInfo _original_road
 
		RoadTypeLabelList(),
 

	
 
		/* map colour */
 
		0x01,
 

	
 
		/* introduction date */
 
		INVALID_DATE,
 
		CalendarTime::INVALID_DATE,
 

	
 
		/* roadtypes required for this to be introduced */
 
		ROADTYPES_NONE,
 

	
 
		/* introduction road types */
 
		ROADTYPES_TRAM,
src/table/settings/currency_settings.ini
Show inline comments
 
@@ -47,14 +47,14 @@ def      = "".""
 
cat      = SC_BASIC
 

	
 
[SDT_VAR]
 
var      = to_euro
 
type     = SLE_INT32
 
def      = 0
 
min      = MIN_YEAR
 
max      = MAX_YEAR
 
min      = CalendarTime::MIN_YEAR
 
max      = CalendarTime::MAX_YEAR
 

	
 
[SDT_SSTR]
 
var      = prefix
 
type     = SLE_STRQ
 
def      = nullptr
 

	
src/table/settings/gui_settings.ini
Show inline comments
 
@@ -493,14 +493,14 @@ max      = 5
 

	
 
[SDTC_VAR]
 
var      = gui.coloured_news_year
 
type     = SLE_INT32
 
flags    = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
 
def      = 2000
 
min      = MIN_YEAR
 
max      = MAX_YEAR
 
min      = CalendarTime::MIN_YEAR
 
max      = CalendarTime::MAX_YEAR
 
interval = 1
 
str      = STR_CONFIG_SETTING_COLOURED_NEWS_YEAR
 
strhelp  = STR_CONFIG_SETTING_COLOURED_NEWS_YEAR_HELPTEXT
 
strval   = STR_JUST_INT
 
cat      = SC_EXPERT
 

	
 
@@ -540,14 +540,14 @@ cat      = SC_EXPERT
 

	
 
[SDTC_VAR]
 
var      = gui.semaphore_build_before
 
type     = SLE_INT32
 
flags    = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
 
def      = 1950
 
min      = MIN_YEAR
 
max      = MAX_YEAR
 
min      = CalendarTime::MIN_YEAR
 
max      = CalendarTime::MAX_YEAR
 
interval = 1
 
str      = STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFORE_DATE
 
strhelp  = STR_CONFIG_SETTING_SEMAPHORE_BUILD_BEFORE_DATE_HELPTEXT
 
strval   = STR_JUST_INT
 
post_cb  = ResetSignalVariant
 

	
src/table/settings/network_settings.ini
Show inline comments
 
@@ -234,14 +234,14 @@ cat      = SC_BASIC
 

	
 
[SDTC_VAR]
 
var      = network.restart_game_year
 
type     = SLE_INT32
 
flags    = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_0_IS_SPECIAL | SF_NETWORK_ONLY
 
def      = 0
 
min      = MIN_YEAR
 
max      = MAX_YEAR
 
min      = CalendarTime::MIN_YEAR
 
max      = CalendarTime::MAX_YEAR
 
interval = 1
 

	
 
[SDTC_VAR]
 
var      = network.min_active_clients
 
type     = SLE_UINT8
 
flags    = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_NETWORK_ONLY
src/table/settings/world_settings.ini
Show inline comments
 
@@ -119,28 +119,28 @@ strhelp  = STR_CONFIG_SETTING_DESERT_COV
 
strval   = STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE
 
cat      = SC_BASIC
 

	
 
[SDT_VAR]
 
var      = game_creation.starting_year
 
type     = SLE_INT32
 
def      = DEF_START_YEAR
 
min      = MIN_YEAR
 
max      = MAX_YEAR
 
def      = CalendarTime::DEF_START_YEAR
 
min      = CalendarTime::MIN_YEAR
 
max      = CalendarTime::MAX_YEAR
 
interval = 1
 
str      = STR_CONFIG_SETTING_STARTING_YEAR
 
strval   = STR_JUST_INT
 
cat      = SC_BASIC
 

	
 
[SDT_VAR]
 
var      = game_creation.ending_year
 
type     = SLE_INT32
 
from     = SLV_ENDING_YEAR
 
flags    = SF_GUI_0_IS_SPECIAL
 
def      = DEF_END_YEAR
 
min      = MIN_YEAR
 
max      = MAX_YEAR - 1
 
def      = CalendarTime::DEF_END_YEAR
 
min      = CalendarTime::MIN_YEAR
 
max      = CalendarTime::MAX_YEAR - 1
 
interval = 1
 
str      = STR_CONFIG_SETTING_ENDING_YEAR
 
strhelp  = STR_CONFIG_SETTING_ENDING_YEAR_HELPTEXT
 
strval   = STR_CONFIG_SETTING_ENDING_YEAR_VALUE
 
cat      = SC_ADVANCED
 

	
src/table/town_land.h
Show inline comments
 
@@ -1818,76 +1818,76 @@ static_assert(lengthof(_town_draw_tile_d
 
/** House specifications from original data */
 
static const HouseSpec _original_house_specs[] = {
 
	/**
 
	 *                                                                              remove_rating_decrease
 
	 *                                                                              |    mail_generation
 
	 *     min_year                                                                 |    |    1st CargoID acceptance
 
	 *     |         max_year                                                       |    |    |    2nd CargoID acceptance
 
	 *     |         CalendarTime::MAX_YEAR                                                       |    |    |    2nd CargoID acceptance
 
	 *     |         |    population                                                |    |    |    |    3th CargoID acceptance
 
	 *     |         |    |    removal_cost                                         |    |    |    |    |
 
	 *     |         |    |    |    building_name                                   |    |    |    |    |
 
	 *     |         |    |    |    |                                               |    |    |    |    |
 
	 *     |         |    |    |    |                                               |    |    |    |    |
 
	 * +-building_flags   |    |    |                                               |    |    |    |    |
 
	 * +-building_availability |    |                                               |    |    |    |    |
 
	 * +-cargoID accepted |    |    |                                               |    |    |    |    |
 
	 * |   |         |    |    |    |                                               |    |    |    |    |
 
	 */
 
	MS(1963, MAX_YEAR, 187, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  70,   8,   3,   4,
 
	MS(1963, CalendarTime::MAX_YEAR, 187, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  70,   8,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 00
 
	MS(1957, MAX_YEAR,  85, 140, STR_TOWN_BUILDING_NAME_OFFICE_BLOCK_1,           130,  55,   8,   3,   4,
 
	MS(1957, CalendarTime::MAX_YEAR,  85, 140, STR_TOWN_BUILDING_NAME_OFFICE_BLOCK_1,           130,  55,   8,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 01
 
	MS(1968, MAX_YEAR,  40, 100, STR_TOWN_BUILDING_NAME_SMALL_BLOCK_OF_FLATS_1,    90,  20,   8,   3,   1,
 
	MS(1968, CalendarTime::MAX_YEAR,  40, 100, STR_TOWN_BUILDING_NAME_SMALL_BLOCK_OF_FLATS_1,    90,  20,   8,   3,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 02
 
	MS(   0, MAX_YEAR,   5,  90, STR_TOWN_BUILDING_NAME_CHURCH_1,                 230,   2,   2,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   5,  90, STR_TOWN_BUILDING_NAME_CHURCH_1,                 230,   2,   2,   0,   0,
 
	   BUILDING_IS_CHURCH | TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 03
 
	MS(1975, MAX_YEAR, 220, 160, STR_TOWN_BUILDING_NAME_LARGE_OFFICE_BLOCK_1,     160,  85,  10,   4,   6,
 
	MS(1975, CalendarTime::MAX_YEAR, 220, 160, STR_TOWN_BUILDING_NAME_LARGE_OFFICE_BLOCK_1,     160,  85,  10,   4,   6,
 
	   BUILDING_IS_ANIMATED | TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 04
 
	MS(1975, MAX_YEAR, 220, 160, STR_TOWN_BUILDING_NAME_LARGE_OFFICE_BLOCK_1,     160,  85,  10,   4,   6,
 
	MS(1975, CalendarTime::MAX_YEAR, 220, 160, STR_TOWN_BUILDING_NAME_LARGE_OFFICE_BLOCK_1,     160,  85,  10,   4,   6,
 
	   BUILDING_IS_ANIMATED | TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE  | HZ_ZON5,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 05
 
	MS(   0, MAX_YEAR,  30,  80, STR_TOWN_BUILDING_NAME_TOWN_HOUSES_1,             80,  12,   4,   1,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,  30,  80, STR_TOWN_BUILDING_NAME_TOWN_HOUSES_1,             80,  12,   4,   1,   0,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 06
 
	MS(1959, MAX_YEAR, 140, 180, STR_TOWN_BUILDING_NAME_HOTEL_1,                  150,  22,   6,   1,   2,
 
	MS(1959, CalendarTime::MAX_YEAR, 140, 180, STR_TOWN_BUILDING_NAME_HOTEL_1,                  150,  22,   6,   1,   2,
 
	   TILE_SIZE_1x2,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 07
 
	MS(1959, MAX_YEAR,   0, 180, STR_TOWN_BUILDING_NAME_HOTEL_1,                  150,  22,   6,   1,   2,
 
	MS(1959, CalendarTime::MAX_YEAR,   0, 180, STR_TOWN_BUILDING_NAME_HOTEL_1,                  150,  22,   6,   1,   2,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 08
 
	MS(1945, MAX_YEAR,   0,  65, STR_TOWN_BUILDING_NAME_STATUE_1,                  40,   0,   2,   0,   0,
 
	MS(1945, CalendarTime::MAX_YEAR,   0,  65, STR_TOWN_BUILDING_NAME_STATUE_1,                  40,   0,   2,   0,   0,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 09
 
	MS(1945, MAX_YEAR,   0,  65, STR_TOWN_BUILDING_NAME_FOUNTAIN_1,                40,   0,   2,   0,   0,
 
	MS(1945, CalendarTime::MAX_YEAR,   0,  65, STR_TOWN_BUILDING_NAME_FOUNTAIN_1,                40,   0,   2,   0,   0,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 0A
 
	MS(   0, MAX_YEAR,   0,  60, STR_TOWN_BUILDING_NAME_PARK_1,                    75,   0,   2,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   0,  60, STR_TOWN_BUILDING_NAME_PARK_1,                    75,   0,   2,   0,   0,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 0B
 
	MS(1935, MAX_YEAR,   0,  60, STR_TOWN_BUILDING_NAME_PARK_1,                    75,   0,   2,   0,   0,
 
	MS(1935, CalendarTime::MAX_YEAR,   0,  60, STR_TOWN_BUILDING_NAME_PARK_1,                    75,   0,   2,   0,   0,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 0C
 
	MS(1951, MAX_YEAR, 150, 130, STR_TOWN_BUILDING_NAME_OFFICE_BLOCK_2,           110,  65,   8,   2,   4,
 
	MS(1951, CalendarTime::MAX_YEAR, 150, 130, STR_TOWN_BUILDING_NAME_OFFICE_BLOCK_2,           110,  65,   8,   2,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 0D
 
	MS(1930, 1960,      95, 110, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      100,  48,   6,   2,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
@@ -1897,381 +1897,381 @@ static const HouseSpec _original_house_s
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 0F
 
	MS(1930, 1960,      95, 107, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      100,  48,   6,   2,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 10
 
	MS(1977, MAX_YEAR, 130, 200, STR_TOWN_BUILDING_NAME_MODERN_OFFICE_BUILDING_1, 150,  50,  10,   3,   6,
 
	MS(1977, CalendarTime::MAX_YEAR, 130, 200, STR_TOWN_BUILDING_NAME_MODERN_OFFICE_BUILDING_1, 150,  50,  10,   3,   6,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 11
 
	MS(1983, MAX_YEAR,   6, 145, STR_TOWN_BUILDING_NAME_WAREHOUSE_1,              110,  10,   6,   3,   8,
 
	MS(1983, CalendarTime::MAX_YEAR,   6, 145, STR_TOWN_BUILDING_NAME_WAREHOUSE_1,              110,  10,   6,   3,   8,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 12
 
	MS(1985, MAX_YEAR, 110, 155, STR_TOWN_BUILDING_NAME_OFFICE_BLOCK_3,           110,  55,   6,   2,   6,
 
	MS(1985, CalendarTime::MAX_YEAR, 110, 155, STR_TOWN_BUILDING_NAME_OFFICE_BLOCK_3,           110,  55,   6,   2,   6,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 13
 
	MS(   0, MAX_YEAR,  65, 250, STR_TOWN_BUILDING_NAME_STADIUM_1,                300,   5,   4,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,  65, 250, STR_TOWN_BUILDING_NAME_STADIUM_1,                300,   5,   4,   0,   0,
 
	   BUILDING_IS_STADIUM | TILE_SIZE_2x2,
 
	   HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 14
 
	MS(   0, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_1,                300,   5,   4,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_1,                300,   5,   4,   0,   0,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 15
 
	MS(   0, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_1,                300,   5,   4,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_1,                300,   5,   4,   0,   0,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 16
 
	MS(   0, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_1,                300,   5,   4,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_1,                300,   5,   4,   0,   0,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 17
 
	MS(   0, 1951,      15,  70, STR_TOWN_BUILDING_NAME_OLD_HOUSES_1,              75,   6,   3,   1,   0,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 18
 
	MS(   0, 1952,      12,  75, STR_TOWN_BUILDING_NAME_COTTAGES_1,                75,   7,   3,   1,   0,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 19
 
	MS(1931, MAX_YEAR,  13,  71, STR_TOWN_BUILDING_NAME_HOUSES_1,                  75,   8,   3,   1,   0,
 
	MS(1931, CalendarTime::MAX_YEAR,  13,  71, STR_TOWN_BUILDING_NAME_HOUSES_1,                  75,   8,   3,   1,   0,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 1A
 
	MS(1935, MAX_YEAR, 100, 135, STR_TOWN_BUILDING_NAME_FLATS_1,                  100,  35,   7,   2,   2,
 
	MS(1935, CalendarTime::MAX_YEAR, 100, 135, STR_TOWN_BUILDING_NAME_FLATS_1,                  100,  35,   7,   2,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 1B
 
	MS(1963, MAX_YEAR, 170, 145, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_2,      170,  50,   8,   3,   3,
 
	MS(1963, CalendarTime::MAX_YEAR, 170, 145, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_2,      170,  50,   8,   3,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 1C
 
	MS(   0, 1955,     100, 132, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_2,      135,  40,   6,   2,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 1D
 
	MS(1973, MAX_YEAR, 180, 155, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_3,      180,  64,   8,   3,   3,
 
	MS(1973, CalendarTime::MAX_YEAR, 180, 155, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_3,      180,  64,   8,   3,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 1E
 
	MS(   0, MAX_YEAR,  35, 220, STR_TOWN_BUILDING_NAME_THEATER_1,                230,  23,   8,   2,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  35, 220, STR_TOWN_BUILDING_NAME_THEATER_1,                230,  23,   8,   2,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 1F
 
	MS(1958, MAX_YEAR,  65, 250, STR_TOWN_BUILDING_NAME_STADIUM_2,                300,   5,   4,   0,   0,
 
	MS(1958, CalendarTime::MAX_YEAR,  65, 250, STR_TOWN_BUILDING_NAME_STADIUM_2,                300,   5,   4,   0,   0,
 
	   BUILDING_IS_STADIUM | TILE_SIZE_2x2,
 
	   HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 20
 
	MS(1958, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_2,                300,   5,   4,   0,   0,
 
	MS(1958, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_2,                300,   5,   4,   0,   0,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 21
 
	MS(1958, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_2,                300,   5,   4,   0,   0,
 
	MS(1958, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_2,                300,   5,   4,   0,   0,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 22
 
	MS(1958, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_2,                300,   5,   4,   0,   0,
 
	MS(1958, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_STADIUM_2,                300,   5,   4,   0,   0,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 23
 
	MS(2000, MAX_YEAR, 140, 170, STR_TOWN_BUILDING_NAME_OFFICES_1,                250,  65,   8,   3,   2,
 
	MS(2000, CalendarTime::MAX_YEAR, 140, 170, STR_TOWN_BUILDING_NAME_OFFICES_1,                250,  65,   8,   3,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 24
 
	MS(   0, 1960,      15,  70, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 25
 
	MS(   0, 1960,      15,  70, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 26
 
	MS(1945, MAX_YEAR,  35, 210, STR_TOWN_BUILDING_NAME_CINEMA_1,                 230,  23,   8,   2,   2,
 
	MS(1945, CalendarTime::MAX_YEAR,  35, 210, STR_TOWN_BUILDING_NAME_CINEMA_1,                 230,  23,   8,   2,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 27
 
	MS(1983, MAX_YEAR, 180, 250, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1,          300,   5,   8,   2,   3,
 
	MS(1983, CalendarTime::MAX_YEAR, 180, 250, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1,          300,   5,   8,   2,   3,
 
	   TILE_SIZE_2x2,
 
	   HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 |HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 28
 
	MS(1983, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1,          300,   5,   8,   2,   3,
 
	MS(1983, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1,          300,   5,   8,   2,   3,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 29
 
	MS(1983, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1,          300,   5,   8,   2,   3,
 
	MS(1983, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1,          300,   5,   8,   2,   3,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 2A
 
	MS(1983, MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1,          300,   5,   8,   2,   3,
 
	MS(1983, CalendarTime::MAX_YEAR,   0, 250, STR_TOWN_BUILDING_NAME_SHOPPING_MALL_1,          300,   5,   8,   2,   3,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 2B
 
	MS(   0, MAX_YEAR,  80, 100, STR_TOWN_BUILDING_NAME_FLATS_1,                   90,  20,   5,   2,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  80, 100, STR_TOWN_BUILDING_NAME_FLATS_1,                   90,  20,   5,   2,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 2C
 
	MS(   0, MAX_YEAR,  80, 100, STR_TOWN_BUILDING_NAME_FLATS_1,                   90,  20,   5,   2,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  80, 100, STR_TOWN_BUILDING_NAME_FLATS_1,                   90,  20,   5,   2,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE  | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 2D
 
	MS(   0, MAX_YEAR,  16,  70, STR_TOWN_BUILDING_NAME_HOUSES_2,                  70,   6,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  16,  70, STR_TOWN_BUILDING_NAME_HOUSES_2,                  70,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 2E
 
	MS(   0, MAX_YEAR,  16,  70, STR_TOWN_BUILDING_NAME_HOUSES_2,                  70,   6,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  16,  70, STR_TOWN_BUILDING_NAME_HOUSES_2,                  70,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 2F
 
	MS(   0, 1963,      14,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  70,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 30
 
	MS(   0, 1963,      14,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  70,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 31
 
	MS(1966, MAX_YEAR, 135, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      120,  60,   8,   3,   4,
 
	MS(1966, CalendarTime::MAX_YEAR, 135, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      120,  60,   8,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 32
 
	MS(1966, MAX_YEAR, 135, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      120,  60,   8,   3,   4,
 
	MS(1966, CalendarTime::MAX_YEAR, 135, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      120,  60,   8,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 33
 
	MS(1970, MAX_YEAR, 170, 170, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  70,   9,   3,   4,
 
	MS(1970, CalendarTime::MAX_YEAR, 170, 170, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  70,   9,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 34
 
	MS(1970, MAX_YEAR, 170, 170, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  70,   9,   3,   4,
 
	MS(1970, CalendarTime::MAX_YEAR, 170, 170, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  70,   9,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 35
 
	MS(1974, MAX_YEAR, 210, 200, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  80,  10,   3,   5,
 
	MS(1974, CalendarTime::MAX_YEAR, 210, 200, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  80,  10,   3,   5,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 36
 
	MS(1974, MAX_YEAR, 210, 200, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  80,  10,   3,   5,
 
	MS(1974, CalendarTime::MAX_YEAR, 210, 200, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  80,  10,   3,   5,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 37
 
	MS(   0, MAX_YEAR,  10,  60, STR_TOWN_BUILDING_NAME_HOUSES_2,                  60,   5,   2,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  10,  60, STR_TOWN_BUILDING_NAME_HOUSES_2,                  60,   5,   2,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 38
 
	MS(   0, MAX_YEAR,  10,  60, STR_TOWN_BUILDING_NAME_HOUSES_2,                  60,   5,   2,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  10,  60, STR_TOWN_BUILDING_NAME_HOUSES_2,                  60,   5,   2,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 39
 
	MS(   0, MAX_YEAR,  25, 100, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,       80,  20,   3,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  25, 100, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,       80,  20,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 3A
 
	MS(   0, MAX_YEAR,  25, 100, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,       80,  20,   3,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  25, 100, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,       80,  20,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 3B
 
	MS(   0, MAX_YEAR,   6,  85, STR_TOWN_BUILDING_NAME_CHURCH_1,                 230,   2,   2,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   6,  85, STR_TOWN_BUILDING_NAME_CHURCH_1,                 230,   2,   2,   0,   0,
 
	   BUILDING_IS_CHURCH | TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 3C
 
	MS(   0, MAX_YEAR,   6,  85, STR_TOWN_BUILDING_NAME_CHURCH_1,                 230,   2,   2,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   6,  85, STR_TOWN_BUILDING_NAME_CHURCH_1,                 230,   2,   2,   0,   0,
 
	   BUILDING_IS_CHURCH | TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 3D
 
	MS(   0, MAX_YEAR,  17,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   7,   3,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  17,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   7,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 3E
 
	MS(   0, MAX_YEAR,  17,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   7,   3,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  17,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   7,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 3F
 
	MS(   0, 1960,      90, 140, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      110,  45,   6,   2,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 40
 
	MS(   0, 1960,      90, 140, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      110,  45,   6,   2,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 41
 
	MS(1972, MAX_YEAR, 140, 160, STR_TOWN_BUILDING_NAME_HOTEL_1,                  160,  25,   6,   1,   3,
 
	MS(1972, CalendarTime::MAX_YEAR, 140, 160, STR_TOWN_BUILDING_NAME_HOTEL_1,                  160,  25,   6,   1,   3,
 
	   TILE_SIZE_1x2,
 
	   HZ_SUBARTC_BELOW| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 42
 
	MS(1972, MAX_YEAR,   0, 160, STR_TOWN_BUILDING_NAME_HOTEL_1,                  160,  25,   6,   1,   2,
 
	MS(1972, CalendarTime::MAX_YEAR,   0, 160, STR_TOWN_BUILDING_NAME_HOTEL_1,                  160,  25,   6,   1,   2,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 43
 
	MS(1972, MAX_YEAR, 140, 160, STR_TOWN_BUILDING_NAME_HOTEL_1,                  160,  25,   6,   1,   3,
 
	MS(1972, CalendarTime::MAX_YEAR, 140, 160, STR_TOWN_BUILDING_NAME_HOTEL_1,                  160,  25,   6,   1,   3,
 
	   TILE_SIZE_1x2,
 
	   HZ_SUBARTC_ABOVE| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 44
 
	MS(1972, MAX_YEAR,   0, 160, STR_TOWN_BUILDING_NAME_HOTEL_1,                  160,  25,   6,   1,   2,
 
	MS(1972, CalendarTime::MAX_YEAR,   0, 160, STR_TOWN_BUILDING_NAME_HOTEL_1,                  160,  25,   6,   1,   2,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 45
 
	MS(1963, MAX_YEAR, 105, 130, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      105,  50,   7,   2,   3,
 
	MS(1963, CalendarTime::MAX_YEAR, 105, 130, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      105,  50,   7,   2,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 46
 
	MS(1963, MAX_YEAR, 105, 130, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      105,  50,   7,   2,   3,
 
	MS(1963, CalendarTime::MAX_YEAR, 105, 130, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      105,  50,   7,   2,   3,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 47
 
	MS(1978, MAX_YEAR, 190, 190, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      135,  75,   9,   3,   4,
 
	MS(1978, CalendarTime::MAX_YEAR, 190, 190, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      135,  75,   9,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_BELOW | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 48
 
	MS(1978, MAX_YEAR, 190, 190, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      135,  75,   9,   3,   4,
 
	MS(1978, CalendarTime::MAX_YEAR, 190, 190, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      135,  75,   9,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 49
 
	MS(1967, MAX_YEAR, 250, 140, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      200,  60,   7,   2,   2,
 
	MS(1967, CalendarTime::MAX_YEAR, 250, 140, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      200,  60,   7,   2,   2,
 
	   TILE_SIZE_2x1,
 
	   HZ_SUBARTC_BELOW| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 4A
 
	MS(1967, MAX_YEAR,   0, 140, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      200,  60,   7,   2,   2,
 
	MS(1967, CalendarTime::MAX_YEAR,   0, 140, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      200,  60,   7,   2,   2,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 4B
 
	MS(1967, MAX_YEAR, 250, 140, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      200,  60,   7,   2,   2,
 
	MS(1967, CalendarTime::MAX_YEAR, 250, 140, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      200,  60,   7,   2,   2,
 
	   TILE_SIZE_2x1,
 
	   HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 4C
 
	MS(1967, MAX_YEAR,   0, 140, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      200,  60,   7,   2,   2,
 
	MS(1967, CalendarTime::MAX_YEAR,   0, 140, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      200,  60,   7,   2,   2,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 4D
 
	MS(   0, MAX_YEAR,  16,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   6,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  16,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 4E
 
	MS(   0, MAX_YEAR,  16,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   6,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  16,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 4F
 
	MS(   0, MAX_YEAR,  16,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   5,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  16,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   5,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 50
 
	MS(   0, MAX_YEAR,   7,  30, STR_TOWN_BUILDING_NAME_HOUSES_2,                  30,   4,   3,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,   7,  30, STR_TOWN_BUILDING_NAME_HOUSES_2,                  30,   4,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 51
 
	MS(   0, MAX_YEAR,  45, 130, STR_TOWN_BUILDING_NAME_FLATS_1,                   95,  15,   6,   2,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  45, 130, STR_TOWN_BUILDING_NAME_FLATS_1,                   95,  15,   6,   2,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 52
 
	MS(   0, MAX_YEAR,   8,  90, STR_TOWN_BUILDING_NAME_CHURCH_1,                 200,   3,   2,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   8,  90, STR_TOWN_BUILDING_NAME_CHURCH_1,                 200,   3,   2,   0,   0,
 
	   BUILDING_IS_CHURCH | TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 53
 
	MS(   0, MAX_YEAR,  18,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   7,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  18,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   7,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
 
	   CT_PASSENGERS, CT_MAIL, CT_FOOD), // 54
 
	MS(1973, MAX_YEAR,  90, 110, STR_TOWN_BUILDING_NAME_FLATS_1,                   95,  24,   6,   2,   1,
 
	MS(1973, CalendarTime::MAX_YEAR,  90, 110, STR_TOWN_BUILDING_NAME_FLATS_1,                   95,  24,   6,   2,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 55
 
	MS(1962, MAX_YEAR, 120, 120, STR_TOWN_BUILDING_NAME_FLATS_1,                   95,  25,   6,   2,   1,
 
	MS(1962, CalendarTime::MAX_YEAR, 120, 120, STR_TOWN_BUILDING_NAME_FLATS_1,                   95,  25,   6,   2,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 56
 
	MS(1984, MAX_YEAR, 250, 190, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  80,   8,   3,   4,
 
	MS(1984, CalendarTime::MAX_YEAR, 250, 190, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  80,   8,   3,   4,
 
	   TILE_SIZE_2x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 57
 
	MS(1984, MAX_YEAR,   0, 190, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  80,   8,   3,   4,
 
	MS(1984, CalendarTime::MAX_YEAR,   0, 190, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      140,  80,   8,   3,   4,
 
	   TILE_NO_FLAG,
 
	   HZ_SUBTROPIC,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 58
 
	MS(   0, MAX_YEAR,  80, 110, STR_TOWN_BUILDING_NAME_FLATS_1,                   95,  23,   6,   2,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  80, 110, STR_TOWN_BUILDING_NAME_FLATS_1,                   95,  23,   6,   2,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 59
 
	MS(1993, MAX_YEAR, 180, 180, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      150,  90,   8,   3,   4,
 
	MS(1993, CalendarTime::MAX_YEAR, 180, 180, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      150,  90,   8,   3,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_GOODS), // 5A
 
	MS(   0, MAX_YEAR,   8,  90, STR_TOWN_BUILDING_NAME_CHURCH_1,                 200,   3,   2,   0,   0,
 
	MS(   0, CalendarTime::MAX_YEAR,   8,  90, STR_TOWN_BUILDING_NAME_CHURCH_1,                 200,   3,   2,   0,   0,
 
	   BUILDING_IS_CHURCH | TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 5B
 
	MS(   0, MAX_YEAR,  18,  90, STR_TOWN_BUILDING_NAME_HOUSES_2,                  90,   5,   6,   2,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  18,  90, STR_TOWN_BUILDING_NAME_HOUSES_2,                  90,   5,   6,   2,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 5C
 
	MS(   0, MAX_YEAR,   7,  70, STR_TOWN_BUILDING_NAME_HOUSES_2,                  50,   3,   3,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,   7,  70, STR_TOWN_BUILDING_NAME_HOUSES_2,                  50,   3,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 5D
 
	MS(   0, MAX_YEAR,  15,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  15,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 5E
 
	MS(   0, MAX_YEAR,  17,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  17,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 5F
 
	MS(   0, MAX_YEAR,  19,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  19,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 60
 
	MS(   0, MAX_YEAR,  21,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  21,  80, STR_TOWN_BUILDING_NAME_HOUSES_2,                  75,   6,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 61
 
	MS(   0, MAX_YEAR,  75, 160, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  20,   8,   4,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  75, 160, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  20,   8,   4,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 62
 
	MS(   0, MAX_YEAR,  35,  90, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   9,   4,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  35,  90, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   9,   4,   1,   2,
 
	   TILE_SIZE_1x2,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 63
 
	MS(   0, MAX_YEAR,   0,  90, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   0,   4,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,   0,  90, STR_TOWN_BUILDING_NAME_HOUSES_2,                  80,   0,   4,   1,   2,
 
	   TILE_NO_FLAG,
 
	   HZ_NOZNS,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 64
 
	MS(   0, MAX_YEAR,  85, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  18,   8,   4,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  85, 150, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  18,   8,   4,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 65
 
	MS(   0, MAX_YEAR,  11,  60, STR_TOWN_BUILDING_NAME_IGLOO_1,                   45,   3,   3,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  11,  60, STR_TOWN_BUILDING_NAME_IGLOO_1,                   45,   3,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 66
 
	MS(   0, MAX_YEAR,  10,  60, STR_TOWN_BUILDING_NAME_TEPEES_1,                  45,   3,   3,   1,   1,
 
	MS(   0, CalendarTime::MAX_YEAR,  10,  60, STR_TOWN_BUILDING_NAME_TEPEES_1,                  45,   3,   3,   1,   1,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 67
 
	MS(   0, MAX_YEAR,  67, 140, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      130,  22,   8,   4,   4,
 
	MS(   0, CalendarTime::MAX_YEAR,  67, 140, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      130,  22,   8,   4,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_FIZZY_DRINKS), // 68
 
	MS(   0, MAX_YEAR,  86, 145, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      130,  23,   8,   4,   4,
 
	MS(   0, CalendarTime::MAX_YEAR,  86, 145, STR_TOWN_BUILDING_NAME_SHOPS_AND_OFFICES_1,      130,  23,   8,   4,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_FIZZY_DRINKS), // 69
 
	MS(   0, MAX_YEAR,  95, 165, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  28,   8,   4,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  95, 165, STR_TOWN_BUILDING_NAME_TALL_OFFICE_BLOCK_1,      130,  28,   8,   4,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 6A
 
	MS(   0, MAX_YEAR,  30,  90, STR_TOWN_BUILDING_NAME_STATUE_1,                  70,  10,   4,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  30,  90, STR_TOWN_BUILDING_NAME_STATUE_1,                  70,  10,   4,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 6B
 
	MS(   0, MAX_YEAR,  25,  75, STR_TOWN_BUILDING_NAME_TEAPOT_HOUSE_1,            65,   8,   3,   1,   2,
 
	MS(   0, CalendarTime::MAX_YEAR,  25,  75, STR_TOWN_BUILDING_NAME_TEAPOT_HOUSE_1,            65,   8,   3,   1,   2,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_CANDY), // 6C
 
	MS(   0, MAX_YEAR,  18,  85, STR_TOWN_BUILDING_NAME_PIGGY_BANK_1,              95,   7,   3,   2,   4,
 
	MS(   0, CalendarTime::MAX_YEAR,  18,  85, STR_TOWN_BUILDING_NAME_PIGGY_BANK_1,              95,   7,   3,   2,   4,
 
	   TILE_SIZE_1x1,
 
	   HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
 
	   CT_PASSENGERS, CT_MAIL, CT_FIZZY_DRINKS), // 6D
 
};
 
#undef MS
 

	
src/timer/timer_game_calendar.cpp
Show inline comments
 
@@ -65,48 +65,48 @@ static const uint16_t _accum_days_for_mo
 

	
 
/**
 
 * Converts a Date to a Year, Month & Day.
 
 * @param date the date to convert from
 
 * @param ymd  the year, month and day to write to
 
 */
 
/* static */ void TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::Date date, YearMonthDay *ymd)
 
/* static */ void TimerGameCalendar::ConvertDateToYMD(TimerGameCalendar::Date date, TimerGameCalendar::YearMonthDay *ymd)
 
{
 
	/* Year determination in multiple steps to account for leap
 
	 * years. First do the large steps, then the smaller ones.
 
	 */
 

	
 
	/* There are 97 leap years in 400 years */
 
	TimerGameCalendar::Year yr = 400 * (static_cast<int32_t>(date) / (DAYS_IN_YEAR * 400 + 97));
 
	int rem = static_cast<int32_t>(date) % (DAYS_IN_YEAR * 400 + 97);
 
	TimerGameCalendar::Year yr = 400 * (static_cast<int32_t>(date) / (CalendarTime::DAYS_IN_YEAR * 400 + 97));
 
	int rem = static_cast<int32_t>(date) % (CalendarTime::DAYS_IN_YEAR * 400 + 97);
 
	uint16_t x;
 

	
 
	if (rem >= DAYS_IN_YEAR * 100 + 25) {
 
	if (rem >= CalendarTime::DAYS_IN_YEAR * 100 + 25) {
 
		/* There are 25 leap years in the first 100 years after
 
		 * every 400th year, as every 400th year is a leap year */
 
		yr += 100;
 
		rem -= DAYS_IN_YEAR * 100 + 25;
 
		rem -= CalendarTime::DAYS_IN_YEAR * 100 + 25;
 

	
 
		/* There are 24 leap years in the next couple of 100 years */
 
		yr += 100 * (rem / (DAYS_IN_YEAR * 100 + 24));
 
		rem = (rem % (DAYS_IN_YEAR * 100 + 24));
 
		yr += 100 * (rem / (CalendarTime::DAYS_IN_YEAR * 100 + 24));
 
		rem = (rem % (CalendarTime::DAYS_IN_YEAR * 100 + 24));
 
	}
 

	
 
	if (!TimerGameCalendar::IsLeapYear(yr) && rem >= DAYS_IN_YEAR * 4) {
 
	if (!TimerGameCalendar::IsLeapYear(yr) && rem >= CalendarTime::DAYS_IN_YEAR * 4) {
 
		/* The first 4 year of the century are not always a leap year */
 
		yr += 4;
 
		rem -= DAYS_IN_YEAR * 4;
 
		rem -= CalendarTime::DAYS_IN_YEAR * 4;
 
	}
 

	
 
	/* There is 1 leap year every 4 years */
 
	yr += 4 * (rem / (DAYS_IN_YEAR * 4 + 1));
 
	rem = rem % (DAYS_IN_YEAR * 4 + 1);
 
	yr += 4 * (rem / (CalendarTime::DAYS_IN_YEAR * 4 + 1));
 
	rem = rem % (CalendarTime::DAYS_IN_YEAR * 4 + 1);
 

	
 
	/* The last (max 3) years to account for; the first one
 
	 * can be, but is not necessarily a leap year */
 
	while (rem >= (TimerGameCalendar::IsLeapYear(yr) ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR)) {
 
		rem -= TimerGameCalendar::IsLeapYear(yr) ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR;
 
	while (rem >= (TimerGameCalendar::IsLeapYear(yr) ? CalendarTime::DAYS_IN_LEAP_YEAR : CalendarTime::DAYS_IN_YEAR)) {
 
		rem -= TimerGameCalendar::IsLeapYear(yr) ? CalendarTime::DAYS_IN_LEAP_YEAR : CalendarTime::DAYS_IN_YEAR;
 
		yr++;
 
	}
 

	
 
	/* Skip the 29th of February in non-leap years */
 
	if (!TimerGameCalendar::IsLeapYear(yr) && rem >= ACCUM_MAR - 1) rem++;
 

	
 
@@ -128,13 +128,13 @@ static const uint16_t _accum_days_for_mo
 
	/* Day-offset in a leap year */
 
	int days = _accum_days_for_month[month] + day - 1;
 

	
 
	/* Account for the missing of the 29th of February in non-leap years */
 
	if (!TimerGameCalendar::IsLeapYear(year) && days >= ACCUM_MAR) days--;
 

	
 
	return DateAtStartOfYear(year) + days;
 
	return TimerGameCalendar::DateAtStartOfYear(year) + days;
 
}
 

	
 
/**
 
 * Checks whether the given year is a leap year or not.
 
 * @param yr The year to check.
 
 * @return True if \c yr is a leap year, otherwise false.
 
@@ -150,13 +150,13 @@ static const uint16_t _accum_days_for_mo
 
 * @param fract The number of ticks that have passed on this date.
 
 */
 
/* static */ void TimerGameCalendar::SetDate(TimerGameCalendar::Date date, TimerGameCalendar::DateFract fract)
 
{
 
	assert(fract < Ticks::DAY_TICKS);
 

	
 
	YearMonthDay ymd;
 
	TimerGameCalendar::YearMonthDay ymd;
 

	
 
	TimerGameCalendar::date = date;
 
	TimerGameCalendar::date_fract = fract;
 
	TimerGameCalendar::ConvertDateToYMD(date, &ymd);
 
	TimerGameCalendar::year = ymd.year;
 
	TimerGameCalendar::month = ymd.month;
 
@@ -237,17 +237,17 @@ void TimerManager<TimerGameCalendar>::El
 
		for (auto timer : timers) {
 
			timer->Elapsed(TimerGameCalendar::YEAR);
 
		}
 
	}
 

	
 
	/* check if we reached the maximum year, decrement dates by a year */
 
	if (TimerGameCalendar::year == MAX_YEAR + 1) {
 
	if (TimerGameCalendar::year == CalendarTime::MAX_YEAR + 1) {
 
		int days_this_year;
 

	
 
		TimerGameCalendar::year--;
 
		days_this_year = TimerGameCalendar::IsLeapYear(TimerGameCalendar::year) ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR;
 
		days_this_year = TimerGameCalendar::IsLeapYear(TimerGameCalendar::year) ? CalendarTime::DAYS_IN_LEAP_YEAR : CalendarTime::DAYS_IN_YEAR;
 
		TimerGameCalendar::date -= days_this_year;
 
		for (Vehicle *v : Vehicle::Iterate()) v->ShiftDates(-days_this_year);
 
		for (LinkGraph *lg : LinkGraph::Iterate()) lg->ShiftDates(-days_this_year);
 
	}
 
}
 

	
src/timer/timer_game_calendar.h
Show inline comments
 
@@ -30,12 +30,35 @@
 
 *   IntervalTimer<TimerGameCalendar>({TimerGameCalendar::DAY, TimerGameCalendar::Priority::NONE}, [](uint count){});
 
 *
 
 * @note Callbacks are executed in the game-thread.
 
 */
 
class TimerGameCalendar {
 
public:
 
	/** The type to store our dates in. */
 
	using Date = StrongType::Typedef<int32_t, struct DateTag, StrongType::Compare, StrongType::Integer>;
 

	
 
	/** The fraction of a date we're in, i.e. the number of ticks since the last date changeover. */
 
	using DateFract = uint16_t;
 

	
 
	/** Type for the year, note: 0 based, i.e. starts at the year 0. */
 
	using Year = StrongType::Typedef<int32_t, struct YearTag, StrongType::Compare, StrongType::Integer>;
 
	/** Type for the month, note: 0 based, i.e. 0 = January, 11 = December. */
 
	using Month = uint8_t;
 
	/** Type for the day of the month, note: 1 based, first day of a month is 1. */
 
	using Day = uint8_t;
 

	
 
	/**
 
	 * Data structure to convert between Date and triplet (year, month, and day).
 
	 * @see TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::ConvertYMDToDate()
 
	 */
 
	struct YearMonthDay {
 
		Year  year;   ///< Year (0...)
 
		Month month;  ///< Month (0..11)
 
		Day   day;    ///< Day (1..31)
 
	};
 

	
 
	enum Trigger {
 
		DAY,
 
		WEEK,
 
		MONTH,
 
		QUARTER,
 
		YEAR,
 
@@ -74,41 +97,92 @@ public:
 
	};
 

	
 
	using TElapsed = uint;
 
	struct TStorage {
 
	};
 

	
 
	/** The type to store our dates in. */
 
	using Date = StrongType::Typedef<int32_t, struct DateTag, StrongType::Compare, StrongType::Integer>;
 

	
 
	/** The fraction of a date we're in, i.e. the number of ticks since the last date changeover. */
 
	using DateFract = uint16_t;
 

	
 
	/** Type for the year, note: 0 based, i.e. starts at the year 0. */
 
	using Year = StrongType::Typedef<int32_t, struct YearTag, StrongType::Compare, StrongType::Integer>;
 
	/** Type for the month, note: 0 based, i.e. 0 = January, 11 = December. */
 
	using Month = uint8_t;
 
	/** Type for the day of the month, note: 1 based, first day of a month is 1. */
 
	using Day = uint8_t;
 
	static bool IsLeapYear(Year yr);
 
	static void ConvertDateToYMD(Date date, YearMonthDay * ymd);
 
	static Date ConvertYMDToDate(Year year, Month month, Day day);
 
	static void SetDate(Date date, DateFract fract);
 

	
 
	/**
 
	 * Data structure to convert between Date and triplet (year, month, and day).
 
	 * @see TimerGameCalendar::ConvertDateToYMD(), TimerGameCalendar::ConvertYMDToDate()
 
	 */
 
	struct YearMonthDay {
 
		Year  year;   ///< Year (0...)
 
		Month month;  ///< Month (0..11)
 
		Day   day;    ///< Day (1..31)
 
	};
 
	* Calculate the year of a given date.
 
	* @param date The date to consider.
 
	* @return the year.
 
	*/
 
	static constexpr Year DateToYear(Date date)
 
	{
 
		/* Hardcode the number of days in a year because we can't access CalendarTime from here. */
 
		return static_cast<int32_t>(date) / 366;
 
	}
 

	
 
	static bool IsLeapYear(TimerGameCalendar::Year yr);
 
	static void ConvertDateToYMD(TimerGameCalendar::Date date, YearMonthDay *ymd);
 
	static TimerGameCalendar::Date ConvertYMDToDate(TimerGameCalendar::Year year, TimerGameCalendar::Month month, TimerGameCalendar::Day day);
 
	static void SetDate(TimerGameCalendar::Date date, TimerGameCalendar::DateFract fract);
 
	/**
 
	* Calculate the date of the first day of a given year.
 
	* @param year the year to get the first day of.
 
	* @return the date.
 
	*/
 
	static constexpr Date DateAtStartOfYear(Year year)
 
	{
 
		int32_t year_as_int = static_cast<int32_t>(year);
 
		uint number_of_leap_years = (year == 0) ? 0 : ((year_as_int - 1) / 4 - (year_as_int - 1) / 100 + (year_as_int - 1) / 400 + 1);
 

	
 
		/* Hardcode the number of days in a year because we can't access CalendarTime from here. */
 
		return (365 * year_as_int) + number_of_leap_years;
 
	}
 

	
 
	static Year year; ///< Current year, starting at 0.
 
	static Month month; ///< Current month (0..11).
 
	static Date date; ///< Current date in days (day counter).
 
	static DateFract date_fract; ///< Fractional part of the day.
 
};
 

	
 
/**
 
 * Storage class for Calendar time constants.
 
 */
 
class CalendarTime {
 
public:
 
	static constexpr int DAYS_IN_YEAR = 365; ///< days per year
 
	static constexpr int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more...
 
	static constexpr int MONTHS_IN_YEAR = 12; ///< months per year
 

	
 
	static constexpr int SECONDS_PER_DAY = 2;   ///< approximate seconds per day, not for precise calculations
 

	
 
	/*
 
	 * ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
 
	 * primarily used for loading newgrf and savegame data and returning some
 
	 * newgrf (callback) functions that were in the original (TTD) inherited
 
	 * format, where 'TimerGameCalendar::date == 0' meant that it was 1920-01-01.
 
	 */
 

	
 
	/** The minimum starting year/base year of the original TTD */
 
	static constexpr TimerGameCalendar::Year ORIGINAL_BASE_YEAR = 1920;
 
	/** The original ending year */
 
	static constexpr TimerGameCalendar::Year ORIGINAL_END_YEAR = 2051;
 
	/** The maximum year of the original TTD */
 
	static constexpr TimerGameCalendar::Year ORIGINAL_MAX_YEAR = 2090;
 

	
 
	/** The absolute minimum & maximum years in OTTD */
 
	static constexpr TimerGameCalendar::Year MIN_YEAR = 0;
 

	
 
	/** The default starting year */
 
	static constexpr TimerGameCalendar::Year DEF_START_YEAR = 1950;
 
	/** The default scoring end year */
 
	static constexpr TimerGameCalendar::Year DEF_END_YEAR = ORIGINAL_END_YEAR - 1;
 

	
 
	/**
 
	 * MAX_YEAR, nicely rounded value of the number of years that can
 
	 * be encoded in a single 32 bits date, about 2^31 / 366 years.
 
	 */
 
	static constexpr TimerGameCalendar::Year MAX_YEAR = 5000000;
 

	
 
	/** The date of the first day of the original base year. */
 
	static constexpr TimerGameCalendar::Date DAYS_TILL_ORIGINAL_BASE_YEAR = TimerGameCalendar::DateAtStartOfYear(ORIGINAL_BASE_YEAR);
 

	
 
	/** The date of the last day of the max year. */
 
	static constexpr TimerGameCalendar::Date MAX_DATE = TimerGameCalendar::DateAtStartOfYear(CalendarTime::MAX_YEAR + 1) - 1;
 

	
 
	static constexpr TimerGameCalendar::Year INVALID_YEAR = -1; ///< Representation of an invalid year
 
	static constexpr TimerGameCalendar::Date INVALID_DATE = -1; ///< Representation of an invalid date
 
};
 

	
 
#endif /* TIMER_GAME_CALENDAR_H */
src/timetable_cmd.cpp
Show inline comments
 
@@ -301,17 +301,17 @@ CommandCost CmdSetTimetableStart(DoComma
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	int total_duration = v->orders->GetTimetableTotalDuration();
 

	
 
	/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
 
	if (start_date < 0 || start_date > MAX_DATE) return CMD_ERROR;
 
	if (start_date - TimerGameCalendar::date > DateAtStartOfYear(MAX_TIMETABLE_START_YEARS)) return CMD_ERROR;
 
	if (TimerGameCalendar::date - start_date > DAYS_IN_LEAP_YEAR) return CMD_ERROR;
 
	if (start_date < 0 || start_date > CalendarTime::MAX_DATE) return CMD_ERROR;
 
	if (start_date - TimerGameCalendar::date > TimerGameCalendar::DateAtStartOfYear(MAX_TIMETABLE_START_YEARS)) return CMD_ERROR;
 
	if (TimerGameCalendar::date - start_date > CalendarTime::DAYS_IN_LEAP_YEAR) return CMD_ERROR;
 
	if (timetable_all && !v->orders->IsCompleteTimetable()) return CommandCost(STR_ERROR_TIMETABLE_INCOMPLETE);
 
	if (timetable_all && start_date + total_duration / Ticks::DAY_TICKS > MAX_DATE) return CMD_ERROR;
 
	if (timetable_all && start_date + total_duration / Ticks::DAY_TICKS > CalendarTime::MAX_DATE) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		std::vector<Vehicle *> vehs;
 

	
 
		if (timetable_all) {
 
			for (Vehicle *w = v->orders->GetFirstSharedVehicle(); w != nullptr; w = w->NextShared()) {
 
@@ -491,13 +491,13 @@ void UpdateVehicleTimetable(Vehicle *v, 
 
	v->lateness_counter -= (timetabled - time_taken);
 

	
 
	/* When we are more late than this timetabled bit takes we (somewhat expensively)
 
	 * check how many ticks the (fully filled) timetable has. If a timetable cycle is
 
	 * shorter than the amount of ticks we are late we reduce the lateness by the
 
	 * length of a full cycle till lateness is less than the length of a timetable
 
	 * cycle. When the timetable isn't fully filled the cycle will be Tick::INVALID_TICKS. */
 
	 * cycle. When the timetable isn't fully filled the cycle will be Ticks::INVALID_TICKS. */
 
	if (v->lateness_counter > (int)timetabled) {
 
		TimerGameTick::Ticks cycle = v->orders->GetTimetableTotalDuration();
 
		if (cycle != Ticks::INVALID_TICKS && v->lateness_counter > cycle) {
 
			v->lateness_counter %= cycle;
 
		}
 
	}
src/timetable_gui.cpp
Show inline comments
 
@@ -191,13 +191,13 @@ struct TimetableWindow : Window {
 
	}
 

	
 
	void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
 
	{
 
		switch (widget) {
 
			case WID_VT_ARRIVAL_DEPARTURE_PANEL:
 
				SetDParamMaxValue(1, DateAtStartOfYear(MAX_YEAR), 0, FS_SMALL);
 
				SetDParamMaxValue(1, TimerGameCalendar::DateAtStartOfYear(CalendarTime::MAX_YEAR), 0, FS_SMALL);
 
				size->width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE).width) + WidgetDimensions::scaled.hsep_wide + padding.width;
 
				FALLTHROUGH;
 

	
 
			case WID_VT_ARRIVAL_DEPARTURE_SELECTION:
 
			case WID_VT_TIMETABLE_PANEL:
 
				resize->height = FONT_HEIGHT_NORMAL;
src/toolbar_gui.cpp
Show inline comments
 
@@ -1145,13 +1145,13 @@ void ToggleDirtyBlocks()
 
/**
 
 * Set the starting year for a scenario.
 
 * @param year New starting year.
 
 */
 
void SetStartingYear(TimerGameCalendar::Year year)
 
{
 
	_settings_game.game_creation.starting_year = Clamp(year, MIN_YEAR, MAX_YEAR);
 
	_settings_game.game_creation.starting_year = Clamp(year, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
 
	TimerGameCalendar::Date new_date = TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
 
	/* If you open a savegame as scenario there may already be link graphs.*/
 
	LinkGraphSchedule::instance.ShiftDates(new_date - TimerGameCalendar::date);
 
	TimerGameCalendar::SetDate(new_date, 0);
 
}
 

	
 
@@ -2354,14 +2354,14 @@ struct ScenarioEditorToolbarWindow : Win
 
	{
 
		Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
 
	}
 

	
 
	void OnPaint() override
 
	{
 
		this->SetWidgetDisabledState(WID_TE_DATE_BACKWARD, _settings_game.game_creation.starting_year <= MIN_YEAR);
 
		this->SetWidgetDisabledState(WID_TE_DATE_FORWARD, _settings_game.game_creation.starting_year >= MAX_YEAR);
 
		this->SetWidgetDisabledState(WID_TE_DATE_BACKWARD, _settings_game.game_creation.starting_year <= CalendarTime::MIN_YEAR);
 
		this->SetWidgetDisabledState(WID_TE_DATE_FORWARD, _settings_game.game_creation.starting_year >= CalendarTime::MAX_YEAR);
 
		this->SetWidgetDisabledState(WID_TE_ROADS, (GetRoadTypes(true) & ~_roadtypes_type) == ROADTYPES_NONE);
 
		this->SetWidgetDisabledState(WID_TE_TRAMS, (GetRoadTypes(true) & _roadtypes_type) == ROADTYPES_NONE);
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
@@ -2395,13 +2395,13 @@ struct ScenarioEditorToolbarWindow : Win
 
		switch (widget) {
 
			case WID_TE_SPACER:
 
				size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width;
 
				break;
 

	
 
			case WID_TE_DATE:
 
				SetDParam(0, TimerGameCalendar::ConvertYMDToDate(MAX_YEAR, 0, 1));
 
				SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1));
 
				*size = GetStringBoundingBox(STR_JUST_DATE_LONG);
 
				break;
 
		}
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
@@ -2509,13 +2509,13 @@ struct ScenarioEditorToolbarWindow : Win
 

	
 
		TimerGameCalendar::Year value;
 
		if (!StrEmpty(str)) {
 
			value = atoi(str);
 
		} else {
 
			/* An empty string means revert to the default */
 
			value = static_cast<int32_t>(DEF_START_YEAR);
 
			value = static_cast<int32_t>(CalendarTime::DEF_START_YEAR);
 
		}
 
		SetStartingYear(value);
 

	
 
		this->SetDirty();
 
	}
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -868,13 +868,13 @@ RoadType GetTownRoadType(const Town *t)
 
		if (rti->label == 0) continue;
 

	
 
		/* Can town build this road. */
 
		if (!HasBit(rti->flags, ROTF_TOWN_BUILD)) continue;
 

	
 
		/* Not yet introduced at this date. */
 
		if (IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(MAX_DATE)) && rti->introduction_date > TimerGameCalendar::date) continue;
 
		if (IsInsideMM(rti->introduction_date, 0, static_cast<int32_t>(CalendarTime::MAX_DATE)) && rti->introduction_date > TimerGameCalendar::date) continue;
 

	
 
		if (best != nullptr) {
 
			if ((rti->max_speed == 0 ? assume_max_speed : rti->max_speed) < (best->max_speed == 0 ? assume_max_speed : best->max_speed)) continue;
 
		}
 

	
 
		best_rt = rt;
src/train_cmd.cpp
Show inline comments
 
@@ -4176,13 +4176,13 @@ void Train::OnNewDay()
 
			TileIndex tile = Station::Get(this->current_order.GetDestination())->train_station.tile;
 
			if (tile != INVALID_TILE) this->dest_tile = tile;
 
		}
 

	
 
		if (this->running_ticks != 0) {
 
			/* running costs */
 
			CommandCost cost(EXPENSES_TRAIN_RUN, this->GetRunningCost() * this->running_ticks / (DAYS_IN_YEAR  * Ticks::DAY_TICKS));
 
			CommandCost cost(EXPENSES_TRAIN_RUN, this->GetRunningCost() * this->running_ticks / (CalendarTime::DAYS_IN_YEAR  * Ticks::DAY_TICKS));
 

	
 
			this->profit_this_year -= cost.GetCost();
 
			this->running_ticks = 0;
 

	
 
			SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
src/vehicle.cpp
Show inline comments
 
@@ -1366,22 +1366,22 @@ bool Vehicle::HandleBreakdown()
 
/**
 
 * Update age of a vehicle.
 
 * @param v Vehicle to update.
 
 */
 
void AgeVehicle(Vehicle *v)
 
{
 
	if (v->age < MAX_DATE) {
 
	if (v->age < CalendarTime::MAX_DATE) {
 
		v->age++;
 
		if (v->IsPrimaryVehicle() && v->age == VEHICLE_PROFIT_MIN_AGE + 1) GroupStatistics::VehicleReachedMinAge(v);
 
	}
 

	
 
	if (!v->IsPrimaryVehicle() && (v->type != VEH_TRAIN || !Train::From(v)->IsEngine())) return;
 

	
 
	auto age = v->age - v->max_age;
 
	for (int32_t i = 0; i <= 4; i++) {
 
		if (age == DateAtStartOfYear(i)) {
 
		if (age == TimerGameCalendar::DateAtStartOfYear(i)) {
 
			v->reliability_spd_dec <<= 1;
 
			break;
 
		}
 
	}
 

	
 
	SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
@@ -1393,17 +1393,17 @@ void AgeVehicle(Vehicle *v)
 
	/* Don't warn if a renew is active */
 
	if (c->settings.engine_renew && v->GetEngine()->company_avail != 0) return;
 
	/* Don't warn if a replacement is active */
 
	if (EngineHasReplacementForCompany(c, v->engine_type, v->group_id)) return;
 

	
 
	StringID str;
 
	if (age == DateAtStartOfYear(-1)) {
 
	if (age == TimerGameCalendar::DateAtStartOfYear(-1)) {
 
		str = STR_NEWS_VEHICLE_IS_GETTING_OLD;
 
	} else if (age == DateAtStartOfYear(0)) {
 
	} else if (age == TimerGameCalendar::DateAtStartOfYear(0)) {
 
		str = STR_NEWS_VEHICLE_IS_GETTING_VERY_OLD;
 
	} else if (age > DateAtStartOfYear(0) && (static_cast<int32_t>(age) % DAYS_IN_LEAP_YEAR) == 0) {
 
	} else if (age > TimerGameCalendar::DateAtStartOfYear(0) && (static_cast<int32_t>(age) % CalendarTime::DAYS_IN_LEAP_YEAR) == 0) {
 
		str = STR_NEWS_VEHICLE_IS_GETTING_VERY_OLD_AND;
 
	} else {
 
		return;
 
	}
 

	
 
	SetDParam(0, v->index);
src/vehicle_func.h
Show inline comments
 
@@ -22,13 +22,13 @@
 
#include "livery.h"
 

	
 
#define is_custom_sprite(x) (x >= 0xFD)
 
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
 
#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
 

	
 
static const int VEHICLE_PROFIT_MIN_AGE = DAYS_IN_YEAR * 2; ///< Only vehicles older than this have a meaningful profit.
 
static const int VEHICLE_PROFIT_MIN_AGE = CalendarTime::DAYS_IN_YEAR * 2; ///< Only vehicles older than this have a meaningful profit.
 
static const Money VEHICLE_PROFIT_THRESHOLD = 10000;        ///< Threshold for a vehicle to be considered making good profit.
 

	
 
/**
 
 * Helper to check whether an image index is valid for a particular vehicle.
 
 * @tparam T The type of vehicle.
 
 * @param image_index The image index to check.
src/vehicle_gui.cpp
Show inline comments
 
@@ -1730,13 +1730,13 @@ void BaseVehicleListWindow::DrawVehicleL
 
				if (show_orderlist) DrawSmallOrderList(v, olr.left, olr.right, ir.top, this->order_arrow_width, v->cur_real_order_index);
 

	
 
				TextColour tc;
 
				if (v->IsChainInDepot()) {
 
					tc = TC_BLUE;
 
				} else {
 
					tc = (v->age > v->max_age - DAYS_IN_LEAP_YEAR) ? TC_RED : TC_BLACK;
 
					tc = (v->age > v->max_age - CalendarTime::DAYS_IN_LEAP_YEAR) ? TC_RED : TC_BLACK;
 
				}
 

	
 
				SetDParam(0, v->unitnumber);
 
				DrawString(ir.left, ir.right, ir.top + WidgetDimensions::scaled.framerect.top, STR_JUST_COMMA, tc);
 
				break;
 
			}
 
@@ -2435,13 +2435,13 @@ struct VehicleDetailsWindow : Window {
 
				*size = maxdim(*size, d);
 
				break;
 
			}
 

	
 
			case WID_VD_SERVICING_INTERVAL:
 
				SetDParamMaxValue(0, MAX_SERVINT_DAYS); // Roughly the maximum interval
 
				SetDParamMaxValue(1, DateAtStartOfYear(MAX_YEAR)); // Roughly the maximum year
 
				SetDParamMaxValue(1, TimerGameCalendar::DateAtStartOfYear(CalendarTime::MAX_YEAR)); // Roughly the maximum year
 
				size->width = std::max(
 
					GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT).width,
 
					GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS).width
 
				) + padding.width;
 
				size->height = FONT_HEIGHT_NORMAL + padding.height;
 
				break;
 
@@ -2492,15 +2492,15 @@ struct VehicleDetailsWindow : Window {
 

	
 
		switch (widget) {
 
			case WID_VD_TOP_DETAILS: {
 
				Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
 

	
 
				/* Draw running cost */
 
				SetDParam(1, DateToYear(v->age));
 
				SetDParam(0, (v->age + DAYS_IN_YEAR < v->max_age) ? STR_VEHICLE_INFO_AGE : STR_VEHICLE_INFO_AGE_RED);
 
				SetDParam(2, DateToYear(v->max_age));
 
				SetDParam(1, TimerGameCalendar::DateToYear(v->age));
 
				SetDParam(0, (v->age + CalendarTime::DAYS_IN_YEAR < v->max_age) ? STR_VEHICLE_INFO_AGE : STR_VEHICLE_INFO_AGE_RED);
 
				SetDParam(2, TimerGameCalendar::DateToYear(v->max_age));
 
				SetDParam(3, v->GetDisplayRunningCost());
 
				DrawString(tr, STR_VEHICLE_INFO_AGE_RUNNING_COST_YR);
 
				tr.top += FONT_HEIGHT_NORMAL;
 

	
 
				/* Draw max speed */
 
				StringID string;
0 comments (0 inline, 0 general)