From b7c4d4030337cc60ecf66eec26c5a32585aac671 Mon Sep 17 00:00:00 2001 From: Tabytac <45774869+tabytac@users.noreply.github.com> Date: Wed, 16 Apr 2025 20:15:26 +0100 Subject: [PATCH] Feature: Add setting to disable vehicle intro date randomisation --- src/engine.cpp | 6 +++++- src/lang/english.txt | 3 +++ src/settingentry_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings/game_settings.ini | 7 +++++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/engine.cpp b/src/engine.cpp index d94a05ebe9..3814b056eb 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -737,7 +737,11 @@ void StartupOneEngine(Engine *e, const TimerGameCalendar::YearMonthDay &aging_ym /* Don't randomise the start-date in the first two years after gamestart to ensure availability * of engines in early starting games. * Note: TTDP uses fixed 1922 */ - e->intro_date = ei->base_intro <= TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (TimerGameCalendar::Date)GB(r, 0, 9) + ei->base_intro; + if (_settings_game.vehicle.vehicle_intro_randomisation) { + e->intro_date = ei->base_intro <= TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (TimerGameCalendar::Date)GB(r, 0, 9) + ei->base_intro; + } else { + e->intro_date = ei->base_intro; + } if (e->intro_date <= TimerGameCalendar::date) { TimerGameCalendar::YearMonthDay intro_ymd = TimerGameCalendar::ConvertDateToYMD(e->intro_date); int aging_months = aging_ymd.year.base() * 12 + aging_ymd.month; diff --git a/src/lang/english.txt b/src/lang/english.txt index aae384933b..45489c289d 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1511,6 +1511,9 @@ STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES_HELPTEXT :When enabled, a STR_CONFIG_SETTING_OFFER_VEHICLE_PREVIEW :Show vehicle previews: {STRING2} STR_CONFIG_SETTING_OFFER_VEHICLE_PREVIEW_HELPTEXT :When enabled, the top performing company is sometimes offered a 1 year exclusive preview of a vehicle +STR_CONFIG_SETTING_VEHICLE_INTRO_RANDOMISATION :Randomise vehicle introduction dates: {STRING2} +STR_CONFIG_SETTING_VEHICLE_INTRO_RANDOMISATION_HELPTEXT :When enabled, randomises vehicle introduction dates by up to 511 extra days from their original date + STR_CONFIG_SETTING_TIMEKEEPING_UNITS :Timekeeping: {STRING2} STR_CONFIG_SETTING_TIMEKEEPING_UNITS_HELPTEXT :Select the timekeeping units of the game. This cannot be changed later.{}{}Calendar-based is the classic OpenTTD experience, with a year consisting of 12 months, and each month having 28-31 days.{}{}In Wallclock-based time, cargo production and financials are instead based on one-minute increments, which is about as long as a 30 day month takes in Calendar-based mode. These are grouped into 12-minute periods, equivalent to a year in Calendar-based mode.{}{}In either mode there is always a classic calendar, which is used for introduction dates of vehicles, houses, and other infrastructure ###length 2 diff --git a/src/settingentry_gui.cpp b/src/settingentry_gui.cpp index 8d592714e1..adb985d2dd 100644 --- a/src/settingentry_gui.cpp +++ b/src/settingentry_gui.cpp @@ -821,6 +821,7 @@ SettingsContainer &GetSettingsTree() limitations->Add(new SettingEntry("station.never_expire_airports")); limitations->Add(new SettingEntry("vehicle.never_expire_vehicles")); limitations->Add(new SettingEntry("vehicle.offer_vehicle_preview")); + limitations->Add(new SettingEntry("vehicle.vehicle_intro_randomisation")); limitations->Add(new SettingEntry("vehicle.max_trains")); limitations->Add(new SettingEntry("vehicle.max_roadveh")); limitations->Add(new SettingEntry("vehicle.max_aircraft")); diff --git a/src/settings_type.h b/src/settings_type.h index 7bfb81f511..7b686e00e8 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -512,6 +512,7 @@ struct VehicleSettings { bool dynamic_engines; ///< enable dynamic allocation of engine data bool never_expire_vehicles; ///< never expire vehicles bool offer_vehicle_preview; ///< offer vehicle preview to companies + bool vehicle_intro_randomisation; ///< randomise the introduction dates of vehicles uint8_t extend_vehicle_life; ///< extend vehicle life by this many years uint8_t road_side; ///< the side of the road vehicles drive on uint8_t plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal diff --git a/src/table/settings/game_settings.ini b/src/table/settings/game_settings.ini index 055cf786d3..ab59094b39 100644 --- a/src/table/settings/game_settings.ini +++ b/src/table/settings/game_settings.ini @@ -248,6 +248,13 @@ def = true str = STR_CONFIG_SETTING_OFFER_VEHICLE_PREVIEW strhelp = STR_CONFIG_SETTING_OFFER_VEHICLE_PREVIEW_HELPTEXT +[SDT_BOOL] +var = vehicle.vehicle_intro_randomisation +flags = SettingFlag::NoNetwork +def = true +str = STR_CONFIG_SETTING_VEHICLE_INTRO_RANDOMISATION +strhelp = STR_CONFIG_SETTING_VEHICLE_INTRO_RANDOMISATION_HELPTEXT + [SDT_VAR] var = vehicle.max_trains type = SLE_UINT16