From 58ba8c122b8636d5cf3ea0e1f561dcd644ab5a38 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Tue, 31 Dec 2024 23:18:54 +0100 Subject: [PATCH] Codechange: use constructor instead of assignment for date/year constants --- src/currency.h | 6 +++--- src/industry.h | 2 +- src/linkgraph/linkgraph.h | 4 ++-- src/timer/timer_game_common.h | 24 ++++++++++++------------ src/timetable.h | 2 +- src/vehicle_func.h | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/currency.h b/src/currency.h index 71d1315aca..d7f8a75e07 100644 --- a/src/currency.h +++ b/src/currency.h @@ -14,9 +14,9 @@ #include "settings_type.h" #include "strings_type.h" -static constexpr TimerGameCalendar::Year CF_NOEURO = 0; ///< Currency never switches to the Euro (as far as known). -static constexpr TimerGameCalendar::Year CF_ISEURO = 1; ///< Currency _is_ the Euro. -static constexpr TimerGameCalendar::Year MIN_EURO_YEAR = 2000; ///< The earliest year custom currencies may switch to the Euro. +static constexpr TimerGameCalendar::Year CF_NOEURO{0}; ///< Currency never switches to the Euro (as far as known). +static constexpr TimerGameCalendar::Year CF_ISEURO{1}; ///< Currency _is_ the Euro. +static constexpr TimerGameCalendar::Year MIN_EURO_YEAR{2000}; ///< The earliest year custom currencies may switch to the Euro. /** * This enum gives the currencies a unique id which must be maintained for diff --git a/src/industry.h b/src/industry.h index b40b9c7c68..02b86fd728 100644 --- a/src/industry.h +++ b/src/industry.h @@ -23,7 +23,7 @@ typedef Pool IndustryPool; extern IndustryPool _industry_pool; -static const TimerGameEconomy::Year PROCESSING_INDUSTRY_ABANDONMENT_YEARS = 5; ///< If a processing industry doesn't produce for this many consecutive economy years, it may close. +static const TimerGameEconomy::Year PROCESSING_INDUSTRY_ABANDONMENT_YEARS{5}; ///< If a processing industry doesn't produce for this many consecutive economy years, it may close. /* * Production level maximum, minimum and default values. diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h index 76eebca10c..71cd9ccd72 100644 --- a/src/linkgraph/linkgraph.h +++ b/src/linkgraph/linkgraph.h @@ -170,10 +170,10 @@ public: static const uint MIN_TIMEOUT_DISTANCE = 32; /** Number of days before deleting links served only by vehicles stopped in depot. */ - static constexpr TimerGameEconomy::Date STALE_LINK_DEPOT_TIMEOUT = 1024; + static constexpr TimerGameEconomy::Date STALE_LINK_DEPOT_TIMEOUT{1024}; /** Minimum number of days between subsequent compressions of a LG. */ - static constexpr TimerGameEconomy::Date COMPRESSION_INTERVAL = 256; + static constexpr TimerGameEconomy::Date COMPRESSION_INTERVAL{256}; /** * Scale a value from a link graph of age orig_age for usage in one of age diff --git a/src/timer/timer_game_common.h b/src/timer/timer_game_common.h index d3548cac48..8ab619e51f 100644 --- a/src/timer/timer_game_common.h +++ b/src/timer/timer_game_common.h @@ -160,37 +160,37 @@ public: */ /** The minimum starting year/base year of the original TTD */ - static constexpr typename TimerGame::Year ORIGINAL_BASE_YEAR = 1920; + static constexpr typename TimerGame::Year ORIGINAL_BASE_YEAR{1920}; /** The original ending year */ - static constexpr typename TimerGame::Year ORIGINAL_END_YEAR = 2051; + static constexpr typename TimerGame::Year ORIGINAL_END_YEAR{2051}; /** The maximum year of the original TTD */ - static constexpr typename TimerGame::Year ORIGINAL_MAX_YEAR = 2090; + static constexpr typename TimerGame::Year ORIGINAL_MAX_YEAR{2090}; /** * 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 typename TimerGame::Year MAX_YEAR = 5000000; + static constexpr typename TimerGame::Year MAX_YEAR{5000000}; /** The absolute minimum year in OTTD */ - static constexpr typename TimerGame::Year MIN_YEAR = 0; + static constexpr typename TimerGame::Year MIN_YEAR{0}; /** The default starting year */ - static constexpr typename TimerGame::Year DEF_START_YEAR = 1950; + static constexpr typename TimerGame::Year DEF_START_YEAR{1950}; /** The default scoring end year */ - static constexpr typename TimerGame::Year DEF_END_YEAR = ORIGINAL_END_YEAR - 1; + static constexpr typename TimerGame::Year DEF_END_YEAR{ORIGINAL_END_YEAR - 1}; /** The date of the first day of the original base year. */ - static constexpr typename TimerGame::Date DAYS_TILL_ORIGINAL_BASE_YEAR = TimerGame::DateAtStartOfYear(ORIGINAL_BASE_YEAR); + static constexpr typename TimerGame::Date DAYS_TILL_ORIGINAL_BASE_YEAR{TimerGame::DateAtStartOfYear(ORIGINAL_BASE_YEAR)}; /** The date of the last day of the max year. */ - static constexpr typename TimerGame::Date MAX_DATE = TimerGame::DateAtStartOfYear(MAX_YEAR + 1) - 1; + static constexpr typename TimerGame::Date MAX_DATE{TimerGame::DateAtStartOfYear(MAX_YEAR + 1) - 1}; /** The date on January 1, year 0. */ - static constexpr typename TimerGame::Date MIN_DATE = 0; + static constexpr typename TimerGame::Date MIN_DATE{0}; - static constexpr typename TimerGame::Year INVALID_YEAR = -1; ///< Representation of an invalid year - static constexpr typename TimerGame::Date INVALID_DATE = -1; ///< Representation of an invalid date + static constexpr typename TimerGame::Year INVALID_YEAR{-1}; ///< Representation of an invalid year + static constexpr typename TimerGame::Date INVALID_DATE{-1}; ///< Representation of an invalid date }; #endif /* TIMER_GAME_COMMON_H */ diff --git a/src/timetable.h b/src/timetable.h index 16b6ceb03f..dd1607e294 100644 --- a/src/timetable.h +++ b/src/timetable.h @@ -14,7 +14,7 @@ #include "timer/timer_game_economy.h" #include "vehicle_type.h" -static const TimerGameEconomy::Year MAX_TIMETABLE_START_YEARS = 15; ///< The maximum start date offset, in economy years. +static const TimerGameEconomy::Year MAX_TIMETABLE_START_YEARS{15}; ///< The maximum start date offset, in economy years. enum class TimetableMode : uint8_t { Days, diff --git a/src/vehicle_func.h b/src/vehicle_func.h index 48ecfb2da0..195cbf8c0d 100644 --- a/src/vehicle_func.h +++ b/src/vehicle_func.h @@ -25,7 +25,7 @@ #define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD) #define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE) -static const TimerGameEconomy::Date VEHICLE_PROFIT_MIN_AGE = CalendarTime::DAYS_IN_YEAR * 2; ///< Only vehicles older than this have a meaningful profit. +static const TimerGameEconomy::Date 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. /**