1
0
Fork 0

Add vehicle introduction randomisation setting and update logic

pull/14015/head^2
Tabytac 2025-04-16 20:15:26 +01:00
parent 1d6aee07d6
commit 324012593d
5 changed files with 17 additions and 1 deletions

View File

@ -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 /* Don't randomise the start-date in the first two years after gamestart to ensure availability
* of engines in early starting games. * of engines in early starting games.
* Note: TTDP uses fixed 1922 */ * 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) { if (e->intro_date <= TimerGameCalendar::date) {
TimerGameCalendar::YearMonthDay intro_ymd = TimerGameCalendar::ConvertDateToYMD(e->intro_date); TimerGameCalendar::YearMonthDay intro_ymd = TimerGameCalendar::ConvertDateToYMD(e->intro_date);
int aging_months = aging_ymd.year.base() * 12 + aging_ymd.month; int aging_months = aging_ymd.year.base() * 12 + aging_ymd.month;

View File

@ -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 :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_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 :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 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 ###length 2

View File

@ -821,6 +821,7 @@ SettingsContainer &GetSettingsTree()
limitations->Add(new SettingEntry("station.never_expire_airports")); limitations->Add(new SettingEntry("station.never_expire_airports"));
limitations->Add(new SettingEntry("vehicle.never_expire_vehicles")); limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
limitations->Add(new SettingEntry("vehicle.offer_vehicle_preview")); 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_trains"));
limitations->Add(new SettingEntry("vehicle.max_roadveh")); limitations->Add(new SettingEntry("vehicle.max_roadveh"));
limitations->Add(new SettingEntry("vehicle.max_aircraft")); limitations->Add(new SettingEntry("vehicle.max_aircraft"));

View File

@ -512,6 +512,7 @@ struct VehicleSettings {
bool dynamic_engines; ///< enable dynamic allocation of engine data bool dynamic_engines; ///< enable dynamic allocation of engine data
bool never_expire_vehicles; ///< never expire vehicles bool never_expire_vehicles; ///< never expire vehicles
bool offer_vehicle_preview; ///< offer vehicle preview to companies 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 extend_vehicle_life; ///< extend vehicle life by this many years
uint8_t road_side; ///< the side of the road vehicles drive on 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 uint8_t plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal

View File

@ -248,6 +248,13 @@ def = true
str = STR_CONFIG_SETTING_OFFER_VEHICLE_PREVIEW str = STR_CONFIG_SETTING_OFFER_VEHICLE_PREVIEW
strhelp = STR_CONFIG_SETTING_OFFER_VEHICLE_PREVIEW_HELPTEXT 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] [SDT_VAR]
var = vehicle.max_trains var = vehicle.max_trains
type = SLE_UINT16 type = SLE_UINT16