From ec40677fdc350823967fd1a2cbb048c38d9a4697 Mon Sep 17 00:00:00 2001 From: Andreas Schmitt Date: Thu, 17 Jun 2021 15:30:06 +0200 Subject: [PATCH] Add a setting to turn off road vehicle slowdown in curves Prior to this change, road vehicles would always slowdown in curves. This forces the player to build grid like roads. With new height levels and more mountainous maps and in the absense of diagonal roads this causes unnecessary pain. It should be an option to turn this off, so mountainous maps and curvy roads are not punishing the player unnecessarily. Nobody wants to build grid like roads outside of towns. --- src/lang/english.txt | 2 ++ src/roadveh_cmd.cpp | 5 ++++- src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings.ini | 13 +++++++++++-- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 17d9770f6a..dcbd355b13 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1807,6 +1807,8 @@ STR_CONFIG_SETTING_NOSERVICE :Disable servici STR_CONFIG_SETTING_NOSERVICE_HELPTEXT :When enabled, vehicles do not get serviced if they cannot break down STR_CONFIG_SETTING_WAGONSPEEDLIMITS :Enable wagon speed limits: {STRING2} STR_CONFIG_SETTING_WAGONSPEEDLIMITS_HELPTEXT :When enabled, also use speed limits of wagons for deciding the maximum speed of a train +STR_CONFIG_SETTING_SLOW_ROAD_VEHICLES_IN_CURVES :Road vehicles slow down in curves: {STRING2} +STR_CONFIG_SETTING_SLOW_ROAD_VEHICLES_IN_CURVES_HELPTEXT :When enabled, road vehicles slow down in curves. (Only with realistic acceleration) STR_CONFIG_SETTING_DISABLE_ELRAILS :Disable electric rails: {STRING2} STR_CONFIG_SETTING_DISABLE_ELRAILS_HELPTEXT :Enabling this setting disables the requirement to electrify tracks to make electric engines run on them diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 10db05c257..6cea05ac8b 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -496,7 +496,10 @@ inline int RoadVehicle::GetCurrentMaxSpeed() const if (this->state <= RVSB_TRACKDIR_MASK && IsReversingRoadTrackdir((Trackdir)this->state)) { max_speed = this->gcache.cached_max_track_speed / 2; break; - } else if ((u->direction & 1) == 0) { + } + + // Are we in a curve and should slow down? + if (((u->direction & 1) == 0) && _settings_game.vehicle.slow_road_vehicles_in_curves) { max_speed = this->gcache.cached_max_track_speed * 3 / 4; } } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 4425d0c54c..435157afdb 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1929,6 +1929,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.slow_road_vehicles_in_curves")); } SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING)); diff --git a/src/settings_type.h b/src/settings_type.h index c94585476d..6090628402 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -570,6 +570,7 @@ struct VehicleSettings { uint8 train_slope_steepness; ///< Steepness of hills for trains when using realistic acceleration uint8 roadveh_slope_steepness; ///< Steepness of hills for road vehicles when using realistic acceleration bool wagon_speed_limits; ///< enable wagon speed limits + bool slow_road_vehicles_in_curves; ///< Road vehicles slow down in curves. bool disable_elrails; ///< when true, the elrails are disabled UnitID max_trains; ///< max trains in game per company UnitID max_roadveh; ///< max trucks in game per company diff --git a/src/table/settings.ini b/src/table/settings.ini index ae61f4d6a1..2cfcfe0d00 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -1647,9 +1647,18 @@ strhelp = STR_CONFIG_SETTING_WAGONSPEEDLIMITS_HELPTEXT proc = UpdateConsists ;; vehicle.slow_road_vehicles_in_curves -[SDT_NULL] -length = 1 +[SDT_XREF] extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_JOKERPP, SL_JOKER_1_25) +xref = ""vehicle.slow_road_vehicles_in_curves"" + +[SDT_BOOL] +base = GameSettings +var = vehicle.slow_road_vehicles_in_curves +def = true +str = STR_CONFIG_SETTING_SLOW_ROAD_VEHICLES_IN_CURVES +strhelp = STR_CONFIG_SETTING_SLOW_ROAD_VEHICLES_IN_CURVES_HELPTEXT +cat = SC_BASIC +patxname = ""slow_road_vehicles_in_curves.vehicle.slow_road_vehicles_in_curves"" ;; vehicle.train_speed_adaption [SDT_NULL]