From a7d8c6fe0c89c8b1622ef452c4c34ff822b869fc Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 9 Jun 2021 20:43:57 +0100 Subject: [PATCH] Add PF setting for whether to pathfind up to back of one-way PBS --- src/lang/english.txt | 2 ++ src/pathfinder/yapf/yapf_costrail.hpp | 3 ++- src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings.ini | 19 +++++++++++++------ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index be2fb8f8cb..80eae3b445 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1275,6 +1275,8 @@ STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS :Slope steepness STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS_HELPTEXT :Steepness of a sloped tile for a road vehicle. Higher values make it more difficult to climb a hill STR_CONFIG_SETTING_FORBID_90_DEG :Forbid trains from making 90° turns: {STRING2} STR_CONFIG_SETTING_FORBID_90_DEG_HELPTEXT :90 degree turns occur when a horizontal track is directly followed by a vertical track piece on the adjacent tile, thus making the train turn by 90 degree when traversing the tile edge instead of the usual 45 degrees for other track combinations. +STR_CONFIG_SETTING_BACK_ONE_WAY_PBS_SAFE_WAITING :Pathfind up to back of one-way path signals: {STRING2} +STR_CONFIG_SETTING_BACK_ONE_WAY_PBS_SAFE_WAITING_HELPTEXT :When enabled, the YAPF train pathfinder may pathfind up to the back of a one-way path signal. STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS :Allow to join stations not directly adjacent: {STRING2} STR_CONFIG_SETTING_DISTANT_JOIN_STATIONS_HELPTEXT :Allow adding parts to a station without directly touching the existing parts. Needs Ctrl+Click while placing the new parts STR_CONFIG_SETTING_INFLATION :Inflation: {STRING2} diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp index 58276b0bcc..1533482207 100644 --- a/src/pathfinder/yapf/yapf_costrail.hpp +++ b/src/pathfinder/yapf/yapf_costrail.hpp @@ -697,7 +697,8 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th if (HasSignalOnTrackdir(next.tile, next.td) && IsPbsSignal(GetSignalType(next.tile, TrackdirToTrack(next.td)))) { /* Possible safe tile. */ end_segment_reason |= ESRB_SAFE_TILE; - } else if (HasSignalOnTrackdir(next.tile, ReverseTrackdir(next.td)) && GetSignalType(next.tile, TrackdirToTrack(next.td)) == SIGTYPE_PBS_ONEWAY) { + } else if (likely(_settings_game.pf.back_of_one_way_pbs_waiting_point) && HasSignalOnTrackdir(next.tile, ReverseTrackdir(next.td)) && + GetSignalType(next.tile, TrackdirToTrack(next.td)) == SIGTYPE_PBS_ONEWAY) { /* Possible safe tile, but not so good as it's the back of a signal... */ end_segment_reason |= ESRB_SAFE_TILE | ESRB_DEAD_END; extra_cost += Yapf().PfGetSettings().rail_lastred_exit_penalty; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index d50820e980..06c43c1fb2 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1936,6 +1936,7 @@ static SettingsContainer &GetSettingsTree() routing->Add(new SettingEntry("pf.pathfinder_for_trains")); routing->Add(new SettingEntry("difficulty.line_reverse_mode")); routing->Add(new SettingEntry("pf.reverse_at_signals")); + routing->Add(new SettingEntry("pf.back_of_one_way_pbs_waiting_point")); routing->Add(new SettingEntry("pf.forbid_90_deg")); routing->Add(new SettingEntry("pf.pathfinder_for_roadvehs")); routing->Add(new SettingEntry("pf.pathfinder_for_ships")); diff --git a/src/settings_type.h b/src/settings_type.h index 7ab21e2596..e38788d014 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -529,6 +529,7 @@ struct PathfinderSettings { bool roadveh_queue; ///< buggy road vehicle queueing bool forbid_90_deg; ///< forbid trains to make 90 deg turns + bool back_of_one_way_pbs_waiting_point;///< whether the back of one-way PBS signals is a safe waiting point uint8 reroute_rv_on_layout_change; ///< whether to re-route road vehicles when the layout changes bool reverse_at_signals; ///< whether to reverse at signals at all diff --git a/src/table/settings.ini b/src/table/settings.ini index ce3f3f71bc..b1000f307f 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -1327,15 +1327,22 @@ strhelp = STR_CONFIG_SETTING_FORBID_90_DEG_HELPTEXT proc = InvalidateShipPathCache cat = SC_EXPERT -;; pf.back_of_one_way_pbs_waiting_point -[SDT_NULL] -length = 1 +[SDT_XREF] extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_JOKERPP) +xref = ""pf.back_of_one_way_pbs_waiting_point"" -;; pf.back_of_one_way_pbs_waiting_point -[SDT_NULL] -length = 1 +[SDT_XREF] extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_CHILLPP, SL_CHILLPP_232) +xref = ""pf.back_of_one_way_pbs_waiting_point"" + +[SDT_BOOL] +base = GameSettings +var = pf.back_of_one_way_pbs_waiting_point +def = true +str = STR_CONFIG_SETTING_BACK_ONE_WAY_PBS_SAFE_WAITING +str = STR_CONFIG_SETTING_BACK_ONE_WAY_PBS_SAFE_WAITING_HELPTEXT +cat = SC_EXPERT +patxname = ""pf.back_of_one_way_pbs_waiting_point"" [SDT_VAR] base = GameSettings