From f461f0de0841437f10845198009f13f54a731277 Mon Sep 17 00:00:00 2001 From: reldred Date: Mon, 22 Nov 2021 15:45:55 +1030 Subject: [PATCH] Introduces a new setting (defaulted off) to allow preventing road vehicles from performing so-called quantum tunelling through other vehicles blocking their path. --- src/lang/english.txt | 3 +++ src/roadveh_cmd.cpp | 2 +- src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings/settings.ini | 8 ++++++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 1951347941..bc6e17d42f 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1465,6 +1465,9 @@ STR_CONFIG_SETTING_FLIP_DIRECTION_ALL_TRAINS_HELPTEXT :Enable flipping STR_CONFIG_SETTING_ROADVEH_ARTICULATED_OVERTAKING :Articulated road vehicles may overtake: {STRING2} STR_CONFIG_SETTING_ROADVEH_ARTICULATED_OVERTAKING_HELPTEXT :Enable articulated road vehicles to overtake other road vehicles. +STR_CONFIG_SETTING_ROADVEH_CANT_QUANTUM_TUNNEL :Prevent vehicles from passing through other vehicles when blocked: {STRING2} +STR_CONFIG_SETTING_ROADVEH_CANT_QUANTUM_TUNNEL_HELPTEXT :Disable vehicles passing through other vehicles when their path is blocked for more than 1480 ticks. + STR_CONFIG_SETTING_DRIVE_THROUGH_TRAIN_DEPOT :Drive-through train depots: {STRING2} STR_CONFIG_SETTING_DRIVE_THROUGH_TRAIN_DEPOT_HELPTEXT :Enable emulation of drive-through train depots. Trains can move between depots placed back to back, optionally with intermediary depots in between. Requires the YAPF pathfinder. diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 9ec01ab4b6..2c61717320 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -743,7 +743,7 @@ static RoadVehicle *RoadVehFindCloseTo(RoadVehicle *v, int x, int y, Direction d return nullptr; } - if (update_blocked_ctr && ++front->blocked_ctr > 1480) return nullptr; + if (update_blocked_ctr && ++front->blocked_ctr > 1480 && (!_settings_game.vehicle.roadveh_cant_quantum_tunnel)) return nullptr; RoadVehicle *rv = RoadVehicle::From(rvf.best); if (rv != nullptr && front->IsRoadVehicleOnLevelCrossing() && (rv->First()->cur_speed == 0 || rv->First()->IsRoadVehicleStopped())) return nullptr; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 2e92d5f3a4..d83f862e27 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1951,6 +1951,7 @@ static SettingsContainer &GetSettingsTree() physics->Add(new SettingEntry("vehicle.plane_speed")); physics->Add(new SettingEntry("vehicle.ship_collision_avoidance")); physics->Add(new SettingEntry("vehicle.roadveh_articulated_overtaking")); + physics->Add(new SettingEntry("vehicle.roadveh_cant_quantum_tunnel")); physics->Add(new SettingEntry("vehicle.slow_road_vehicles_in_curves")); } diff --git a/src/settings_type.h b/src/settings_type.h index 97b76f6631..6cb3b75561 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -614,6 +614,7 @@ struct VehicleSettings { bool no_train_crash_other_company; ///< trains cannot crash with trains from other companies bool flip_direction_all_trains; ///< enable flipping direction in depot for all train engine types bool roadveh_articulated_overtaking; ///< enable articulated road vehicles overtaking other vehicles + bool roadveh_cant_quantum_tunnel; ///< enable or disable vehicles quantum tunelling through over vehicles when blocked bool drive_through_train_depot; ///< enable drive-through train depot emulation }; diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index 81d5a13af1..e488662f72 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -1798,6 +1798,14 @@ strhelp = STR_CONFIG_SETTING_ROADVEH_ARTICULATED_OVERTAKING_HELPTEXT patxname = ""roadveh_articulated_overtaking.vehicle.roadveh_articulated_overtaking"" cat = SC_BASIC +[SDT_BOOL] +var = vehicle.roadveh_cant_quantum_tunnel +def = false +str = STR_CONFIG_SETTING_ROADVEH_CANT_QUANTUM_TUNNEL +strhelp = STR_CONFIG_SETTING_ROADVEH_CANT_QUANTUM_TUNNEL_HELPTEXT +patxname = ""roadveh_cant_quantum_tunnel.vehicle.roadveh_cant_quantum_tunnel"" +cat = SC_BASIC + [SDT_BOOL] var = vehicle.drive_through_train_depot def = false